@@ -206,6 +206,10 @@ describe('[APTX] appTemplates', function () {
206206 const collectorClients = await myAppClient . getCollectorClients ( true ) ;
207207 assert . equal ( collectorClients . length , 1 ) ;
208208
209+ // collectorClients can be retrieved by key
210+ const found = await myAppClient . getCollectorClientByKey ( collectorClient . key ) ;
211+ assert . equal ( found , collectorClients [ 0 ] ) ;
212+
209213 // check requestData
210214 assert . deepEqual ( collectorClient . requestData , requestContent ) ;
211215
@@ -294,9 +298,19 @@ describe('[APTX] appTemplates', function () {
294298 // revoke appManaging
295299 await new0 . appManaging . connection . revoke ( ) ;
296300 // create a new appManaging with the same name for the same user
297- // const new1 = await helperNewAppManaging('dummy', 'dummyApp', new0.managingUser);
298- // create a new invite for existing client
299- // TODO
301+ const manager1 = await helperNewAppManaging ( 'dummy' , 'dummyApp' , new0 . managingUser ) ;
302+ // get invites from precedent collector
303+ const collector1 = ( await manager1 . appManaging . getCollectors ( ) ) [ 0 ] ;
304+ await collector1 . init ( ) ;
305+ const inv1 = ( await collector1 . getInvites ( ) ) [ 0 ] ;
306+ const inviteSharingData1 = await inv1 . getSharingData ( ) ;
307+ // Already known but different incomingEnventId
308+ try {
309+ await new0 . appClient . handleIncomingRequest ( inviteSharingData1 . apiEndpoint , inviteSharingData1 . eventId ) ;
310+ throw new Error ( 'should throw Error' ) ;
311+ } catch ( e ) {
312+ assert . equal ( e . message , 'Found existing collectorClient with a different apiEndpoint' ) ;
313+ }
300314 } ) ;
301315 } ) ;
302316
@@ -329,7 +343,8 @@ async function helperNewAppManaging (baseStreamIdManager, appName, managingUser
329343 if ( ! managingUser ) {
330344 managingUser = await createUserAndPermissions ( null , permissionsManager , initialStreams , appName ) ;
331345 } else {
332- await createUserPermissions ( managingUser , permissionsManager , initialStreams , appName ) ;
346+ // replace managing user with new permissions set
347+ managingUser = await createUserPermissions ( managingUser , permissionsManager , initialStreams , appName ) ;
333348 }
334349 const connection = new pryv . Connection ( managingUser . appApiEndpoint ) ;
335350 const appManaging = await AppManagingAccount . newFromConnection ( baseStreamIdManager , connection ) ;
0 commit comments