@@ -1192,14 +1192,10 @@ describe('authorized live retrieval', () => {
11921192 describe ( 'live document IDs' , ( ) => {
11931193 const workspaceScope = resourceScopeKey ( resourceScopeFromOwner ( { workspaceId : 'workspace' } ) )
11941194 /** The earlier wire form, spelled out so these tests pin what older conversations hold. */
1195- const legacyId = ( { owner : _owner , ... fields } : Record < string , string > ) =>
1195+ const legacyId = ( fields : Record < string , string > ) =>
11961196 `live:${ Buffer . from ( JSON . stringify ( { v : 1 , ...fields } ) ) . toString ( 'base64url' ) } `
1197- const fields = {
1198- owner : liveReferenceOwner ( 'reader' , workspaceScope ) ,
1199- account : 'account' ,
1200- provider : 'google_drive' as const ,
1201- id : 'doc' ,
1202- }
1197+ const readerOwner = liveReferenceOwner ( 'reader' , workspaceScope )
1198+ const fields = { account : 'account' , provider : 'google_drive' as const , id : 'doc' }
12031199 const read = ( documentId : string , extra : Record < string , unknown > = { } , as = principal ) =>
12041200 readLiveDocument . execute ( {
12051201 principal : as ,
@@ -1217,8 +1213,8 @@ describe('authorized live retrieval', () => {
12171213 const [ first ] = search . results
12181214 if ( ! first ) throw new Error ( 'Expected a search result' )
12191215 const { documentId } = first
1220- expect ( documentId ) . toBe ( encodeLiveReference ( fields ) )
1221- expect ( documentId ) . toMatch ( / ^ l i v e 2 : g o o g l e _ d r i v e ~ [ 0 - 9 a - f ] { 8 } ~ a c c o u n t ~ d o c ~ [ 0 - 9 a - f ] { 6 } $ / )
1216+ expect ( documentId ) . toBe ( encodeLiveReference ( fields , readerOwner ) )
1217+ expect ( documentId ) . toMatch ( / ^ l i v e 2 : g o o g l e _ d r i v e ~ a c c o u n t ~ d o c ~ [ 0 - 9 a - f ] { 6 } $ / )
12221218 const result = await read ( documentId )
12231219 expect ( result . documentId ) . toBe ( documentId )
12241220 expect ( result . chunks [ 0 ] ?. content ) . toBe ( 'Evidence' )
@@ -1235,7 +1231,7 @@ describe('authorized live retrieval', () => {
12351231 throw new NativeSearchError ( 'reconnect' , 'This search connection is no longer available.' )
12361232 return { account, accessToken : 'secret' }
12371233 } )
1238- const theirs = encodeLiveReference ( { ...fields , account : 'their-account' } )
1234+ const theirs = encodeLiveReference ( { ...fields , account : 'their-account' } , readerOwner )
12391235 await expect ( read ( theirs ) ) . rejects . toMatchObject ( { code : 'unauthorized' } )
12401236 expect ( mocks . resolveAccount ) . toHaveBeenCalledWith (
12411237 expect . anything ( ) ,
@@ -1255,7 +1251,7 @@ describe('authorized live retrieval', () => {
12551251 ] ) (
12561252 'refuses an ID minted for %s as not found before resolving any account' ,
12571253 async ( _case , user , scope ) => {
1258- const theirs = encodeLiveReference ( { ... fields , owner : liveReferenceOwner ( user , scope ) } )
1254+ const theirs = encodeLiveReference ( fields , liveReferenceOwner ( user , scope ) )
12591255 await expect ( read ( theirs ) ) . rejects . toThrow ( 'Document not found in this search scope' )
12601256 expect ( mocks . resolveAccount ) . not . toHaveBeenCalled ( )
12611257 expect ( mocks . read ) . not . toHaveBeenCalled ( )
@@ -1289,7 +1285,7 @@ describe('authorized live retrieval', () => {
12891285 }
12901286 )
12911287 it ( 'matches a selected document across the earlier and current forms' , async ( ) => {
1292- const current = encodeLiveReference ( fields )
1288+ const current = encodeLiveReference ( fields , readerOwner )
12931289 const earlier = legacyId ( { user : 'reader' , scope : workspaceScope , ...fields } )
12941290 await expect ( read ( current , { filters : { documentIds : [ earlier ] } } ) ) . resolves . toMatchObject ( {
12951291 documentId : current ,
@@ -1300,7 +1296,7 @@ describe('authorized live retrieval', () => {
13001296 ) . toBe ( true )
13011297 await expect (
13021298 read ( current , {
1303- filters : { documentIds : [ encodeLiveReference ( { ...fields , id : 'other' } ) ] } ,
1299+ filters : { documentIds : [ encodeLiveReference ( { ...fields , id : 'other' } , readerOwner ) ] } ,
13041300 } )
13051301 ) . rejects . toThrow ( 'outside the selected search filters' )
13061302 } )
0 commit comments