@@ -2131,4 +2131,73 @@ describe("Tier 1 - Feature Coverage", () => {
21312131 ) ;
21322132 } ) ;
21332133 } ) ;
2134+
2135+ // ── 15. Personal Agent Protocol (Poppy) Discovery & Issuer Binding ────
2136+ describe ( "Personal Agent Protocol (Poppy) Discovery & OAuth Issuer Binding" , ( ) => {
2137+ it ( "15.1 /.well-known/poppy.json returns protocol_version 0.1, matching organization.domain, and RFC 8414 issuer binding" , async ( ) => {
2138+ const poppyModule = loadModule ( "src/pages/.well-known/poppy.json.ts" ) ;
2139+ const oauthServerModule = loadModule (
2140+ "src/pages/.well-known/oauth-authorization-server.ts" ,
2141+ ) ;
2142+ const locals = {
2143+ siteUrl : new URL ( "https://codingcat.dev" ) ,
2144+ } ;
2145+
2146+ const poppyRes = await poppyModule . GET ( {
2147+ request : new Request (
2148+ "https://www.codingcat.dev/.well-known/poppy.json" ,
2149+ ) ,
2150+ locals,
2151+ } ) ;
2152+ assert . equal ( poppyRes . status , 200 ) ;
2153+ assert . ok (
2154+ poppyRes . headers . get ( "content-type" ) ?. includes ( "application/json" ) ,
2155+ ) ;
2156+ const poppy = await poppyRes . json ( ) ;
2157+
2158+ assert . equal ( poppy . protocol_version , "0.1" ) ;
2159+ assert . equal ( poppy . organization ?. name , "CodingCat.dev" ) ;
2160+ assert . equal (
2161+ poppy . organization ?. domain ,
2162+ "codingcat.dev" ,
2163+ "organization.domain must match requested hostname ignoring leading www." ,
2164+ ) ;
2165+ assert . equal ( poppy . auth ?. issuer , "https://codingcat.dev" ) ;
2166+ assert . ok ( Array . isArray ( poppy . auth ?. direct ?. scopes ) ) ;
2167+ assert . ok ( Array . isArray ( poppy . apis ) && poppy . apis . length >= 2 ) ;
2168+ assert . equal ( typeof poppy . web , "object" ) ;
2169+
2170+ const oauthRes = await oauthServerModule . GET ( {
2171+ request : new Request (
2172+ "https://codingcat.dev/.well-known/oauth-authorization-server" ,
2173+ ) ,
2174+ locals,
2175+ } ) ;
2176+ assert . equal ( oauthRes . status , 200 ) ;
2177+ const oauthMeta = await oauthRes . json ( ) ;
2178+
2179+ assert . equal (
2180+ oauthMeta . issuer ,
2181+ poppy . auth . issuer ,
2182+ "RFC 8414 issuer must exactly match poppy.json auth.issuer" ,
2183+ ) ;
2184+ assert . ok (
2185+ Array . isArray ( oauthMeta . poppy_domains ) &&
2186+ oauthMeta . poppy_domains . includes ( poppy . organization . domain ) ,
2187+ "RFC 8414 poppy_domains must include organization.domain" ,
2188+ ) ;
2189+ assert . equal (
2190+ oauthMeta . token_endpoint ,
2191+ "https://codingcat.dev/oauth2/token" ,
2192+ ) ;
2193+ assert . equal (
2194+ oauthMeta . revocation_endpoint ,
2195+ "https://codingcat.dev/oauth2/revoke" ,
2196+ ) ;
2197+ assert . equal (
2198+ oauthMeta . authorization_endpoint ,
2199+ "https://codingcat.dev/oauth2/authorize" ,
2200+ ) ;
2201+ } ) ;
2202+ } ) ;
21342203} ) ;
0 commit comments