Search in sources :

Example 1 with GetConsentResponse

use of net.petafuel.styx.api.v1.consent.entity.GetConsentResponse in project styx by petafuel.

the class GetConsentResource method fetchConsent.

/**
 * Returns the consent object with the corresponding accounts
 *
 * @param consentId of the target consent
 * @return a GetConsentResponse object
 * @throws BankRequestFailedException if something went wrong between the core service and the aspsp
 */
@AcceptsPreStepAuth
@GET
@Path("/consents/{consentId}")
public Response fetchConsent(@NotEmpty @NotBlank @PathParam("consentId") String consentId) throws BankRequestFailedException {
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setConsentId(consentId);
    IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
    ioProcessor.modifyInput(xs2AFactoryInput);
    AISRequest request = new AISRequestFactory().create(getXS2AStandard().getRequestClassProvider().consentRetrieval(), xs2AFactoryInput);
    request.getHeaders().putAll(getAdditionalHeaders());
    ioProcessor.modifyRequest(request, xs2AFactoryInput);
    Consent consent = getXS2AStandard().getCs().getConsent(request);
    GetConsentResponse response = new GetConsentResponse(consent);
    LOG.info("Successfully fetched consent entity for bic={}, consentId={}", getXS2AStandard().getAspsp().getBic(), consentId);
    return Response.status(ResponseConstant.OK).entity(response).build();
}
Also used : GetConsentResponse(net.petafuel.styx.api.v1.consent.entity.GetConsentResponse) Consent(net.petafuel.styx.core.xs2a.entities.Consent) AISRequest(net.petafuel.styx.core.xs2a.contracts.AISRequest) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) AISRequestFactory(net.petafuel.styx.core.xs2a.factory.AISRequestFactory) IOProcessor(net.petafuel.styx.core.ioprocessing.IOProcessor) AcceptsPreStepAuth(net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth) Path(javax.ws.rs.Path) ApplicationPath(javax.ws.rs.ApplicationPath) GET(javax.ws.rs.GET)

Example 2 with GetConsentResponse

use of net.petafuel.styx.api.v1.consent.entity.GetConsentResponse in project styx by petafuel.

the class ConsentResourcesFiduciaTest method B_fetchConsentTest.

@Override
@Test
@Category(IntegrationTest.class)
public void B_fetchConsentTest() throws IOException {
    Response response = fetchConsentEndpoint();
    Assertions.assertEquals(200, response.getStatus());
    GetConsentResponse consentResponse = jsonb.fromJson(IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8), GetConsentResponse.class);
    Assertions.assertNotNull(consentResponse.getConsent().getId());
    Assertions.assertTrue(consentResponse.getConsent().getAccess().getAccounts().contains(getAccountReference()));
}
Also used : Response(javax.ws.rs.core.Response) GetConsentResponse(net.petafuel.styx.api.v1.consent.entity.GetConsentResponse) POSTConsentResponse(net.petafuel.styx.api.v1.consent.entity.POSTConsentResponse) GetConsentStatusResponse(net.petafuel.styx.api.v1.consent.entity.GetConsentStatusResponse) AuthorisationStatusResponse(net.petafuel.styx.api.v1.payment.entity.AuthorisationStatusResponse) GetConsentResponse(net.petafuel.styx.api.v1.consent.entity.GetConsentResponse) InputStream(java.io.InputStream) Category(org.junit.experimental.categories.Category) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test)

Example 3 with GetConsentResponse

use of net.petafuel.styx.api.v1.consent.entity.GetConsentResponse in project styx by petafuel.

the class ConsentResourcesTargoTest method B_fetchConsentTest.

@Override
@Test
@Category(IntegrationTest.class)
public void B_fetchConsentTest() throws IOException {
    Response response = fetchConsentEndpoint();
    Assertions.assertEquals(200, response.getStatus());
    GetConsentResponse consentResponse = jsonb.fromJson(IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8), GetConsentResponse.class);
    Assertions.assertNotNull(consentResponse.getConsent().getId());
    Assertions.assertTrue(consentResponse.getConsent().getAccess().getAccounts().contains(getAccountReference()));
}
Also used : Response(javax.ws.rs.core.Response) GetConsentResponse(net.petafuel.styx.api.v1.consent.entity.GetConsentResponse) POSTConsentResponse(net.petafuel.styx.api.v1.consent.entity.POSTConsentResponse) GetConsentStatusResponse(net.petafuel.styx.api.v1.consent.entity.GetConsentStatusResponse) AuthorisationStatusResponse(net.petafuel.styx.api.v1.payment.entity.AuthorisationStatusResponse) GetConsentResponse(net.petafuel.styx.api.v1.consent.entity.GetConsentResponse) InputStream(java.io.InputStream) Category(org.junit.experimental.categories.Category) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test)

