|
| 1 | +package org.a2aproject.sdk.tests.multitenancy.jsonrpc; |
| 2 | + |
| 3 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 4 | + |
| 5 | +import io.quarkus.test.junit.QuarkusTest; |
| 6 | +import io.restassured.RestAssured; |
| 7 | +import io.restassured.path.json.JsonPath; |
| 8 | +import org.junit.jupiter.api.Test; |
| 9 | + |
| 10 | +/** |
| 11 | + * Verifies that the JSON-RPC transport serves the public agent card endpoints |
| 12 | + * (/.well-known/agent-card.json and /.well-known/{tenant}/agent-card.json) |
| 13 | + * when the REST transport is NOT on the classpath. |
| 14 | + */ |
| 15 | +@QuarkusTest |
| 16 | +public class MultiTenantJSONRPCPublicCardTest { |
| 17 | + |
| 18 | + @Test |
| 19 | + public void defaultPublicCardIsServed() { |
| 20 | + String response = RestAssured.given() |
| 21 | + .when().get("/.well-known/agent-card.json") |
| 22 | + .then().statusCode(200) |
| 23 | + .extract().asString(); |
| 24 | + assertEquals("Default Agent", JsonPath.from(response).getString("name")); |
| 25 | + } |
| 26 | + |
| 27 | + @Test |
| 28 | + public void acmeTenantPublicCardIsServed() { |
| 29 | + String response = RestAssured.given() |
| 30 | + .when().get("/.well-known/acme/agent-card.json") |
| 31 | + .then().statusCode(200) |
| 32 | + .extract().asString(); |
| 33 | + assertEquals("Acme Agent", JsonPath.from(response).getString("name")); |
| 34 | + } |
| 35 | + |
| 36 | + @Test |
| 37 | + public void betaTenantPublicCardIsServed() { |
| 38 | + String response = RestAssured.given() |
| 39 | + .when().get("/.well-known/beta/agent-card.json") |
| 40 | + .then().statusCode(200) |
| 41 | + .extract().asString(); |
| 42 | + assertEquals("Beta Agent", JsonPath.from(response).getString("name")); |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + public void unknownTenantPublicCardFallsBackToDefault() { |
| 47 | + String response = RestAssured.given() |
| 48 | + .when().get("/.well-known/unknown-corp/agent-card.json") |
| 49 | + .then().statusCode(200) |
| 50 | + .extract().asString(); |
| 51 | + assertEquals("Default Agent", JsonPath.from(response).getString("name")); |
| 52 | + } |
| 53 | +} |
0 commit comments