Search in sources :

Example 1 with XS2ARequest

use of net.petafuel.styx.core.xs2a.contracts.XS2ARequest in project styx by petafuel.

the class STYX09IntegrationTest method testStyx09.

@Test
@Category(IntegrationTest.class)
public void testStyx09() throws ImplementerOptionException {
    Assume.assumeNotNull(ing);
    Assume.assumeNotNull(styx09Option);
    styx09Option.setOptions(Collections.singletonMap("required", true));
    ing.getConfig().setImplementerOptions(Collections.singletonMap("STYX09", styx09Option));
    IOParser ioParser = new IOParser(ing);
    STYX09 styx09 = new STYX09(ioParser);
    Assertions.assertEquals(IOOrder.POST_CREATION, styx09.order());
    XS2ARequest xs2ARequest = new XS2ARequest() {

        @Override
        public Optional<String> getRawBody() {
            return Optional.empty();
        }

        @Override
        public BasicService.RequestType getHttpMethod() {
            return BasicService.RequestType.POST;
        }

        @Override
        public String getServicePath() {
            return "";
        }
    };
    Assertions.assertTrue(styx09.apply(null, xs2ARequest, null));
    Assertions.assertNotNull(xs2ARequest.getHeaders().get(XS2AHeader.AUTHORIZATION));
    Assertions.assertNotNull(xs2ARequest.getHeaders().get(INGSigner.ING_CLIENT_ID));
    Assertions.assertNotNull(xs2ARequest.getHeaders().get(INGSigner.REQUEST_TARGET));
    Assertions.assertEquals(ingClientId, xs2ARequest.getHeaders().get(INGSigner.ING_CLIENT_ID));
    Assertions.assertNotEquals("post /oauth2/token", xs2ARequest.getHeaders().get(INGSigner.REQUEST_TARGET));
}
Also used : BasicService(net.petafuel.styx.core.xs2a.contracts.BasicService) IOParser(net.petafuel.styx.core.ioprocessing.IOParser) XS2ARequest(net.petafuel.styx.core.xs2a.contracts.XS2ARequest) Category(org.junit.experimental.categories.Category) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test) StyxRESTTest(net.petafuel.styx.api.StyxRESTTest)

Example 2 with XS2ARequest

use of net.petafuel.styx.core.xs2a.contracts.XS2ARequest in project styx by petafuel.

the class STYX10UnitTest method test_STYX10_with_uk_bank.

@Test
void test_STYX10_with_uk_bank() throws ImplementerOptionException {
    uniCredit.setBic(TEST_BIC_UK);
    Assume.assumeNotNull(uniCredit);
    Assume.assumeNotNull(styx10Option);
    styx10Option.setOptions(Collections.singletonMap("required", true));
    uniCredit.getConfig().setImplementerOptions(Collections.singletonMap("STYX10", styx10Option));
    IOParser ioParser = new IOParser(uniCredit);
    STYX10 styx10 = new STYX10(ioParser);
    Assertions.assertEquals(IOOrder.POST_CREATION, styx10.order());
    Assertions.assertFalse(styx10.apply(null, null, null));
    XS2ARequest xs2ARequest = new XS2ARequest() {

        @Override
        public Optional<String> getRawBody() {
            return Optional.empty();
        }

        @Override
        public BasicService.RequestType getHttpMethod() {
            return BasicService.RequestType.GET;
        }

        @Override
        public String getServicePath() {
            return "";
        }
    };
    PSU psu = new PSU("bgdemo");
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setPsu(psu);
    Assertions.assertFalse(styx10.apply(xs2AFactoryInput, xs2ARequest, null));
}
Also used : BasicService(net.petafuel.styx.core.xs2a.contracts.BasicService) PSU(net.petafuel.styx.core.xs2a.entities.PSU) IOParser(net.petafuel.styx.core.ioprocessing.IOParser) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) XS2ARequest(net.petafuel.styx.core.xs2a.contracts.XS2ARequest) Test(org.junit.jupiter.api.Test)

Example 3 with XS2ARequest

use of net.petafuel.styx.core.xs2a.contracts.XS2ARequest in project styx by petafuel.

the class STYX10UnitTest method test_STYX10_with_invalid_bic.

@Test
void test_STYX10_with_invalid_bic() throws ImplementerOptionException {
    uniCredit.setBic(TEST_BIC_INVALID);
    Assume.assumeNotNull(uniCredit);
    Assume.assumeNotNull(styx10Option);
    styx10Option.setOptions(Collections.singletonMap("required", true));
    uniCredit.getConfig().setImplementerOptions(Collections.singletonMap("STYX10", styx10Option));
    IOParser ioParser = new IOParser(uniCredit);
    STYX10 styx10 = new STYX10(ioParser);
    Assertions.assertEquals(IOOrder.POST_CREATION, styx10.order());
    Assertions.assertFalse(styx10.apply(null, null, null));
    XS2ARequest xs2ARequest = new XS2ARequest() {

        @Override
        public Optional<String> getRawBody() {
            return Optional.empty();
        }

        @Override
        public BasicService.RequestType getHttpMethod() {
            return BasicService.RequestType.GET;
        }

        @Override
        public String getServicePath() {
            return "";
        }
    };
    PSU psu = new PSU("bgdemo");
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setPsu(psu);
    Assertions.assertThrows(ImplementerOptionException.class, () -> styx10.apply(xs2AFactoryInput, xs2ARequest, null));
}
Also used : BasicService(net.petafuel.styx.core.xs2a.contracts.BasicService) PSU(net.petafuel.styx.core.xs2a.entities.PSU) IOParser(net.petafuel.styx.core.ioprocessing.IOParser) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) XS2ARequest(net.petafuel.styx.core.xs2a.contracts.XS2ARequest) Test(org.junit.jupiter.api.Test)

