towerops/test/towerops_web/controllers/well_known_controller_test.exs
Graham McIntire 0bb76dbe68 feat: add /.well-known discovery endpoints for agent readiness
Adds WellKnownController with 6 public, no-auth endpoints:
api-catalog, openid-configuration, oauth-authorization-server,
oauth-protected-resource, mcp/server-card.json, and agent-skills/index.json.
2026-04-17 14:06:51 -05:00

70 lines
2.6 KiB
Elixir

defmodule ToweropsWeb.WellKnownControllerTest do
use ToweropsWeb.ConnCase, async: true
describe "GET /.well-known/api-catalog" do
test "returns linkset+json with API entries", %{conn: conn} do
conn = get(conn, "/.well-known/api-catalog")
assert get_resp_header(conn, "content-type") == ["application/linkset+json; charset=utf-8"]
body = json_response(conn, 200)
assert is_list(body["linkset"])
[entry] = body["linkset"]
assert is_binary(entry["anchor"])
assert is_list(entry["service-doc"])
assert is_list(entry["service-desc"])
assert is_list(entry["status"])
end
end
describe "GET /.well-known/openid-configuration" do
test "returns OIDC discovery metadata", %{conn: conn} do
conn = get(conn, "/.well-known/openid-configuration")
body = json_response(conn, 200)
assert is_binary(body["issuer"])
assert is_binary(body["authorization_endpoint"])
assert is_binary(body["token_endpoint"])
assert is_binary(body["jwks_uri"])
assert is_list(body["grant_types_supported"])
assert is_list(body["response_types_supported"])
end
end
describe "GET /.well-known/oauth-authorization-server" do
test "returns OAuth 2.0 server metadata", %{conn: conn} do
conn = get(conn, "/.well-known/oauth-authorization-server")
body = json_response(conn, 200)
assert is_binary(body["issuer"])
assert is_binary(body["authorization_endpoint"])
assert is_binary(body["token_endpoint"])
end
end
describe "GET /.well-known/oauth-protected-resource" do
test "returns protected resource metadata", %{conn: conn} do
conn = get(conn, "/.well-known/oauth-protected-resource")
body = json_response(conn, 200)
assert is_binary(body["resource"])
assert is_list(body["authorization_servers"])
assert is_list(body["scopes_supported"])
end
end
describe "GET /.well-known/mcp/server-card.json" do
test "returns MCP server card", %{conn: conn} do
conn = get(conn, "/.well-known/mcp/server-card.json")
body = json_response(conn, 200)
assert get_in(body, ["serverInfo", "name"]) == "TowerOps"
assert is_binary(get_in(body, ["serverInfo", "version"]))
assert is_binary(get_in(body, ["transport", "endpoint"]))
assert is_map(body["capabilities"])
end
end
describe "GET /.well-known/agent-skills/index.json" do
test "returns agent skills discovery index", %{conn: conn} do
conn = get(conn, "/.well-known/agent-skills/index.json")
body = json_response(conn, 200)
assert body["$schema"] =~ "agentskills.io"
assert is_list(body["skills"])
end
end
end