mirror of
https://github.com/hanzoai/agents.git
synced 2026-10-30 18:48:36 +00:00
Transforms hanzoai/agents from a marketplace config repo into a full agent orchestration platform by merging the AgentField infrastructure: - Go control plane (K8s-like agent orchestration, service mesh, DAG workflows) - Python SDK (FastAPI-based agent framework, LiteLLM, memory, DID/VC) - TypeScript SDK (@hanzo/agents - Vercel AI SDK, MCP, workflows) - Go SDK (idiomatic agent builder + client) - React 19 embedded dashboard (XyFlow DAGs, Recharts, Radix UI) - Docker/K8s/Helm deployment configs - Examples: hello world, deep research, RAG, simulation, benchmarks - Functional test suite across Python/Go/TypeScript All references rebranded: AgentField → Hanzo Agents - Module: github.com/hanzoai/agents/control-plane - Python: hanzo_agents - TypeScript: @hanzo/agents - Go: github.com/hanzoai/agents/sdk/go - Env vars: HANZO_AGENTS_* - Config: hanzo-agents.yaml Previous marketplace configs moved to config/ directory.
71 lines
1.8 KiB
Go
71 lines
1.8 KiB
Go
package services
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/hanzoai/agents/control-plane/internal/config"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestKeystoreServiceLocalLifecycle(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
keystoreDir := t.TempDir()
|
|
svc, err := NewKeystoreService(&config.KeystoreConfig{Path: keystoreDir, Type: "local"})
|
|
require.NoError(t, err)
|
|
|
|
keyID := "agent-secret"
|
|
payload := []byte("super-secret")
|
|
|
|
require.NoError(t, svc.StoreKey(keyID, payload))
|
|
|
|
storedPath := filepath.Join(keystoreDir, keyID+".key")
|
|
fileContents, err := os.ReadFile(storedPath)
|
|
require.NoError(t, err)
|
|
require.NotEqual(t, payload, fileContents, "data should be encrypted on disk")
|
|
|
|
retrieved, err := svc.RetrieveKey(keyID)
|
|
require.NoError(t, err)
|
|
require.Equal(t, payload, retrieved)
|
|
|
|
keys, err := svc.ListKeys()
|
|
require.NoError(t, err)
|
|
require.ElementsMatch(t, []string{keyID}, keys)
|
|
|
|
encrypted, err := svc.EncryptData([]byte("plaintext"))
|
|
require.NoError(t, err)
|
|
require.False(t, bytes.Equal(encrypted, []byte("plaintext")))
|
|
|
|
decrypted, err := svc.DecryptData(encrypted)
|
|
require.NoError(t, err)
|
|
require.Equal(t, []byte("plaintext"), decrypted)
|
|
|
|
require.NoError(t, svc.DeleteKey(keyID))
|
|
require.NoError(t, svc.DeleteKey(keyID))
|
|
|
|
keys, err = svc.ListKeys()
|
|
require.NoError(t, err)
|
|
require.Empty(t, keys)
|
|
|
|
require.NoError(t, svc.BackupKeys())
|
|
}
|
|
|
|
func TestKeystoreServiceRejectsNonLocal(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
svc, err := NewKeystoreService(&config.KeystoreConfig{Path: t.TempDir(), Type: "local"})
|
|
require.NoError(t, err)
|
|
|
|
svc.config.Type = "remote"
|
|
require.Error(t, svc.StoreKey("id", []byte("data")))
|
|
_, err = svc.RetrieveKey("id")
|
|
require.Error(t, err)
|
|
require.Error(t, svc.DeleteKey("id"))
|
|
_, err = svc.ListKeys()
|
|
require.Error(t, err)
|
|
}
|