JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
Update A2A credential handling to ensure apiKeySecurityScheme is treated as non-sensitive. Added unit tests to verify persistence and correct behavior of API key schemes in various locations (header, query, cookie).
NickFuryXXXce199fb95941
diff --git a/jiuwenswarm/gateway/a2a_manager/outbound/models.py b/jiuwenswarm/gateway/a2a_manager/outbound/models.pyindex 87545a1455..f0383a2e82 100644--- a/jiuwenswarm/gateway/a2a_manager/outbound/models.py+++ b/jiuwenswarm/gateway/a2a_manager/outbound/models.py@@ -76,6 +76,9 @@ _SENSITIVE_KEY_COMPACTS = (def _is_sensitive_key(key: str) -> bool:+ # A2A protocol metadata describes credential placement, not a credential value.+ if key == "apiKeySecurityScheme":+ return Falsenormalized = key.strip().lower().replace("-", "_")compact = normalized.replace("_", "")return (diff --git a/tests/unit_tests/gateway/test_manager_config_receiver_a2a.py b/tests/unit_tests/gateway/test_manager_config_receiver_a2a.pyindex 9ded0c991d..b2c8e28872 100644--- a/tests/unit_tests/gateway/test_manager_config_receiver_a2a.py+++ b/tests/unit_tests/gateway/test_manager_config_receiver_a2a.py@@ -1022,3 +1022,40 @@ def test_credential_receiver_network_policy(a2a_receiver, host, scheme, flags):response = client.post("/api/v1/a2a-outbound-templates", json=payload)assert response.status_code == (200 if allowed else 400)assert bool(secrets.values) is allowed++[email protected]("location", ["header", "query", "cookie"])+def test_api_key_scheme_survives_persistence_and_builds_auth(a2a_receiver, location):+ from jiuwenswarm.gateway.a2a_manager.outbound.credentials import A2AOutboundCredentialStore+ from jiuwenswarm.gateway.a2a_manager.outbound.models import sanitize_persisted_value++ client, repos, _ = a2a_receiver+ payload = _outbound_payload()+ payload["agent_card"]["securitySchemes"] = {+ "ingress": {"apiKeySecurityScheme": {+ "location": location, "name": "X-API-Key", "api_key": "must-redact",+ }},+ }+ payload["agent_card"]["securityRequirements"] = [{"schemes": {"ingress": []}}]+ path = "/api/v1/a2a-outbound-templates"+ assert client.post(path, json=payload).status_code == 200+ stored = repos["a2a_outbound_template"]+ row = client.portal.call(lambda: stored.get(template_id="a2a-weather"))+ scheme = row["agent_card"]["securitySchemes"]["ingress"]["apiKeySecurityScheme"]+ assert scheme == {"location": location, "name": "X-API-Key", "api_key": "******"}+ card = sanitize_persisted_value(row["agent_card"])+ assert card == row["agent_card"]+ credential = A2AOutboundCredentialStore().get(row["credential_ref"])+ assert credential == "secret"+ headers, params, cookies = A2AOutboundDispatcher._credential_transport_options(card, credential)+ assert {"header": headers, "query": params, "cookie": cookies}[location] == {+ "X-API-Key": "secret",+ }+ # Replaying a complete Card repairs an already-redacted stored definition.+ broken = {**card, "securitySchemes": {"ingress": {"apiKeySecurityScheme": "******"}}}+ client.portal.call(lambda: stored.update(+ {"template_id": "a2a-weather"}, {"agent_card": broken},+ ))+ assert client.post(path, json=payload).status_code == 200+ restored = client.portal.call(lambda: stored.get(template_id="a2a-weather"))+ assert restored["agent_card"] == card