@@ -221,7 +221,7 @@ func Test_defaultClientRegistrationManager_deactivate(t *testing.T) {
221
221
ctx .invoker .EXPECT ().Register (gomock .Any (), gomock .Any (), gomock .Any ())
222
222
ctx .wallet .EXPECT ().BuildPresentation (gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any (), false ).Return (& vpAlice , nil )
223
223
ctx .subjectManager .EXPECT ().ListDIDs (gomock .Any (), aliceSubject ).Return ([]did.DID {aliceDID }, nil )
224
- require .NoError (t , ctx .store .add (testServiceID , vpAlice , 1 ))
224
+ require .NoError (t , ctx .store .add (testServiceID , vpAlice , testSeed , 1 ))
225
225
226
226
err := ctx .manager .deactivate (audit .TestContext (), testServiceID , aliceSubject )
227
227
@@ -236,7 +236,7 @@ func Test_defaultClientRegistrationManager_deactivate(t *testing.T) {
236
236
claims ["retract_jti" ] = vpAlice .ID .String ()
237
237
vp .Type = append (vp .Type , retractionPresentationType )
238
238
}, vcAlice )
239
- require .NoError (t , ctx .store .add (testServiceID , vpAliceDeactivated , 1 ))
239
+ require .NoError (t , ctx .store .add (testServiceID , vpAliceDeactivated , testSeed , 1 ))
240
240
241
241
err := ctx .manager .deactivate (audit .TestContext (), testServiceID , aliceSubject )
242
242
@@ -255,7 +255,7 @@ func Test_defaultClientRegistrationManager_deactivate(t *testing.T) {
255
255
ctx .invoker .EXPECT ().Register (gomock .Any (), gomock .Any (), gomock .Any ()).Return (errors .New ("remote error" ))
256
256
ctx .wallet .EXPECT ().BuildPresentation (gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any (), false ).Return (& vpAlice , nil )
257
257
ctx .subjectManager .EXPECT ().ListDIDs (gomock .Any (), aliceSubject ).Return ([]did.DID {aliceDID }, nil )
258
- require .NoError (t , ctx .store .add (testServiceID , vpAlice , 1 ))
258
+ require .NoError (t , ctx .store .add (testServiceID , vpAlice , testSeed , 1 ))
259
259
260
260
err := ctx .manager .deactivate (audit .TestContext (), testServiceID , aliceSubject )
261
261
@@ -266,7 +266,7 @@ func Test_defaultClientRegistrationManager_deactivate(t *testing.T) {
266
266
ctx := newTestContext (t )
267
267
ctx .wallet .EXPECT ().BuildPresentation (gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any (), false ).Return (nil , assert .AnError )
268
268
ctx .subjectManager .EXPECT ().ListDIDs (gomock .Any (), aliceSubject ).Return ([]did.DID {aliceDID }, nil )
269
- require .NoError (t , ctx .store .add (testServiceID , vpAlice , 1 ))
269
+ require .NoError (t , ctx .store .add (testServiceID , vpAlice , testSeed , 1 ))
270
270
271
271
err := ctx .manager .deactivate (audit .TestContext (), testServiceID , aliceSubject )
272
272
@@ -394,7 +394,7 @@ func Test_clientUpdater_updateService(t *testing.T) {
394
394
httpClient := client .NewMockHTTPClient (ctrl )
395
395
updater := newClientUpdater (testDefinitions (), store , alwaysOkVerifier , httpClient )
396
396
397
- httpClient .EXPECT ().Get (ctx , testDefinitions ()[testServiceID ].Endpoint , 0 ).Return (map [string ]vc.VerifiablePresentation {}, 0 , nil )
397
+ httpClient .EXPECT ().Get (ctx , testDefinitions ()[testServiceID ].Endpoint , 0 ).Return (map [string ]vc.VerifiablePresentation {}, testSeed , 0 , nil )
398
398
399
399
err := updater .updateService (ctx , testDefinitions ()[testServiceID ])
400
400
@@ -406,7 +406,7 @@ func Test_clientUpdater_updateService(t *testing.T) {
406
406
httpClient := client .NewMockHTTPClient (ctrl )
407
407
updater := newClientUpdater (testDefinitions (), store , alwaysOkVerifier , httpClient )
408
408
409
- httpClient .EXPECT ().Get (ctx , serviceDefinition .Endpoint , 0 ).Return (map [string ]vc.VerifiablePresentation {"1" : vpAlice }, 1 , nil )
409
+ httpClient .EXPECT ().Get (ctx , serviceDefinition .Endpoint , 0 ).Return (map [string ]vc.VerifiablePresentation {"1" : vpAlice }, testSeed , 1 , nil )
410
410
411
411
err := updater .updateService (ctx , testDefinitions ()[testServiceID ])
412
412
@@ -423,7 +423,7 @@ func Test_clientUpdater_updateService(t *testing.T) {
423
423
return nil
424
424
}, httpClient )
425
425
426
- httpClient .EXPECT ().Get (ctx , serviceDefinition .Endpoint , 0 ).Return (map [string ]vc.VerifiablePresentation {"1" : vpAlice , "2" : vpBob }, 2 , nil )
426
+ httpClient .EXPECT ().Get (ctx , serviceDefinition .Endpoint , 0 ).Return (map [string ]vc.VerifiablePresentation {"1" : vpAlice , "2" : vpBob }, testSeed , 2 , nil )
427
427
428
428
err := updater .updateService (ctx , testDefinitions ()[testServiceID ])
429
429
@@ -440,28 +440,49 @@ func Test_clientUpdater_updateService(t *testing.T) {
440
440
resetStore (t , storageEngine .GetSQLDatabase ())
441
441
ctrl := gomock .NewController (t )
442
442
httpClient := client .NewMockHTTPClient (ctrl )
443
- err := store .setTimestamp (store .db , testServiceID , 1 )
443
+ err := store .setTimestamp (store .db , testServiceID , testSeed , 1 )
444
444
require .NoError (t , err )
445
445
updater := newClientUpdater (testDefinitions (), store , alwaysOkVerifier , httpClient )
446
446
447
- httpClient .EXPECT ().Get (ctx , serviceDefinition .Endpoint , 1 ).Return (map [string ]vc.VerifiablePresentation {"1" : vpAlice }, 1 , nil )
447
+ httpClient .EXPECT ().Get (ctx , serviceDefinition .Endpoint , 1 ).Return (map [string ]vc.VerifiablePresentation {"1" : vpAlice }, testSeed , 1 , nil )
448
448
449
449
err = updater .updateService (ctx , testDefinitions ()[testServiceID ])
450
450
451
451
require .NoError (t , err )
452
452
})
453
+ t .Run ("seed change wipes entries" , func (t * testing.T ) {
454
+ resetStore (t , storageEngine .GetSQLDatabase ())
455
+ ctrl := gomock .NewController (t )
456
+ httpClient := client .NewMockHTTPClient (ctrl )
457
+ updater := newClientUpdater (testDefinitions (), store , alwaysOkVerifier , httpClient )
458
+ store .add (testServiceID , vpAlice , testSeed , 0 )
459
+
460
+ exists , err := store .exists (testServiceID , aliceDID .String (), vpAlice .ID .String ())
461
+ require .NoError (t , err )
462
+ require .True (t , exists )
463
+
464
+ httpClient .EXPECT ().Get (ctx , testDefinitions ()[testServiceID ].Endpoint , 1 ).Return (map [string ]vc.VerifiablePresentation {}, "other" , 0 , nil )
465
+
466
+ err = updater .updateService (ctx , testDefinitions ()[testServiceID ])
467
+
468
+ require .NoError (t , err )
469
+ exists , err = store .exists (testServiceID , aliceDID .String (), vpAlice .ID .String ())
470
+ require .NoError (t , err )
471
+ require .False (t , exists )
472
+ })
453
473
}
454
474
455
475
func Test_clientUpdater_update (t * testing.T ) {
476
+ seed := "seed"
456
477
t .Run ("proceeds when service update fails" , func (t * testing.T ) {
457
478
storageEngine := storage .NewTestStorageEngine (t )
458
479
require .NoError (t , storageEngine .Start ())
459
480
store := setupStore (t , storageEngine .GetSQLDatabase ())
460
481
ctrl := gomock .NewController (t )
461
482
httpClient := client .NewMockHTTPClient (ctrl )
462
- httpClient .EXPECT ().Get (gomock .Any (), "http://example.com/usecase" , gomock .Any ()).Return (map [string ]vc.VerifiablePresentation {}, 0 , nil )
463
- httpClient .EXPECT ().Get (gomock .Any (), "http://example.com/other" , gomock .Any ()).Return (nil , 0 , errors .New ("test" ))
464
- httpClient .EXPECT ().Get (gomock .Any (), "http://example.com/unsupported" , gomock .Any ()).Return (map [string ]vc.VerifiablePresentation {}, 0 , nil )
483
+ httpClient .EXPECT ().Get (gomock .Any (), "http://example.com/usecase" , gomock .Any ()).Return (map [string ]vc.VerifiablePresentation {}, seed , 0 , nil )
484
+ httpClient .EXPECT ().Get (gomock .Any (), "http://example.com/other" , gomock .Any ()).Return (nil , "" , 0 , errors .New ("test" ))
485
+ httpClient .EXPECT ().Get (gomock .Any (), "http://example.com/unsupported" , gomock .Any ()).Return (map [string ]vc.VerifiablePresentation {}, seed , 0 , nil )
465
486
updater := newClientUpdater (testDefinitions (), store , alwaysOkVerifier , httpClient )
466
487
467
488
err := updater .update (context .Background ())
@@ -474,7 +495,7 @@ func Test_clientUpdater_update(t *testing.T) {
474
495
store := setupStore (t , storageEngine .GetSQLDatabase ())
475
496
ctrl := gomock .NewController (t )
476
497
httpClient := client .NewMockHTTPClient (ctrl )
477
- httpClient .EXPECT ().Get (gomock .Any (), gomock .Any (), gomock .Any ()).Return (map [string ]vc.VerifiablePresentation {}, 0 , nil ).MinTimes (2 )
498
+ httpClient .EXPECT ().Get (gomock .Any (), gomock .Any (), gomock .Any ()).Return (map [string ]vc.VerifiablePresentation {}, seed , 0 , nil ).MinTimes (2 )
478
499
updater := newClientUpdater (testDefinitions (), store , alwaysOkVerifier , httpClient )
479
500
480
501
err := updater .update (context .Background ())
0 commit comments