@@ -102,7 +102,8 @@ public IssuerComponentBusinessLogicTests()
102102 public async Task CreateBpnlCredential_WithValid_CallsExpected ( )
103103 {
104104 // Arrange
105- CreateContextForCredential ( out var entry , out var context ) ;
105+ CreateContextForCredential ( out var entry , out var checklist ) ;
106+ var context = new IApplicationChecklistService . WorkerChecklistProcessStepData ( IdWithBpn , ProcessStepTypeId . REQUEST_BPN_CREDENTIAL , checklist . ToImmutableDictionary ( ) , Enumerable . Empty < ProcessStepTypeId > ( ) ) ;
106107
107108 // Act
108109 var result = await _sut . CreateBpnlCredential ( context , CancellationToken . None ) ;
@@ -135,7 +136,8 @@ public async Task CreateBpnlCredential_WithValid_CallsExpected()
135136 public async Task CreateBpnlCredential_WithValid_BringYourOwnWallet_true_CallsExpected ( )
136137 {
137138 // Arrange
138- CreateContextForCredential ( out var entry , out var context ) ;
139+ CreateContextForCredential ( out var entry , out var checklist ) ;
140+ var context = new IApplicationChecklistService . WorkerChecklistProcessStepData ( IdWithBpn , ProcessStepTypeId . REQUEST_BPN_CREDENTIAL , checklist . ToImmutableDictionary ( ) , Enumerable . Empty < ProcessStepTypeId > ( ) ) ;
139141
140142 //bring your own wallet true
141143 A . CallTo ( ( ) => _companyRepository . IsBringYourOwnWallet ( A < Guid > . _ ) ) . Returns ( true ) ;
@@ -165,7 +167,8 @@ public async Task CreateBpnlCredential_WithValid_BringYourOwnWallet_true_CallsEx
165167 public async Task CreateBpnlCredential_WithValid_BringYourOwnWallet_false_CallsExpected ( )
166168 {
167169 // Arrange
168- CreateContextForCredential ( out var entry , out var context ) ;
170+ CreateContextForCredential ( out var entry , out var checklist ) ;
171+ var context = new IApplicationChecklistService . WorkerChecklistProcessStepData ( IdWithBpn , ProcessStepTypeId . REQUEST_BPN_CREDENTIAL , checklist . ToImmutableDictionary ( ) , Enumerable . Empty < ProcessStepTypeId > ( ) ) ;
169172
170173 //bring your own wallet false
171174 A . CallTo ( ( ) => _companyRepository . IsBringYourOwnWallet ( A < Guid > . _ ) ) . Returns ( false ) ;
@@ -373,23 +376,8 @@ public async Task StoreBpnlCredential_WithUnsuccessful_UpdatesEntry()
373376 public async Task CreateMembershipCredential_WithValid_CallsExpected ( )
374377 {
375378 // Arrange
376- var cryptoConfig = _options . Value . EncryptionConfigs . First ( ) ;
377- var ( secret , vector ) = CryptoHelper . Encrypt ( "test123" , Convert . FromHexString ( cryptoConfig . EncryptionKey ) , cryptoConfig . CipherMode , cryptoConfig . PaddingMode ) ;
378- var checklist = new Dictionary < ApplicationChecklistEntryTypeId , ApplicationChecklistEntryStatusId >
379- {
380- { ApplicationChecklistEntryTypeId . REGISTRATION_VERIFICATION , ApplicationChecklistEntryStatusId . DONE } ,
381- { ApplicationChecklistEntryTypeId . BUSINESS_PARTNER_NUMBER , ApplicationChecklistEntryStatusId . DONE } ,
382- { ApplicationChecklistEntryTypeId . IDENTITY_WALLET , ApplicationChecklistEntryStatusId . DONE } ,
383- { ApplicationChecklistEntryTypeId . BPNL_CREDENTIAL , ApplicationChecklistEntryStatusId . TO_DO }
384- }
385- . ToImmutableDictionary ( ) ;
386- var entry = new ApplicationChecklistEntry ( IdWithBpn , ApplicationChecklistEntryTypeId . BPNL_CREDENTIAL , ApplicationChecklistEntryStatusId . TO_DO , DateTimeOffset . UtcNow ) ;
387- var context = new IApplicationChecklistService . WorkerChecklistProcessStepData ( IdWithBpn , ProcessStepTypeId . REQUEST_BPN_CREDENTIAL , checklist , Enumerable . Empty < ProcessStepTypeId > ( ) ) ;
388- A . CallTo ( ( ) => _applicationRepository . GetBpnlCredentialIformationByApplicationId ( A < Guid > . _ ) )
389- . Returns ( ( true , "did:123:testabc" , ValidBpn , new WalletInformation ( "cl1" , secret , vector , 0 , "https://example.com/wallet" ) ) ) ;
390-
391- //bring your own wallet false
392- A . CallTo ( ( ) => _companyRepository . IsBringYourOwnWallet ( A < Guid > . _ ) ) . Returns ( false ) ;
379+ CreateContextForCredential ( out var entry , out var checklist ) ;
380+ var context = new IApplicationChecklistService . WorkerChecklistProcessStepData ( IdWithBpn , ProcessStepTypeId . REQUEST_BPN_CREDENTIAL , checklist . ToImmutableDictionary ( ) , Enumerable . Empty < ProcessStepTypeId > ( ) ) ;
393381
394382 // Act
395383 var result = await _sut . CreateMembershipCredential ( context , CancellationToken . None ) ;
@@ -409,11 +397,30 @@ public async Task CreateMembershipCredential_WithValid_CallsExpected()
409397 A < CancellationToken > . _ ) )
410398 . MustHaveHappenedOnceExactly ( ) ;
411399
412- //bring your own wallet false
400+ A . CallTo ( ( ) => _applicationRepository . GetBpnlCredentialIformationByApplicationId ( IdWithBpn ) )
401+ . MustHaveHappenedOnceExactly ( ) ;
402+ result . StepStatusId . Should ( ) . Be ( ProcessStepStatusId . DONE ) ;
403+ result . ScheduleStepTypeIds . Should ( ) . ContainSingle ( ) . Which . Should ( ) . Be ( ProcessStepTypeId . AWAIT_MEMBERSHIP_CREDENTIAL_RESPONSE ) ;
404+ result . Modified . Should ( ) . BeTrue ( ) ;
405+ result . SkipStepTypeIds . Should ( ) . BeNull ( ) ;
406+ result . ModifyChecklistEntry . Should ( ) . NotBeNull ( ) ;
407+ result . ModifyChecklistEntry ! ( entry ) ;
408+ entry . ApplicationChecklistEntryStatusId . Should ( ) . Be ( ApplicationChecklistEntryStatusId . IN_PROGRESS ) ;
409+ }
410+
411+ [ Fact ]
412+ public async Task CreateMembershipCredential_WithValid_BringYourOwnWallet_True_CallsExpected ( )
413+ {
414+ // Arrange
415+ CreateContextForCredential ( out var entry , out var checklist ) ;
416+ var context = new IApplicationChecklistService . WorkerChecklistProcessStepData ( IdWithBpn , ProcessStepTypeId . REQUEST_BPN_CREDENTIAL , checklist . ToImmutableDictionary ( ) , Enumerable . Empty < ProcessStepTypeId > ( ) ) ;
417+
418+ //bring your own wallet true
413419 A . CallTo ( ( ) => _companyRepository . IsBringYourOwnWallet ( A < Guid > . _ ) ) . Returns ( true ) ;
414420
415421 // Act
416- result = await _sut . CreateMembershipCredential ( context , CancellationToken . None ) ;
422+ var result = await _sut . CreateMembershipCredential ( context , CancellationToken . None ) ;
423+
417424 A . CallTo ( ( ) => _issuerComponentService
418425 . CreateMembershipCredential (
419426 A < CreateMembershipCredentialRequest > . That . Matches ( x =>
@@ -423,9 +430,48 @@ public async Task CreateMembershipCredential_WithValid_CallsExpected()
423430 ) ,
424431 A < CancellationToken > . _ ) )
425432 . MustHaveHappenedOnceExactly ( ) ;
426- //call should be 2 times now
433+
427434 A . CallTo ( ( ) => _applicationRepository . GetBpnlCredentialIformationByApplicationId ( IdWithBpn ) )
428- . MustHaveHappenedTwiceExactly ( ) ;
435+ . MustHaveHappenedOnceExactly ( ) ;
436+ result . StepStatusId . Should ( ) . Be ( ProcessStepStatusId . DONE ) ;
437+ result . ScheduleStepTypeIds . Should ( ) . ContainSingle ( ) . Which . Should ( ) . Be ( ProcessStepTypeId . AWAIT_MEMBERSHIP_CREDENTIAL_RESPONSE ) ;
438+ result . Modified . Should ( ) . BeTrue ( ) ;
439+ result . SkipStepTypeIds . Should ( ) . BeNull ( ) ;
440+ result . ModifyChecklistEntry . Should ( ) . NotBeNull ( ) ;
441+ result . ModifyChecklistEntry ! ( entry ) ;
442+ entry . ApplicationChecklistEntryStatusId . Should ( ) . Be ( ApplicationChecklistEntryStatusId . IN_PROGRESS ) ;
443+ }
444+
445+ [ Fact ]
446+ public async Task CreateMembershipCredential_WithValid_BringYourOwnWallet_False_CallsExpected ( )
447+ {
448+ // Arrange
449+ CreateContextForCredential ( out var entry , out var checklist ) ;
450+ var context = new IApplicationChecklistService . WorkerChecklistProcessStepData ( IdWithBpn , ProcessStepTypeId . REQUEST_BPN_CREDENTIAL , checklist . ToImmutableDictionary ( ) , Enumerable . Empty < ProcessStepTypeId > ( ) ) ;
451+
452+ //bring your own wallet false
453+ A . CallTo ( ( ) => _companyRepository . IsBringYourOwnWallet ( A < Guid > . _ ) ) . Returns ( false ) ;
454+
455+ // Act
456+ var result = await _sut . CreateMembershipCredential ( context , CancellationToken . None ) ;
457+
458+ // Assert
459+ A . CallTo ( ( ) => _issuerComponentService
460+ . CreateMembershipCredential (
461+ A < CreateMembershipCredentialRequest > . That . Matches ( x =>
462+ x . Holder == "did:123:testabc" &&
463+ x . HolderBpn == ValidBpn &&
464+ x . TechnicalUserDetails != null &&
465+ x . TechnicalUserDetails . ClientId == "cl1" &&
466+ x . TechnicalUserDetails . ClientSecret == "test123" &&
467+ x . TechnicalUserDetails . WalletUrl == "https://example.com/wallet" &&
468+ x . CallbackUrl == "https://example.org/callback/api/administration/registration/issuer/membershipcredential"
469+ ) ,
470+ A < CancellationToken > . _ ) )
471+ . MustHaveHappenedOnceExactly ( ) ;
472+
473+ A . CallTo ( ( ) => _applicationRepository . GetBpnlCredentialIformationByApplicationId ( IdWithBpn ) )
474+ . MustHaveHappenedOnceExactly ( ) ;
429475 result . StepStatusId . Should ( ) . Be ( ProcessStepStatusId . DONE ) ;
430476 result . ScheduleStepTypeIds . Should ( ) . ContainSingle ( ) . Which . Should ( ) . Be ( ProcessStepTypeId . AWAIT_MEMBERSHIP_CREDENTIAL_RESPONSE ) ;
431477 result . Modified . Should ( ) . BeTrue ( ) ;
@@ -741,20 +787,18 @@ private void SetupForProcessIssuerComponentResponse(ApplicationChecklistEntry ap
741787
742788 #endregion
743789
744- private void CreateContextForCredential ( out ApplicationChecklistEntry entry , out IApplicationChecklistService . WorkerChecklistProcessStepData context )
790+ private void CreateContextForCredential ( out ApplicationChecklistEntry entry , out Dictionary < ApplicationChecklistEntryTypeId , ApplicationChecklistEntryStatusId > checklist )
745791 {
746792 var cryptoConfig = _options . Value . EncryptionConfigs . First ( ) ;
747793 var ( secret , vector ) = CryptoHelper . Encrypt ( "test123" , Convert . FromHexString ( cryptoConfig . EncryptionKey ) , cryptoConfig . CipherMode , cryptoConfig . PaddingMode ) ;
748- var checklist = new Dictionary < ApplicationChecklistEntryTypeId , ApplicationChecklistEntryStatusId >
794+ checklist = new Dictionary < ApplicationChecklistEntryTypeId , ApplicationChecklistEntryStatusId >
749795 {
750796 { ApplicationChecklistEntryTypeId . REGISTRATION_VERIFICATION , ApplicationChecklistEntryStatusId . DONE } ,
751797 { ApplicationChecklistEntryTypeId . BUSINESS_PARTNER_NUMBER , ApplicationChecklistEntryStatusId . DONE } ,
752798 { ApplicationChecklistEntryTypeId . IDENTITY_WALLET , ApplicationChecklistEntryStatusId . DONE } ,
753799 { ApplicationChecklistEntryTypeId . BPNL_CREDENTIAL , ApplicationChecklistEntryStatusId . TO_DO }
754- }
755- . ToImmutableDictionary ( ) ;
800+ } ;
756801 entry = new ApplicationChecklistEntry ( IdWithBpn , ApplicationChecklistEntryTypeId . BPNL_CREDENTIAL , ApplicationChecklistEntryStatusId . TO_DO , DateTimeOffset . UtcNow ) ;
757- context = new IApplicationChecklistService . WorkerChecklistProcessStepData ( IdWithBpn , ProcessStepTypeId . REQUEST_BPN_CREDENTIAL , checklist , Enumerable . Empty < ProcessStepTypeId > ( ) ) ;
758802 A . CallTo ( ( ) => _applicationRepository . GetBpnlCredentialIformationByApplicationId ( A < Guid > . _ ) )
759803 . Returns ( ( true , "did:123:testabc" , ValidBpn , new WalletInformation ( "cl1" , secret , vector , 0 , "https://example.com/wallet" ) ) ) ;
760804 }
0 commit comments