use of com.forgerock.openbanking.model.Tpp in project openbanking-aspsp by OpenBankingToolkit.
the class AccountsApiEndpointWrapperTest method testMatls_success.
@Test
public void testMatls_success() {
// Given
String authorisatioNumber = "PSDGB-OB-2345343";
String clientId = "clientId";
FRAccountRequest accountRequest = new FRAccountRequest();
accountRequest.setClientId(clientId);
wrapper.accountRequest = accountRequest;
Collection<? extends GrantedAuthority> authorities = Collections.emptyList();
Authentication authentication = new X509Authentication(authorisatioNumber, authorities, null);
wrapper.principal = authentication;
Tpp tpp = new Tpp();
tpp.setAuthorisationNumber(authorisatioNumber);
given(this.tppStoreService.findByClientId(clientId)).willReturn(Optional.of(tpp));
// Then
assertThatCode(() -> wrapper.verifyMatlsFromAccountRequest()).doesNotThrowAnyException();
}
use of com.forgerock.openbanking.model.Tpp in project openbanking-aspsp by OpenBankingToolkit.
the class AccountAccessConsentsApiControllerIT method createAccountAccessConsent.
@Test
public void createAccountAccessConsent() throws Exception {
// Given
String jws = jws("accounts", OIDCConstants.GrantType.CLIENT_CREDENTIAL);
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_AISP);
mockAccessTokenVerification(jws);
OBReadConsentResponse1 readConsentResponse = new OBReadConsentResponse1().data(new OBReadConsentResponse1Data().consentId("AISP_3980298093280").statusUpdateDateTime(DateTime.now()).status(OBExternalRequestStatus1Code.AWAITINGAUTHORISATION).permissions(Collections.singletonList(OBExternalPermissions1Code.READACCOUNTSBASIC)));
given(rsStoreGateway.toRsStore(any(), any(), any(), any(), any())).willReturn(ResponseEntity.status(HttpStatus.CREATED).body(readConsentResponse));
Tpp tpp = new Tpp();
tpp.setAuthorisationNumber("test-tpp");
given(tppStoreService.findByClientId(any())).willReturn(Optional.of(tpp));
final OBReadConsent1 obReadConsent = new OBReadConsent1().data(new OBReadData1().permissions(Collections.singletonList(OBExternalPermissions1Code.READACCOUNTSBASIC))).risk(new OBRisk2());
// When
HttpResponse<OBReadConsentResponse1> response = Unirest.post("https://rs-api:" + port + "/open-banking/v3.1/aisp/account-access-consents/").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "Bearer " + jws).header(OBHeaders.X_IDEMPOTENCY_KEY, UUID.randomUUID().toString()).header(OBHeaders.X_JWS_SIGNATURE, UUID.randomUUID().toString()).header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").body(obReadConsent).asObject(OBReadConsentResponse1.class);
// Then
verify(accountAccessConsentPermittedPermissionsFilter, times(1)).filter(any());
assertThat(response.getStatus()).isEqualTo(201);
}
use of com.forgerock.openbanking.model.Tpp in project openbanking-aspsp by OpenBankingToolkit.
the class AccountAccessConsentsApiControllerIT method createCustomerInfoAccountAccessConsent.
@Test
public void createCustomerInfoAccountAccessConsent() throws Exception {
// Given
String jws = jws("accounts", OIDCConstants.GrantType.CLIENT_CREDENTIAL);
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_AISP);
mockAccessTokenVerification(jws);
OBReadConsentResponse1 readConsentResponse = new OBReadConsentResponse1().data(new OBReadConsentResponse1Data().consentId("AISP_3980298093280").statusUpdateDateTime(DateTime.now()).status(OBExternalRequestStatus1Code.AWAITINGAUTHORISATION).permissions(Collections.singletonList(OBExternalPermissions1Code.READCUSTOMERINFOCONSENT)));
given(rsStoreGateway.toRsStore(any(), any(), any(), any(), any())).willReturn(ResponseEntity.status(HttpStatus.CREATED).body(readConsentResponse));
Tpp tpp = new Tpp();
tpp.setAuthorisationNumber("test-tpp");
given(tppStoreService.findByClientId(any())).willReturn(Optional.of(tpp));
final OBReadConsent1 obReadConsent = new OBReadConsent1().data(new OBReadData1().permissions(Collections.singletonList(OBExternalPermissions1Code.READCUSTOMERINFOCONSENT))).risk(new OBRisk2());
// When
HttpResponse<OBReadConsentResponse1> response = Unirest.post("https://rs-api:" + port + "/open-banking/v3.1/aisp/account-access-consents/").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "Bearer " + jws).header(OBHeaders.X_IDEMPOTENCY_KEY, UUID.randomUUID().toString()).header(OBHeaders.X_JWS_SIGNATURE, UUID.randomUUID().toString()).header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").body(obReadConsent).asObject(OBReadConsentResponse1.class);
// Then
verify(accountAccessConsentPermittedPermissionsFilter, times(1)).filter(any());
assertThat(response.getStatus()).isEqualTo(201);
}
use of com.forgerock.openbanking.model.Tpp in project openbanking-aspsp by OpenBankingToolkit.
the class TransactionsApiControllerIT method mockAccountPermissions.
private void mockAccountPermissions(List<FRExternalPermissionsCode> permissions) {
FRAccountRequest value = new FRAccountRequest();
Tpp tpp = new Tpp();
tpp.setClientId("test-tpp");
value.setAisp(tpp);
value.setAccountIds(Collections.singletonList("100000123"));
value.setAccountRequest(FRReadResponse.builder().data(FRReadDataResponse.builder().permissions(permissions).transactionFromDateTime(CONSENT_FROM).transactionToDateTime(CONSENT_TO).status(FRExternalRequestStatusCode.AUTHORISED).build()).build());
given(accountRequestStore.get(any())).willReturn(Optional.of(value));
}
use of com.forgerock.openbanking.model.Tpp in project openbanking-aspsp by OpenBankingToolkit.
the class InfoApiControllerIT method setUp.
@Before
public void setUp() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JodaModule());
JacksonObjectMapper jacksonObjectMapper = new JacksonObjectMapper(objectMapper);
Unirest.config().setObjectMapper(jacksonObjectMapper).verifySsl(false);
tpp = new Tpp();
tpp.setClientId(CLIENT_ID);
tpp.setAuthorisationNumber(AUTHORISATION_NUMBER);
}
Aggregations