Search in sources :

Example 6 with Tpp

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();
}
Also used : FRAccountRequest(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest) Tpp(com.forgerock.openbanking.model.Tpp) X509Authentication(com.forgerock.spring.security.multiauth.model.authentication.X509Authentication) Authentication(org.springframework.security.core.Authentication) X509Authentication(com.forgerock.spring.security.multiauth.model.authentication.X509Authentication) Test(org.junit.Test)

Example 7 with Tpp

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);
}
Also used : Tpp(com.forgerock.openbanking.model.Tpp) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with Tpp

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);
}
Also used : Tpp(com.forgerock.openbanking.model.Tpp) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with Tpp

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));
}
Also used : FRAccountRequest(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest) Tpp(com.forgerock.openbanking.model.Tpp)

Example 10 with Tpp

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);
}
Also used : JacksonObjectMapper(kong.unirest.JacksonObjectMapper) Tpp(com.forgerock.openbanking.model.Tpp) JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JacksonObjectMapper(kong.unirest.JacksonObjectMapper) Before(org.junit.Before)

Aggregations

Tpp (com.forgerock.openbanking.model.Tpp)131 ConsentStatusEntry (com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)39 Test (org.junit.Test)28 OIDCRegistrationResponse (com.forgerock.openbanking.model.oidc.OIDCRegistrationResponse)19 Before (org.junit.Before)13 SpringSecForTest (com.forgerock.openbanking.integration.test.support.SpringSecForTest)12 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)12 JacksonObjectMapper (kong.unirest.JacksonObjectMapper)11 OAuth2InvalidClientException (com.forgerock.openbanking.common.error.exception.oauth2.OAuth2InvalidClientException)9 OBErrorException (com.forgerock.openbanking.exceptions.OBErrorException)9 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)9 AccountWithBalance (com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance)8 URI (java.net.URI)8 FRInternationalStandingOrderConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalStandingOrderConsent)7 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)7 FRWriteInternationalStandingOrderConsent (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalStandingOrderConsent)6 FRDomesticConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent)6 FRDomesticScheduledConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent)6 FRDomesticStandingOrderConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent)6