diff --git a/build.gradle b/build.gradle index a760a6e44..3ffaa2257 100644 --- a/build.gradle +++ b/build.gradle @@ -50,7 +50,7 @@ dependencies { implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:${openApiVersion}" implementation group: 'com.smartsensesolutions', name: 'commons-dao', version: '0.0.5' implementation 'org.liquibase:liquibase-core' - implementation 'org.eclipse.tractusx.ssi:cx-ssi-lib:0.0.14' + implementation 'org.eclipse.tractusx.ssi:cx-ssi-lib:0.0.15' //Added explicitly to mitigate CVE 2022-1471 implementation group: 'org.yaml', name: 'snakeyaml', version: '2.0' diff --git a/src/main/java/org/eclipse/tractusx/managedidentitywallets/controller/WalletController.java b/src/main/java/org/eclipse/tractusx/managedidentitywallets/controller/WalletController.java index 1ad61c46e..6ace5285c 100644 --- a/src/main/java/org/eclipse/tractusx/managedidentitywallets/controller/WalletController.java +++ b/src/main/java/org/eclipse/tractusx/managedidentitywallets/controller/WalletController.java @@ -155,10 +155,10 @@ public class WalletController extends BaseController { """) }) }) - @Operation(summary = "Create Wallet", description = "Permission: **add_wallets** \n\n Create a wallet and store it") + @Operation(summary = "Create Wallet", description = "Permission: **add_wallets** (The BPN of the base wallet must equal BPN of caller)\n\n Create a wallet and store it") @PostMapping(path = RestURI.WALLETS, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity createWallet(@Valid @RequestBody CreateWalletRequest request) { - return ResponseEntity.status(HttpStatus.CREATED).body(service.createWallet(request)); + public ResponseEntity createWallet(@Valid @RequestBody CreateWalletRequest request, Principal principal) { + return ResponseEntity.status(HttpStatus.CREATED).body(service.createWallet(request,getBPNFromToken(principal))); } /** diff --git a/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/WalletService.java b/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/WalletService.java index bab1f7ede..ce7cef318 100644 --- a/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/WalletService.java +++ b/src/main/java/org/eclipse/tractusx/managedidentitywallets/service/WalletService.java @@ -76,6 +76,10 @@ public class WalletService extends BaseService { + /** + * The constant BASE_WALLET_BPN_IS_NOT_MATCHING_WITH_REQUEST_BPN_FROM_TOKEN. + */ + public static final String BASE_WALLET_BPN_IS_NOT_MATCHING_WITH_REQUEST_BPN_FROM_TOKEN = "Base wallet BPN is not matching with request BPN(from token)"; private final WalletRepository walletRepository; private final MIWSettings miwSettings; @@ -195,8 +199,8 @@ public Page getWallets(int pageNumber, int size, String sortColumn, Stri */ @SneakyThrows @Transactional(isolation = Isolation.READ_UNCOMMITTED, propagation = Propagation.REQUIRED) - public Wallet createWallet(CreateWalletRequest request) { - return createWallet(request, false); + public Wallet createWallet(CreateWalletRequest request, String callerBpn) { + return createWallet(request, false,callerBpn); } /** @@ -206,8 +210,8 @@ public Wallet createWallet(CreateWalletRequest request) { * @return the wallet */ @SneakyThrows - private Wallet createWallet(CreateWalletRequest request, boolean authority) { - validateCreateWallet(request); + private Wallet createWallet(CreateWalletRequest request, boolean authority, String callerBpn) { + validateCreateWallet(request,callerBpn); //create private key pair IKeyGenerator keyGenerator = new x21559Generator(); @@ -275,19 +279,22 @@ public void createAuthorityWallet() { .name(miwSettings.authorityWalletName()) .bpn(miwSettings.authorityWalletBpn()) .build(); - createWallet(request, true); + createWallet(request, true,miwSettings.authorityWalletBpn()); log.info("Authority wallet created with bpn {}", StringEscapeUtils.escapeJava(miwSettings.authorityWalletBpn())); } else { log.info("Authority wallet exists with bpn {}", StringEscapeUtils.escapeJava(miwSettings.authorityWalletBpn())); } } - private void validateCreateWallet(CreateWalletRequest request) { + private void validateCreateWallet(CreateWalletRequest request,String callerBpn) { + // check base wallet + Validate.isFalse(callerBpn.equalsIgnoreCase(miwSettings.authorityWalletBpn())).launch(new ForbiddenException(BASE_WALLET_BPN_IS_NOT_MATCHING_WITH_REQUEST_BPN_FROM_TOKEN)); + + // check wallet already exists boolean exist = walletRepository.existsByBpn(request.getBpn()); if (exist) { throw new DuplicateWalletProblem("Wallet is already exists for bpn " + request.getBpn()); } - } @SneakyThrows private String getPrivateKeyString(byte[] privateKeyBytes) { diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/did/DidDocumentsTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/did/DidDocumentsTest.java index 538e0c6b3..f11d9c674 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/did/DidDocumentsTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/did/DidDocumentsTest.java @@ -22,6 +22,7 @@ package org.eclipse.tractusx.managedidentitywallets.did; import org.eclipse.tractusx.managedidentitywallets.ManagedIdentityWalletsApplication; +import org.eclipse.tractusx.managedidentitywallets.config.MIWSettings; import org.eclipse.tractusx.managedidentitywallets.config.TestContextInitializer; import org.eclipse.tractusx.managedidentitywallets.constant.RestURI; import org.eclipse.tractusx.managedidentitywallets.dao.entity.Wallet; @@ -47,6 +48,9 @@ class DidDocumentsTest { @Autowired private TestRestTemplate restTemplate; + @Autowired + private MIWSettings miwSettings; + @Test void getDidDocumentInvalidBpn404() { ResponseEntity response = restTemplate.getForEntity(RestURI.DID_DOCUMENTS, String.class, UUID.randomUUID().toString()); @@ -85,6 +89,6 @@ private Wallet createWallet(String bpn) { CreateWalletRequest createWalletRequest = new CreateWalletRequest(); createWalletRequest.setBpn(bpn); createWalletRequest.setName("wallet_" + bpn); - return walletService.createWallet(createWalletRequest); + return walletService.createWallet(createWalletRequest,miwSettings.authorityWalletBpn()); } } diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/utils/TestUtils.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/utils/TestUtils.java index d0c184fc9..885553974 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/utils/TestUtils.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/utils/TestUtils.java @@ -56,8 +56,8 @@ public class TestUtils { - public static ResponseEntity createWallet(String bpn, String name, TestRestTemplate testTemplate) { - HttpHeaders headers = AuthenticationUtils.getValidUserHttpHeaders(bpn); + public static ResponseEntity createWallet(String bpn, String name, TestRestTemplate testTemplate,String baseBPN) { + HttpHeaders headers = AuthenticationUtils.getValidUserHttpHeaders(baseBPN); CreateWalletRequest request = CreateWalletRequest.builder().bpn(bpn).name(name).build(); diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/DeleteHoldersCredentialTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/DeleteHoldersCredentialTest.java index 3d5e7fc5b..9d0707083 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/DeleteHoldersCredentialTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/DeleteHoldersCredentialTest.java @@ -82,7 +82,7 @@ public void setup() { final CreateWalletRequest createWalletRequest = new CreateWalletRequest(); createWalletRequest.setBpn(tenantBpn); createWalletRequest.setName("My Test Tenant Wallet"); - final Wallet tenantWallet = walletService.createWallet(createWalletRequest); + final Wallet tenantWallet = walletService.createWallet(createWalletRequest,bpnOperator); tenantDid = DidParser.parse(tenantWallet.getDid()); } diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/DismantlerHoldersCredentialTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/DismantlerHoldersCredentialTest.java index 42bc558c0..8f2c09f1b 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/DismantlerHoldersCredentialTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/DismantlerHoldersCredentialTest.java @@ -112,9 +112,10 @@ void issueDismantlerCredentialTest201() throws JsonProcessingException, JSONExce String bpn = UUID.randomUUID().toString(); String did = DidWebFactory.fromHostnameAndPath(miwSettings.host(), bpn).toString(); + String baseBpn = miwSettings.authorityWalletBpn(); //create wallet - Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, bpn, restTemplate).getBody()); + Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, bpn, restTemplate,baseBpn).getBody()); String oldSummaryCredentialId = TestUtils.getSummaryCredentialId(wallet.getDid(), holdersCredentialRepository); ResponseEntity response = issueDismantlerCredential(bpn, did); diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/FrameworkHoldersCredentialTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/FrameworkHoldersCredentialTest.java index 611b72424..499519267 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/FrameworkHoldersCredentialTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/FrameworkHoldersCredentialTest.java @@ -187,7 +187,8 @@ void issueFrameworkCredentialTest400() throws JsonProcessingException, JSONExcep private void createAndValidateVC(String bpn, String did, String type) throws JsonProcessingException { //create wallet - Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, bpn, restTemplate).getBody()); + String baseBpn = miwSettings.authorityWalletBpn(); + Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, bpn, restTemplate,baseBpn).getBody()); String oldSummaryCredentialId = TestUtils.getSummaryCredentialId(wallet.getDid(), holdersCredentialRepository); HttpHeaders headers = AuthenticationUtils.getValidUserHttpHeaders(miwSettings.authorityWalletBpn()); diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/HoldersCredentialTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/HoldersCredentialTest.java index 61019c676..861736b68 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/HoldersCredentialTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/HoldersCredentialTest.java @@ -304,8 +304,8 @@ void validateExpiredCredentialsWithExpiryCheckTrue() throws com.fasterxml.jackso private Map issueVC() throws JsonProcessingException { String bpn = UUID.randomUUID().toString(); - HttpHeaders headers = AuthenticationUtils.getValidUserHttpHeaders(bpn); - TestUtils.createWallet(bpn, "Test", restTemplate); + String baseBpn = miwSettings.authorityWalletBpn(); + TestUtils.createWallet(bpn, "Test", restTemplate,baseBpn); ResponseEntity vc = TestUtils.issueMembershipVC(restTemplate, bpn, miwSettings.authorityWalletBpn()); VerifiableCredential verifiableCredential = new VerifiableCredential(new ObjectMapper().readValue(vc.getBody(), Map.class)); Map map = objectMapper.readValue(verifiableCredential.toJson(), Map.class); @@ -314,8 +314,9 @@ private Map issueVC() throws JsonProcessingException { private ResponseEntity issueVC(String bpn, String did, String type, HttpHeaders headers) throws JsonProcessingException { + String baseBpn = miwSettings.authorityWalletBpn(); //save wallet - TestUtils.createWallet(bpn, did, restTemplate); + TestUtils.createWallet(bpn, did, restTemplate,baseBpn); // Create VC without proof //VC Bulider diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/IssuersCredentialTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/IssuersCredentialTest.java index 76b913289..b6cbdd9f2 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/IssuersCredentialTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/IssuersCredentialTest.java @@ -229,9 +229,9 @@ void issueCredentials200() throws com.fasterxml.jackson.core.JsonProcessingExcep private ResponseEntity issueVC(String bpn, String holderDid, String issuerDid, String type, HttpHeaders headers) throws JsonProcessingException { - + String baseBpn = miwSettings.authorityWalletBpn(); //save wallet - TestUtils.createWallet(bpn, holderDid, restTemplate); + TestUtils.createWallet(bpn, holderDid, restTemplate,baseBpn); // Create VC without proof //VC Bulider diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/MembershipHoldersCredentialTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/MembershipHoldersCredentialTest.java index c68e14d4d..7be86edbd 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/MembershipHoldersCredentialTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/MembershipHoldersCredentialTest.java @@ -96,9 +96,10 @@ void issueMembershipCredentialTest403() { void testIssueSummeryVCAfterDeleteSummaryVCFromHolderWallet() throws JsonProcessingException { String bpn = UUID.randomUUID().toString(); String did = DidWebFactory.fromHostnameAndPath(miwSettings.host(), bpn).toString(); + String baseBpn = miwSettings.authorityWalletBpn(); // create wallet, in background bpn and summary credential generated - Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, bpn, restTemplate).getBody()); + Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, bpn, restTemplate,baseBpn).getBody()); List byHolderDid = holdersCredentialRepository.getByHolderDid(did); @@ -124,9 +125,10 @@ void testIssueSummeryVCAfterDeleteSummaryVCFromHolderWallet() throws JsonProcess void testStoredSummaryVCTest() throws JsonProcessingException { String bpn = UUID.randomUUID().toString(); String did = DidWebFactory.fromHostnameAndPath(miwSettings.host(), bpn).toString(); + String baseBpn = miwSettings.authorityWalletBpn(); // create wallet, in background bpn and summary credential generated - Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, bpn, restTemplate).getBody()); + Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, bpn, restTemplate,baseBpn).getBody()); String vc = """ @@ -185,10 +187,10 @@ void testStoredSummaryVCTest() throws JsonProcessingException { @Test void issueMembershipCredentialToBaseWalletTest400() throws JsonProcessingException { String bpn = UUID.randomUUID().toString(); - String did = DidWebFactory.fromHostnameAndPath(miwSettings.host(), bpn).toString(); + String baseBpn = miwSettings.authorityWalletBpn(); // create wallet, in background bpn and summary credential generated - Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, bpn, restTemplate).getBody()); + Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, bpn, restTemplate,baseBpn).getBody()); //add 2 subject in VC for testing List vcs = issuersCredentialRepository.getByIssuerDidAndHolderDidAndType(miwSettings.authorityWalletDid(), wallet.getDid(), MIWVerifiableCredentialType.SUMMARY_CREDENTIAL); @@ -278,9 +280,10 @@ void issueMembershipCredentialToBaseWalletTest201() throws JsonProcessingExcepti void issueMembershipCredentialTest201() throws JsonProcessingException, JSONException { String bpn = UUID.randomUUID().toString(); + String baseBpn = miwSettings.authorityWalletBpn(); //create wallet - Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, bpn, restTemplate).getBody()); + Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, bpn, restTemplate,baseBpn).getBody()); String oldSummaryCredentialId = TestUtils.getSummaryCredentialId(wallet.getDid(), holdersCredentialRepository); ResponseEntity response = TestUtils.issueMembershipVC(restTemplate, bpn, miwSettings.authorityWalletBpn()); diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/PresentationValidationTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/PresentationValidationTest.java index 678bbb449..1ce596a55 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/PresentationValidationTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/PresentationValidationTest.java @@ -94,13 +94,13 @@ public void setup() { CreateWalletRequest createWalletRequest = new CreateWalletRequest(); createWalletRequest.setBpn(bpnTenant_1); createWalletRequest.setName("My Test Tenant Wallet"); - Wallet tenantWallet = walletService.createWallet(createWalletRequest); + Wallet tenantWallet = walletService.createWallet(createWalletRequest,bpnOperator); tenant_1 = DidParser.parse(tenantWallet.getDid()); CreateWalletRequest createWalletRequest2 = new CreateWalletRequest(); createWalletRequest2.setBpn(bpnTenant_2); createWalletRequest2.setName("My Test Tenant Wallet"); - Wallet tenantWallet2 = walletService.createWallet(createWalletRequest2); + Wallet tenantWallet2 = walletService.createWallet(createWalletRequest2,bpnOperator); tenant_2 = DidParser.parse(tenantWallet2.getDid()); IssueMembershipCredentialRequest issueMembershipCredentialRequest = new IssueMembershipCredentialRequest(); diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vp/PresentationTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vp/PresentationTest.java index fc53ba6d6..c4e3eedf3 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vp/PresentationTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vp/PresentationTest.java @@ -243,37 +243,10 @@ void createPresentationWithInvalidBPNAccess403() throws JsonProcessingException Assertions.assertEquals(vpResponse.getStatusCode().value(), HttpStatus.NOT_FOUND.value()); } - @Test - void createPresentationWithMoreThenOneVC400() throws JsonProcessingException { - String bpn = UUID.randomUUID().toString(); - String didWeb = DidWebFactory.fromHostnameAndPath(miwSettings.host(), bpn).toString(); - - ResponseEntity response = TestUtils.createWallet(bpn, bpn, restTemplate); - Assertions.assertEquals(response.getStatusCode().value(), HttpStatus.CREATED.value()); - Wallet wallet = TestUtils.getWalletFromString(response.getBody()); - - //get BPN credentials - List credentials = holdersCredentialRepository.getByHolderDidAndType(wallet.getDid(), MIWVerifiableCredentialType.BPN_CREDENTIAL); - Assertions.assertFalse(credentials.isEmpty()); - Map map = objectMapper.readValue(credentials.get(0).getData().toJson(), Map.class); - - //create request - Map request = new HashMap<>(); - request.put(StringPool.HOLDER_IDENTIFIER, wallet.getDid()); - request.put(StringPool.VERIFIABLE_CREDENTIALS, List.of(map, map)); - - HttpHeaders headers = AuthenticationUtils.getValidUserHttpHeaders("invalid bpn"); - headers.put(HttpHeaders.CONTENT_TYPE, List.of(MediaType.APPLICATION_JSON_VALUE)); - - HttpEntity entity = new HttpEntity<>(objectMapper.writeValueAsString(request), headers); - - ResponseEntity vpResponse = restTemplate.exchange(RestURI.API_PRESENTATIONS + "?asJwt={asJwt}&audience={audience}", HttpMethod.POST, entity, Map.class, true, "companyA"); - Assertions.assertEquals(vpResponse.getStatusCode().value(), HttpStatus.BAD_REQUEST.value()); - } - @NotNull private Map getIssueVPRequest(String bpn) throws JsonProcessingException { - ResponseEntity response = TestUtils.createWallet(bpn, bpn, restTemplate); + String baseBpn = miwSettings.authorityWalletBpn(); + ResponseEntity response = TestUtils.createWallet(bpn, bpn, restTemplate,baseBpn); Assertions.assertEquals(response.getStatusCode().value(), HttpStatus.CREATED.value()); Wallet wallet = TestUtils.getWalletFromString(response.getBody()); @@ -291,7 +264,8 @@ private Map getIssueVPRequest(String bpn) throws JsonProcessingE @NotNull private ResponseEntity getIssueVPRequestWithShortExpiry(String bpn, String audience) throws JsonProcessingException { - ResponseEntity response = TestUtils.createWallet(bpn, bpn, restTemplate); + String baseBpn = miwSettings.authorityWalletBpn(); + ResponseEntity response = TestUtils.createWallet(bpn, bpn, restTemplate,baseBpn); Assertions.assertEquals(response.getStatusCode().value(), HttpStatus.CREATED.value()); Wallet wallet = TestUtils.getWalletFromString(response.getBody()); diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/wallet/WalletTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/wallet/WalletTest.java index 12d56bf96..045dd2e11 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/wallet/WalletTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/wallet/WalletTest.java @@ -127,8 +127,9 @@ void createWalletTest201() throws JsonProcessingException, JSONException { String bpn = UUID.randomUUID().toString(); String name = "Sample Wallet"; + String baseBpn = miwSettings.authorityWalletBpn(); - ResponseEntity response = TestUtils.createWallet(bpn, name, restTemplate); + ResponseEntity response = TestUtils.createWallet(bpn, name, restTemplate,baseBpn); Assertions.assertEquals(HttpStatus.CREATED.value(), response.getStatusCode().value()); Wallet wallet = TestUtils.getWalletFromString(response.getBody()); @@ -182,7 +183,9 @@ void storeCredentialsTest201() throws JsonProcessingException { String bpn = UUID.randomUUID().toString(); String did = DidWebFactory.fromHostnameAndPath(miwSettings.host(), bpn).toString(); - TestUtils.createWallet(bpn, "name", restTemplate); + String baseBpn = miwSettings.authorityWalletBpn(); + + TestUtils.createWallet(bpn, "name", restTemplate,baseBpn); ResponseEntity response = storeCredential(bpn, did); @@ -258,7 +261,8 @@ void storeCredentialsWithDifferentHolder403() throws JsonProcessingException { String bpn = UUID.randomUUID().toString(); String did = DidWebFactory.fromHostnameAndPath(miwSettings.host(), bpn).toString(); - TestUtils.createWallet(bpn, "name", restTemplate); + String baseBpn = miwSettings.authorityWalletBpn(); + TestUtils.createWallet(bpn, "name", restTemplate,baseBpn); HttpHeaders headers = AuthenticationUtils.getValidUserHttpHeaders("Some random pbn"); @@ -273,14 +277,15 @@ void createWalletWithDuplicateBpn409() throws JsonProcessingException { String bpn = UUID.randomUUID().toString(); String name = "Sample Wallet"; + String baseBpn = miwSettings.authorityWalletBpn(); //save wallet - ResponseEntity response = TestUtils.createWallet(bpn, name, restTemplate); + ResponseEntity response = TestUtils.createWallet(bpn, name, restTemplate,baseBpn); TestUtils.getWalletFromString(response.getBody()); Assertions.assertEquals(HttpStatus.CREATED.value(), response.getStatusCode().value()); //try with again with same BPN - ResponseEntity response1 = TestUtils.createWallet(bpn, name, restTemplate); + ResponseEntity response1 = TestUtils.createWallet(bpn, name, restTemplate,baseBpn); Assertions.assertEquals(HttpStatus.CONFLICT.value(), response1.getStatusCode().value()); } @@ -299,8 +304,9 @@ void getWalletByIdentifierTest403() { @Test void getWalletByIdentifierWithInvalidBPNTest403() { String bpn = UUID.randomUUID().toString(); + String baseBpn = miwSettings.authorityWalletBpn(); - TestUtils.createWallet(bpn, "sample name", restTemplate); + TestUtils.createWallet(bpn, "sample name", restTemplate,baseBpn); //create token with different BPN HttpHeaders headers = AuthenticationUtils.getValidUserHttpHeaders("invalid BPN"); @@ -315,9 +321,10 @@ void getWalletByIdentifierWithInvalidBPNTest403() { void getWalletByIdentifierBPNTest200() throws JsonProcessingException { String bpn = UUID.randomUUID().toString(); String name = "Sample Name"; + String baseBpn = miwSettings.authorityWalletBpn(); //Create entry - Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, name, restTemplate).getBody()); + Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, name, restTemplate,baseBpn).getBody()); //get wallet without credentials HttpHeaders headers = AuthenticationUtils.getValidUserHttpHeaders(bpn); @@ -338,8 +345,10 @@ void getWalletByIdentifierBPNWithCredentialsTest200() throws JsonProcessingExcep String bpn = UUID.randomUUID().toString(); String name = "Sample Name"; String did = DidWebFactory.fromHostnameAndPath(miwSettings.host(), bpn).toString(); + String baseBpn = miwSettings.authorityWalletBpn(); + //Create entry - Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, name, restTemplate).getBody()); + Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, name, restTemplate,baseBpn).getBody()); //store credentials ResponseEntity response = storeCredential(bpn, did); @@ -365,10 +374,10 @@ void getWalletByIdentifierDidTest200() throws JsonProcessingException { String bpn = UUID.randomUUID().toString(); String name = "Sample Name"; - String did = "did:web:localhost:" + bpn; + String baseBpn = miwSettings.authorityWalletBpn(); //Create entry - Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, name, restTemplate).getBody()); + Wallet wallet = TestUtils.getWalletFromString(TestUtils.createWallet(bpn, name, restTemplate,baseBpn).getBody()); HttpHeaders headers = AuthenticationUtils.getValidUserHttpHeaders(bpn); HttpEntity entity = new HttpEntity<>(headers); @@ -410,9 +419,9 @@ void getWallets200() throws JsonProcessingException { String bpn = UUID.randomUUID().toString(); String name = "Sample Name"; - String did = DidWebFactory.fromHostnameAndPath(miwSettings.host(), bpn).toString(); + String baseBpn = miwSettings.authorityWalletBpn(); //Create entry - TestUtils.createWallet(bpn, name, restTemplate); + TestUtils.createWallet(bpn, name, restTemplate,baseBpn); HttpHeaders headers = AuthenticationUtils.getValidUserHttpHeaders(); HttpEntity entity = new HttpEntity<>(headers);