Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
tests: use example.com personas instead of real domains and names
Antonio Ojeaa9acd904d46e
diff --git a/api/ingress_test.go b/api/ingress_test.goindex 14472b38..f7a904bd 100644--- a/api/ingress_test.go+++ b/api/ingress_test.go@@ -61,7 +61,7 @@ func TestValidateServiceIngress(t *testing.T) {svcType: ServiceType_SERVICE_TYPE_MCP,ing: &ServiceIngress{AuthMode: IngressAuthMode_INGRESS_AUTH_MODE_EDGE,- Allow: []string{"email:[email protected]", "email:*@google.com", "node:" + pid.String()},+ Allow: []string{"email:[email protected]", "email:*@example.com", "node:" + pid.String()},},},{@@ -119,7 +119,7 @@ func TestServiceIngressFromConfig(t *testing.T) {}got, err = ServiceIngressFromConfig(ServiceType_SERVICE_TYPE_A2A, &IngressConfig{- Allow: []string{"email:[email protected]"},+ Allow: []string{"email:[email protected]"},})if err != nil {t.Fatalf("ServiceIngressFromConfig default mode: %v", err)@@ -237,7 +237,7 @@ func TestValidateIngressURL(t *testing.T) {func TestMatchIngressAllow(t *testing.T) {pid := testPeerID(t)claims := map[string][]string{- FactEmail: {"[email protected]"},+ FactEmail: {"[email protected]"},FactGroup: {"a2a-team"},FactNode: {pid.String()},}@@ -251,8 +251,8 @@ func TestMatchIngressAllow(t *testing.T) {if !MatchIngressAllow([]string{SystemAuthenticated}, claims) {t.Fatal("SystemAuthenticated must match non-empty identity claims")}- if !MatchIngressAllow([]string{"email:*@google.com"}, claims) {- t.Fatal("wildcard domain should match [email protected]")+ if !MatchIngressAllow([]string{"email:*@example.com"}, claims) {+ t.Fatal("wildcard domain should match [email protected]")}if !MatchIngressAllow([]string{"node:" + pid.String()}, claims) {t.Fatal("exact node peer ID should match")diff --git a/internal/identity/biscuit_test.go b/internal/identity/biscuit_test.goindex 18354b1d..f8267c88 100644--- a/internal/identity/biscuit_test.go+++ b/internal/identity/biscuit_test.go@@ -115,7 +115,7 @@ func TestMintBiscuitToken_ClaimsTranslation(t *testing.T) {claims := jwt.MapClaims{"sub": "user-12345",- "email": "[email protected]",+ "email": "[email protected]","groups": []any{"beta-testers", "engineering"},}@@ -144,11 +144,11 @@ func TestMintBiscuitToken_ClaimsTranslation(t *testing.T) {}}authorizer.AddCheck(checkUser)- // Verify email("[email protected]") fact is present+ // Verify email("[email protected]") fact is presentcheckEmail := biscuit.Check{Queries: []biscuit.Rule{{Body: []biscuit.Predicate{- {Name: "email", IDs: []biscuit.Term{biscuit.String("[email protected]")}},+ {Name: "email", IDs: []biscuit.Term{biscuit.String("[email protected]")}},},},}}diff --git a/internal/identity/ingress_test.go b/internal/identity/ingress_test.goindex 3eeeb2b1..3cfe8cf8 100644--- a/internal/identity/ingress_test.go+++ b/internal/identity/ingress_test.go@@ -111,7 +111,7 @@ func TestAuthorizeIngressCallers(t *testing.T) {},}bindings := []*api.PolicyBinding{- {Role: "caller-role", Members: []string{"email:*@google.com"}},+ {Role: "caller-role", Members: []string{"email:*@example.com"}},}compiled, warnings := api.BuildPolicyRules(roles, bindings)if len(warnings) != 0 {@@ -208,7 +208,7 @@ func TestAuthorizeIngressCallers(t *testing.T) {}delRaw, err := MintDelegatedBiscuitToken(priv, jwt.MapClaims{"sub": "uid-1",- "email": "[email protected]",+ "email": "[email protected]",}, actorPeer, time.Now().Add(time.Hour), []string{"caller-role"}, roles, tarRule, true)if err != nil {t.Fatalf("MintDelegatedBiscuitToken: %v", err)@@ -230,14 +230,14 @@ func TestAuthorizeIngressCallers(t *testing.T) {Path: "/message:send",TargetFacts: targetFacts,MeshPolicyRules: meshRules,- Allow: []string{"email:[email protected]"},+ Allow: []string{"email:[email protected]"},Timeout: time.Second,})if err != nil {t.Fatalf("AuthorizeIngressDelegatedBiscuit: %v", err)}- if res.Principal != "[email protected]" || res.TaskName != "assist-only" {- t.Fatalf("got principal=%q task=%q, want [email protected] / assist-only", res.Principal, res.TaskName)+ if res.Principal != "[email protected]" || res.TaskName != "assist-only" {+ t.Fatalf("got principal=%q task=%q, want [email protected] / assist-only", res.Principal, res.TaskName)}// TAR blocks mcp://calc even though role grants it.@@ -261,7 +261,7 @@ func TestAuthorizeIngressCallers(t *testing.T) {Path: "/message:send",TargetFacts: targetFacts,MeshPolicyRules: meshRules,- Allow: []string{"email:[email protected]"},+ Allow: []string{"email:[email protected]"},Timeout: time.Second,}); err == nil {t.Fatal("expected allow list mismatch to deny")diff --git a/tests/integration/ingress_test.go b/tests/integration/ingress_test.goindex faf22f17..4dbcb03f 100644--- a/tests/integration/ingress_test.go+++ b/tests/integration/ingress_test.go@@ -273,7 +273,7 @@ func TestStandaloneExternalIngressCUJ(t *testing.T) {Bindings: []*api.PolicyBinding{{Role: "external-caller",- Members: []string{"email:[email protected]", "email:[email protected]"},+ Members: []string{"email:[email protected]", "email:[email protected]"},},},})@@ -379,7 +379,7 @@ func TestStandaloneExternalIngressCUJ(t *testing.T) {Type: "a2a",Name: "coder",TargetURL: coderBackend.URL,- Ingress: &api.IngressConfig{AuthMode: "edge", Allow: []string{"email:[email protected]"}},+ Ingress: &api.IngressConfig{AuthMode: "edge", Allow: []string{"email:[email protected]"}},},{Type: "a2a",@@ -476,10 +476,10 @@ func TestStandaloneExternalIngressCUJ(t *testing.T) {// Raw OIDC JWT presented directly to /ingress/ is rejected with 401 + RFC 9728 WWW-Authenticate// (external callers exchange JWTs at POST /oauth/token into Delegated Session Biscuits).- yaroslavJWT := mintJWT(map[string]any{"sub": "yaroslav-sub", "email": "[email protected]"})+ carolJWT := mintJWT(map[string]any{"sub": "carol-sub", "email": "[email protected]"})rawJWTReq, _ := http.NewRequestWithContext(ctx, http.MethodPost, wantInvokeURL, strings.NewReader(`{"jsonrpc":"2.0","id":1,"method":"message/send"}`))rawJWTReq.Header.Set("Content-Type", "application/json")- rawJWTReq.Header.Set("Authorization", "Bearer "+yaroslavJWT)+ rawJWTReq.Header.Set("Authorization", "Bearer "+carolJWT)rawJWTResp, err := httpClient.Do(rawJWTReq)if err != nil {t.Fatalf("raw JWT POST: %v", err)@@ -501,22 +501,22 @@ func TestStandaloneExternalIngressCUJ(t *testing.T) {}// Authorized Delegated Session Biscuit succeeds on both SendMessage and SSE SendStreamingMessage.- yaroslavBiscuit := exchangeJWTForBiscuit(t, srv.PublicURL(), yaroslavJWT, "", false)- allowedClient, err := a2aclient.NewFromCard(ctx, publicCoderCard, a2aclient.WithJSONRPCTransport(bearerClient(yaroslavBiscuit, nil)))+ carolBiscuit := exchangeJWTForBiscuit(t, srv.PublicURL(), carolJWT, "", false)+ allowedClient, err := a2aclient.NewFromCard(ctx, publicCoderCard, a2aclient.WithJSONRPCTransport(bearerClient(carolBiscuit, nil)))if err != nil {- t.Fatalf("NewFromCard(yaroslav): %v", err)+ t.Fatalf("NewFromCard(carol): %v", err)}sendRes, err := allowedClient.SendMessage(ctx, &a2a.SendMessageRequest{Message: a2a.NewMessage(a2a.MessageRoleUser, a2a.NewTextPart("hi"))})if err != nil {- t.Fatalf("SendMessage(yaroslav): %v", err)+ t.Fatalf("SendMessage(carol): %v", err)}replyMsg, ok := sendRes.(*a2a.Message)if !ok || len(replyMsg.Parts) == 0 || replyMsg.Parts[0].Text() != "hello from laptop" {t.Fatalf("SendMessage reply = %#v, want 'hello from laptop'", sendRes)}evPrincipal, _ := lastPrincipal.Load().(string)- if !strings.Contains(evPrincipal, "yaroslav") {- t.Fatalf("backend X-Mesh-Principal = %q, want yaroslav identity", evPrincipal)+ if !strings.Contains(evPrincipal, "carol") {+ t.Fatalf("backend X-Mesh-Principal = %q, want carol identity", evPrincipal)}var streamed []a2a.Event@@ -536,7 +536,7 @@ func TestStandaloneExternalIngressCUJ(t *testing.T) {// Exchange OIDC JWT at POST /oauth/token into a TAR-attenuated, sealed Session Biscuit// scoped exclusively to mcp://tools tool "read_file".tarJSON := `{"name":"read-only","rules":[{"allowed_services":["mcp://tools"],"operation":{"allowed_tools":["read_file"]}}]}`- tarBiscuit := exchangeJWTForBiscuit(t, srv.PublicURL(), yaroslavJWT, tarJSON, true)+ tarBiscuit := exchangeJWTForBiscuit(t, srv.PublicURL(), carolJWT, tarJSON, true)mcpURL := fmt.Sprintf("%s/%s/mcp/tools", srv.IngressURL(), peerID)mcpCli := mcp.NewClient(&mcp.Implementation{Name: "external-mcp-caller", Version: "1.0.0"}, nil)@@ -677,7 +677,7 @@ func TestFederatedMultiRouterIngressRoleCeilingAndBan(t *testing.T) {Bindings: []*api.PolicyBinding{{Role: api.RoleRouter, Members: []string{"group:routers"}},{Role: api.RoleNode, Members: []string{"email:[email protected]"}},- {Role: "external-caller", Members: []string{"email:[email protected]"}},+ {Role: "external-caller", Members: []string{"email:[email protected]"}},},})@@ -840,11 +840,11 @@ func TestFederatedMultiRouterIngressRoleCeilingAndBan(t *testing.T) {}// External caller exchanges OIDC JWT at POST /oauth/token and invokes a2a://coder through Router B -> Router A circuit relay -> private node.- alanJWT := mintJWT(map[string]any{"sub": "alan-sub", "email": "[email protected]"})- alanBiscuit := exchangeJWTForBiscuit(t, cpURL, alanJWT, "", false)- a2aCli, err := a2aclient.NewFromCard(ctx, resolvedCard, a2aclient.WithJSONRPCTransport(bearerClient(alanBiscuit, nil)))+ daveJWT := mintJWT(map[string]any{"sub": "dave-sub", "email": "[email protected]"})+ daveBiscuit := exchangeJWTForBiscuit(t, cpURL, daveJWT, "", false)+ a2aCli, err := a2aclient.NewFromCard(ctx, resolvedCard, a2aclient.WithJSONRPCTransport(bearerClient(daveBiscuit, nil)))if err != nil {- t.Fatalf("NewFromCard(alan): %v", err)+ t.Fatalf("NewFromCard(dave): %v", err)}res, err := a2aCli.SendMessage(ctx, &a2a.SendMessageRequest{Message: a2a.NewMessage(a2a.MessageRoleUser, a2a.NewTextPart("ping"))})if err != nil {