Example 4 with XS2ARequest

use of net.petafuel.styx.core.xs2a.contracts.XS2ARequest in project styx by petafuel.

the class STYX10UnitTest method test_STYX10_with_german_bank.

@Test
void test_STYX10_with_german_bank() throws ImplementerOptionException {
    uniCredit.setBic(TEST_BIC_DE);
    Assume.assumeNotNull(uniCredit);
    Assume.assumeNotNull(styx10Option);
    styx10Option.setOptions(Collections.singletonMap("required", true));
    uniCredit.getConfig().setImplementerOptions(Collections.singletonMap("STYX10", styx10Option));
    IOParser ioParser = new IOParser(uniCredit);
    STYX10 styx10 = new STYX10(ioParser);
    Assertions.assertEquals(IOOrder.POST_CREATION, styx10.order());
    Assertions.assertFalse(styx10.apply(null, null, null));
    XS2ARequest xs2ARequest = new XS2ARequest() {

        @Override
        public Optional<String> getRawBody() {
            return Optional.empty();
        }

        @Override
        public BasicService.RequestType getHttpMethod() {
            return BasicService.RequestType.GET;
        }

        @Override
        public String getServicePath() {
            return "";
        }
    };
    PSU psu = new PSU("bgdemo");
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setPsu(psu);
    Assertions.assertTrue(styx10.apply(xs2AFactoryInput, xs2ARequest, null));
    Assertions.assertNotNull(xs2ARequest.getHeaders().get(XS2AHeader.PSU_ID_TYPE));
    Assertions.assertEquals("HVB_ONLINEBANKING", xs2ARequest.getHeaders().get(XS2AHeader.PSU_ID_TYPE));
}
Also used : BasicService(net.petafuel.styx.core.xs2a.contracts.BasicService) PSU(net.petafuel.styx.core.xs2a.entities.PSU) IOParser(net.petafuel.styx.core.ioprocessing.IOParser) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) XS2ARequest(net.petafuel.styx.core.xs2a.contracts.XS2ARequest) Test(org.junit.jupiter.api.Test)

Example 5 with XS2ARequest

use of net.petafuel.styx.core.xs2a.contracts.XS2ARequest in project styx by petafuel.

the class STYX08UnitTest method test_STYX08.

@Test
void test_STYX08() throws ImplementerOptionException {
    Assume.assumeNotNull(uniCredit);
    Assume.assumeNotNull(styx08Option);
    styx08Option.setOptions(Collections.singletonMap("required", true));
    uniCredit.getConfig().setImplementerOptions(Collections.singletonMap("STYX08", styx08Option));
    IOParser ioParser = new IOParser(uniCredit);
    STYX08 styx08 = new STYX08(ioParser);
    Assertions.assertEquals(IOOrder.POST_CREATION, styx08.order());
    Assertions.assertFalse(styx08.apply(null, null, null));
    XS2ARequest xs2ARequest = new XS2ARequest() {

        @Override
        public Optional<String> getRawBody() {
            return Optional.empty();
        }

        @Override
        public BasicService.RequestType getHttpMethod() {
            return BasicService.RequestType.GET;
        }

        @Override
        public String getServicePath() {
            return "";
        }
    };
    PSU psu = new PSU("bgdemo");
    psu.setIp("1.2.3.4");
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setPsu(psu);
    Assertions.assertTrue(styx08.apply(xs2AFactoryInput, xs2ARequest, null));
    Assertions.assertNotNull(xs2ARequest.getHeaders().get(XS2AHeader.PSU_IP_ADDRESS));
    Assertions.assertEquals("1.2.3.4", xs2ARequest.getHeaders().get(XS2AHeader.PSU_IP_ADDRESS));
}
Also used : BasicService(net.petafuel.styx.core.xs2a.contracts.BasicService) PSU(net.petafuel.styx.core.xs2a.entities.PSU) IOParser(net.petafuel.styx.core.ioprocessing.IOParser) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) XS2ARequest(net.petafuel.styx.core.xs2a.contracts.XS2ARequest) Test(org.junit.jupiter.api.Test)

Aggregations

XS2ARequest (net.petafuel.styx.core.xs2a.contracts.XS2ARequest)10 IOParser (net.petafuel.styx.core.ioprocessing.IOParser)8 BasicService (net.petafuel.styx.core.xs2a.contracts.BasicService)8 Test (org.junit.jupiter.api.Test)8 XS2AFactoryInput (net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput)6 PSU (net.petafuel.styx.core.xs2a.entities.PSU)5 Optional (java.util.Optional)1 IntegrationTest (net.petafuel.styx.api.IntegrationTest)1 StyxRESTTest (net.petafuel.styx.api.StyxRESTTest)1 Aspsp (net.petafuel.styx.core.banklookup.sad.entities.Aspsp)1 Config (net.petafuel.styx.core.banklookup.sad.entities.Config)1 ImplementerOption (net.petafuel.styx.core.banklookup.sad.entities.ImplementerOption)1 XS2AResponse (net.petafuel.styx.core.xs2a.entities.XS2AResponse)1 Test (org.junit.Test)1 Category (org.junit.experimental.categories.Category)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1