11import { test , expect , type Page } from '@playwright/test' ;
22
33// ---------------------------------------------------------------------------
4- // Mock data — matches the structure the GitHub adapter expects
4+ // Mock data — matches the registry format (refs/auths/registry)
55// ---------------------------------------------------------------------------
66
7- const TEST_DID = 'did:key:z6MkiTBz1ymuepAQ4HEHYSF1H8quG5GLVVQR3djdX3mDooWp' ;
7+ const TEST_KERI_PREFIX = 'EXrBYxo2ovC9iZIKgXZhbiDvD21eAVwoLnlziitHeTiM' ;
8+ const TEST_CESR_KEY = 'DQIS37c2Ar3CzozrmU9KpbUWBYWMJhBWPV-wN50i-RGI' ;
9+
10+ const STATE_JSON = JSON . stringify ( {
11+ version : 1 ,
12+ state : {
13+ prefix : TEST_KERI_PREFIX ,
14+ current_keys : [ TEST_CESR_KEY ] ,
15+ sequence : 0 ,
16+ } ,
17+ } ) ;
818
9- const IDENTITY_JSON = JSON . stringify ( { controller_did : TEST_DID } ) ;
1019const ATTESTATION_JSON = JSON . stringify ( {
1120 version : 1 ,
12- rid : 'test-rid ' ,
13- issuer : TEST_DID ,
21+ rid : '.auths ' ,
22+ issuer : `did:keri: ${ TEST_KERI_PREFIX } ` ,
1423 subject : 'did:key:z6MkDev1Device' ,
15- iat : '2025-01-01T00:00:00Z' ,
16- signature : 'deadbeef' ,
24+ device_public_key : 'abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234' ,
25+ identity_signature : 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef' ,
26+ device_signature : 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef' ,
27+ timestamp : '2025-01-01T00:00:00Z' ,
1728} ) ;
1829
19- const IDENTITY_B64 = btoa ( IDENTITY_JSON ) ;
30+ const STATE_B64 = btoa ( STATE_JSON ) ;
2031const ATTESTATION_B64 = btoa ( ATTESTATION_JSON ) ;
2132
2233// ---------------------------------------------------------------------------
23- // Route handler: mocks the GitHub REST API for forge adapter
34+ // Route handler: mocks the GitHub REST API for forge adapter (registry format)
2435// ---------------------------------------------------------------------------
2536
2637async function mockGitHubAPI ( page : Page ) {
27- // Intercept all requests to api.github.com
2838 await page . route ( 'https://api.github.com/**' , async ( route ) => {
2939 const url = route . request ( ) . url ( ) ;
3040
@@ -34,8 +44,7 @@ async function mockGitHubAPI(page: Page) {
3444 status : 200 ,
3545 contentType : 'application/json' ,
3646 body : JSON . stringify ( [
37- { ref : 'refs/auths/identity' , object : { sha : 'commit-id-1' } } ,
38- { ref : 'refs/auths/keys/dev1/signatures' , object : { sha : 'commit-att-1' } } ,
47+ { ref : 'refs/auths/registry' , object : { sha : 'commit-registry' } } ,
3948 ] ) ,
4049 } ) ;
4150 }
@@ -50,49 +59,35 @@ async function mockGitHubAPI(page: Page) {
5059 }
5160
5261 // 2. Get commit → tree SHA
53- if ( url . includes ( 'git/commits/commit-id-1' ) ) {
54- return route . fulfill ( {
55- status : 200 ,
56- contentType : 'application/json' ,
57- body : JSON . stringify ( { tree : { sha : 'tree-identity' } } ) ,
58- } ) ;
59- }
60-
61- if ( url . includes ( 'git/commits/commit-att-1' ) ) {
62+ if ( url . includes ( 'git/commits/commit-registry' ) ) {
6263 return route . fulfill ( {
6364 status : 200 ,
6465 contentType : 'application/json' ,
65- body : JSON . stringify ( { tree : { sha : 'tree-attestation ' } } ) ,
66+ body : JSON . stringify ( { tree : { sha : 'tree-registry ' } } ) ,
6667 } ) ;
6768 }
6869
69- // 3. Get tree → blob entries
70- if ( url . includes ( 'git/trees/tree-identity ' ) ) {
70+ // 3. Get recursive tree → all blobs in registry
71+ if ( url . includes ( 'git/trees/tree-registry ' ) ) {
7172 return route . fulfill ( {
7273 status : 200 ,
7374 contentType : 'application/json' ,
7475 body : JSON . stringify ( {
75- tree : [ { path : 'identity.json' , sha : 'blob-identity' } ] ,
76- } ) ,
77- } ) ;
78- }
79-
80- if ( url . includes ( 'git/trees/tree-attestation' ) ) {
81- return route . fulfill ( {
82- status : 200 ,
83- contentType : 'application/json' ,
84- body : JSON . stringify ( {
85- tree : [ { path : 'attestation.json' , sha : 'blob-attestation' } ] ,
76+ tree : [
77+ { path : `v1/identities/EX/rB/${ TEST_KERI_PREFIX } /state.json` , sha : 'blob-state' , type : 'blob' } ,
78+ { path : `v1/devices/z6/Mk/did_key_z6MkDev1Device/attestation.json` , sha : 'blob-attestation' , type : 'blob' } ,
79+ { path : 'v1/metadata.json' , sha : 'blob-meta' , type : 'blob' } ,
80+ ] ,
8681 } ) ,
8782 } ) ;
8883 }
8984
9085 // 4. Read blobs
91- if ( url . includes ( 'git/blobs/blob-identity ' ) ) {
86+ if ( url . includes ( 'git/blobs/blob-state ' ) ) {
9287 return route . fulfill ( {
9388 status : 200 ,
9489 contentType : 'application/json' ,
95- body : JSON . stringify ( { content : IDENTITY_B64 , encoding : 'base64' } ) ,
90+ body : JSON . stringify ( { content : STATE_B64 , encoding : 'base64' } ) ,
9691 } ) ;
9792 }
9893
@@ -136,11 +131,11 @@ test.describe('auths-verify widget E2E', () => {
136131 await page . goto ( '/e2e/fixture.html' ) ;
137132 } ) ;
138133
139- test ( 'badge mode: resolves identity from mocked GitHub API and reaches terminal state' , async ( { page } ) => {
134+ test ( 'badge mode: resolves identity from mocked registry and reaches terminal state' , async ( { page } ) => {
140135 await waitForState ( page , '#badge-repo' ) ;
141136
142137 const state = await page . getAttribute ( '#badge-repo' , 'data-state' ) ;
143- // The widget fetched refs , read identity .json, attempted WASM verification.
138+ // The widget fetched registry , read state .json, attempted WASM verification.
144139 // With fake crypto data the result is either 'verified', 'invalid', or 'error'
145140 // — any of these proves the pipeline ran end-to-end.
146141 expect ( [ 'verified' , 'invalid' , 'error' ] ) . toContain ( state ) ;
@@ -197,7 +192,6 @@ test.describe('auths-verify widget E2E', () => {
197192 } ) ;
198193
199194 test ( 'events: widget emits auths-verified or auths-error' , async ( { page } ) => {
200- // Collect events from the badge-repo widget
201195 const events = await page . evaluate ( ( ) => {
202196 return new Promise < { type : string ; detail : unknown } [ ] > ( ( resolve ) => {
203197 const collected : { type : string ; detail : unknown } [ ] = [ ] ;
@@ -211,7 +205,6 @@ test.describe('auths-verify widget E2E', () => {
211205 collected . push ( { type : 'auths-error' , detail : ( e as CustomEvent ) . detail } ) ;
212206 } ) ;
213207
214- // Wait for event (widget auto-verifies on connect)
215208 setTimeout ( ( ) => resolve ( collected ) , 10_000 ) ;
216209 } ) ;
217210 } ) ;
@@ -245,5 +238,4 @@ test.describe('auths-verify widget E2E', () => {
245238 } ) ;
246239 expect ( expanded ) . toBe ( 'false' ) ;
247240 } ) ;
248-
249241} ) ;
0 commit comments