|
4 | 4 | import static io.a2a.client.JsonMessages.AUTHENTICATION_EXTENDED_AGENT_CARD; |
5 | 5 | import static io.a2a.client.JsonMessages.CANCEL_TASK_TEST_REQUEST; |
6 | 6 | import static io.a2a.client.JsonMessages.CANCEL_TASK_TEST_RESPONSE; |
| 7 | +import static io.a2a.client.JsonMessages.GET_AUTHENTICATED_EXTENDED_AGENT_CARD_REQUEST; |
| 8 | +import static io.a2a.client.JsonMessages.GET_AUTHENTICATED_EXTENDED_AGENT_CARD_RESPONSE; |
7 | 9 | import static io.a2a.client.JsonMessages.GET_TASK_PUSH_NOTIFICATION_CONFIG_TEST_REQUEST; |
8 | 10 | import static io.a2a.client.JsonMessages.GET_TASK_PUSH_NOTIFICATION_CONFIG_TEST_RESPONSE; |
9 | 11 | import static io.a2a.client.JsonMessages.GET_TASK_TEST_REQUEST; |
|
38 | 40 |
|
39 | 41 | import io.a2a.spec.A2AServerException; |
40 | 42 | import io.a2a.spec.AgentCard; |
| 43 | +import io.a2a.spec.AgentCardSignature; |
| 44 | +import io.a2a.spec.AgentInterface; |
41 | 45 | import io.a2a.spec.AgentSkill; |
42 | 46 | import io.a2a.spec.Artifact; |
43 | 47 | import io.a2a.spec.CancelTaskResponse; |
|
46 | 50 | import io.a2a.spec.FilePart; |
47 | 51 | import io.a2a.spec.FileWithBytes; |
48 | 52 | import io.a2a.spec.FileWithUri; |
| 53 | +import io.a2a.spec.GetAuthenticatedExtendedCardResponse; |
49 | 54 | import io.a2a.spec.GetTaskPushNotificationConfigParams; |
50 | 55 | import io.a2a.spec.GetTaskPushNotificationConfigResponse; |
51 | 56 | import io.a2a.spec.GetTaskResponse; |
|
65 | 70 | import io.a2a.spec.TaskQueryParams; |
66 | 71 | import io.a2a.spec.TaskState; |
67 | 72 | import io.a2a.spec.TextPart; |
| 73 | +import io.a2a.spec.TransportProtocol; |
| 74 | + |
68 | 75 | import org.junit.jupiter.api.AfterEach; |
69 | 76 | import org.junit.jupiter.api.BeforeEach; |
70 | 77 | import org.junit.jupiter.api.Test; |
@@ -382,7 +389,7 @@ public void testA2AClientGetAgentCard() throws Exception { |
382 | 389 | this.server.when( |
383 | 390 | request() |
384 | 391 | .withMethod("GET") |
385 | | - .withPath("/.well-known/agent.json") |
| 392 | + .withPath("/.well-known/agent-card.json") |
386 | 393 | ) |
387 | 394 | .respond( |
388 | 395 | response() |
@@ -443,24 +450,36 @@ public void testA2AClientGetAgentCard() throws Exception { |
443 | 450 | assertEquals(outputModes, skills.get(1).outputModes()); |
444 | 451 | assertTrue(agentCard.supportsAuthenticatedExtendedCard()); |
445 | 452 | assertEquals("https://georoute-agent.example.com/icon.png", agentCard.iconUrl()); |
446 | | - assertEquals("0.2.5", agentCard.protocolVersion()); |
| 453 | + assertEquals("0.2.9", agentCard.protocolVersion()); |
| 454 | + assertEquals("JSONRPC", agentCard.preferredTransport()); |
| 455 | + List<AgentInterface> additionalInterfaces = agentCard.additionalInterfaces(); |
| 456 | + assertEquals(3, additionalInterfaces.size()); |
| 457 | + AgentInterface jsonrpc = new AgentInterface(TransportProtocol.JSONRPC.asString(), "https://georoute-agent.example.com/a2a/v1"); |
| 458 | + AgentInterface grpc = new AgentInterface(TransportProtocol.GRPC.asString(), "https://georoute-agent.example.com/a2a/grpc"); |
| 459 | + AgentInterface httpJson = new AgentInterface(TransportProtocol.HTTP_JSON.asString(), "https://georoute-agent.example.com/a2a/json"); |
| 460 | + assertEquals(jsonrpc, additionalInterfaces.get(0)); |
| 461 | + assertEquals(grpc, additionalInterfaces.get(1)); |
| 462 | + assertEquals(httpJson, additionalInterfaces.get(2)); |
447 | 463 | } |
448 | 464 |
|
449 | 465 | @Test |
450 | 466 | public void testA2AClientGetAuthenticatedExtendedAgentCard() throws Exception { |
451 | 467 | this.server.when( |
452 | 468 | request() |
453 | | - .withMethod("GET") |
454 | | - .withPath("/agent/authenticatedExtendedCard") |
| 469 | + .withMethod("POST") |
| 470 | + .withPath("/") |
| 471 | + .withBody(JsonBody.json(GET_AUTHENTICATED_EXTENDED_AGENT_CARD_REQUEST, MatchType.STRICT)) |
| 472 | + |
455 | 473 | ) |
456 | 474 | .respond( |
457 | 475 | response() |
458 | 476 | .withStatusCode(200) |
459 | | - .withBody(AUTHENTICATION_EXTENDED_AGENT_CARD) |
| 477 | + .withBody(GET_AUTHENTICATED_EXTENDED_AGENT_CARD_RESPONSE) |
460 | 478 | ); |
461 | 479 |
|
462 | 480 | A2AClient client = new A2AClient("http://localhost:4001"); |
463 | | - AgentCard agentCard = client.getAgentCard("/agent/authenticatedExtendedCard", null); |
| 481 | + GetAuthenticatedExtendedCardResponse response = client.getAuthenticatedExtendedCard("1", null); |
| 482 | + AgentCard agentCard = response.getResult(); |
464 | 483 | assertEquals("GeoSpatial Route Planner Agent Extended", agentCard.name()); |
465 | 484 | assertEquals("Extended description", agentCard.description()); |
466 | 485 | assertEquals("https://georoute-agent.example.com/a2a/v1", agentCard.url()); |
@@ -516,7 +535,13 @@ public void testA2AClientGetAuthenticatedExtendedAgentCard() throws Exception { |
516 | 535 | assertEquals(List.of("extended"), skills.get(2).tags()); |
517 | 536 | assertTrue(agentCard.supportsAuthenticatedExtendedCard()); |
518 | 537 | assertEquals("https://georoute-agent.example.com/icon.png", agentCard.iconUrl()); |
519 | | - assertEquals("0.2.5", agentCard.protocolVersion()); |
| 538 | + assertEquals("0.2.9", agentCard.protocolVersion()); |
| 539 | + List<AgentCardSignature> signatures = agentCard.signatures(); |
| 540 | + assertEquals(1, signatures.size()); |
| 541 | + AgentCardSignature signature = new AgentCardSignature(null, |
| 542 | + "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpPU0UiLCJraWQiOiJrZXktMSIsImprdSI6Imh0dHBzOi8vZXhhbXBsZS5jb20vYWdlbnQvandrcy5qc29uIn0", |
| 543 | + "QFdkNLNszlGj3z3u0YQGt_T9LixY3qtdQpZmsTdDHDe3fXV9y9-B3m2-XgCpzuhiLt8E0tV6HXoZKHv4GtHgKQ"); |
| 544 | + assertEquals(signature, signatures.get(0)); |
520 | 545 | } |
521 | 546 |
|
522 | 547 | @Test |
|
0 commit comments