70 lines
3.4 KiB
Elixir
70 lines
3.4 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"]) and body["linkset"] != []
|
|
[entry] = body["linkset"]
|
|
assert is_binary(entry["anchor"]) and byte_size(entry["anchor"]) > 0
|
|
assert is_list(entry["service-doc"]) and entry["service-doc"] != []
|
|
assert is_list(entry["service-desc"]) and entry["service-desc"] != []
|
|
assert is_list(entry["status"]) and 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"]) and byte_size(body["issuer"]) > 0
|
|
assert is_binary(body["authorization_endpoint"]) and byte_size(body["authorization_endpoint"]) > 0
|
|
assert is_binary(body["token_endpoint"]) and byte_size(body["token_endpoint"]) > 0
|
|
assert is_binary(body["jwks_uri"]) and byte_size(body["jwks_uri"]) > 0
|
|
assert is_list(body["grant_types_supported"]) and body["grant_types_supported"] != []
|
|
assert is_list(body["response_types_supported"]) and 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"]) and byte_size(body["issuer"]) > 0
|
|
assert is_binary(body["authorization_endpoint"]) and byte_size(body["authorization_endpoint"]) > 0
|
|
assert is_binary(body["token_endpoint"]) and byte_size(body["token_endpoint"]) > 0
|
|
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"]) and byte_size(body["resource"]) > 0
|
|
assert is_list(body["authorization_servers"]) and body["authorization_servers"] != []
|
|
assert is_list(body["scopes_supported"]) and 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"])) and byte_size(get_in(body, ["serverInfo", "version"])) > 0
|
|
assert is_binary(get_in(body, ["transport", "endpoint"])) and byte_size(get_in(body, ["transport", "endpoint"])) > 0
|
|
assert is_map(body["capabilities"]) and map_size(body["capabilities"]) > 0
|
|
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"]) and body["skills"] != []
|
|
end
|
|
end
|
|
end
|