Example 4 with GetConsentResponse

use of net.petafuel.styx.api.v1.consent.entity.GetConsentResponse in project styx by petafuel.

the class ConsentResourcesConsorsTest method B_fetchConsentTest.

@Override
@Test
@Category(IntegrationTest.class)
public void B_fetchConsentTest() throws IOException {
    Response response = fetchConsentEndpoint();
    Assertions.assertEquals(200, response.getStatus());
    GetConsentResponse consentResponse = jsonb.fromJson(IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8), GetConsentResponse.class);
    Assertions.assertNotNull(consentResponse.getConsent().getId());
    Assertions.assertTrue(consentResponse.getConsent().getAccess().getAccounts().contains(getAccountReference()));
}
Also used : Response(javax.ws.rs.core.Response) GetConsentResponse(net.petafuel.styx.api.v1.consent.entity.GetConsentResponse) POSTConsentResponse(net.petafuel.styx.api.v1.consent.entity.POSTConsentResponse) GetConsentStatusResponse(net.petafuel.styx.api.v1.consent.entity.GetConsentStatusResponse) GetConsentResponse(net.petafuel.styx.api.v1.consent.entity.GetConsentResponse) InputStream(java.io.InputStream) Category(org.junit.experimental.categories.Category) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test)

Example 5 with GetConsentResponse

use of net.petafuel.styx.api.v1.consent.entity.GetConsentResponse in project styx by petafuel.

the class ConsentResourcesSparkasseTest method B_fetchConsentTest.

@Override
@Test
@Category(IntegrationTest.class)
public void B_fetchConsentTest() throws IOException {
    Response response = fetchConsentEndpoint();
    Assertions.assertEquals(200, response.getStatus());
    GetConsentResponse consentResponse = jsonb.fromJson(IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8), GetConsentResponse.class);
    Assertions.assertNotNull(consentResponse.getConsent().getId());
    Assertions.assertTrue(consentResponse.getConsent().getAccess().getAccounts().contains(getAccountReference()));
}
Also used : Response(javax.ws.rs.core.Response) GetConsentResponse(net.petafuel.styx.api.v1.consent.entity.GetConsentResponse) POSTConsentResponse(net.petafuel.styx.api.v1.consent.entity.POSTConsentResponse) GetConsentStatusResponse(net.petafuel.styx.api.v1.consent.entity.GetConsentStatusResponse) GetConsentResponse(net.petafuel.styx.api.v1.consent.entity.GetConsentResponse) InputStream(java.io.InputStream) Category(org.junit.experimental.categories.Category) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test)

Aggregations

GetConsentResponse (net.petafuel.styx.api.v1.consent.entity.GetConsentResponse)5 InputStream (java.io.InputStream)4 Response (javax.ws.rs.core.Response)4 IntegrationTest (net.petafuel.styx.api.IntegrationTest)4 GetConsentStatusResponse (net.petafuel.styx.api.v1.consent.entity.GetConsentStatusResponse)4 POSTConsentResponse (net.petafuel.styx.api.v1.consent.entity.POSTConsentResponse)4 Test (org.junit.Test)4 Category (org.junit.experimental.categories.Category)4 AuthorisationStatusResponse (net.petafuel.styx.api.v1.payment.entity.AuthorisationStatusResponse)2 ApplicationPath (javax.ws.rs.ApplicationPath)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 AcceptsPreStepAuth (net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth)1 IOProcessor (net.petafuel.styx.core.ioprocessing.IOProcessor)1 AISRequest (net.petafuel.styx.core.xs2a.contracts.AISRequest)1 Consent (net.petafuel.styx.core.xs2a.entities.Consent)1 AISRequestFactory (net.petafuel.styx.core.xs2a.factory.AISRequestFactory)1 XS2AFactoryInput (net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput)1