use of net.petafuel.styx.core.banklookup.sad.entities.Aspsp in project styx by petafuel.
the class SADTest method testXS2AStandardInitialisationProduction.
@ParameterizedTest
@MethodSource("BICProvider")
@DisplayName("testXS2AStandardInitialisationProduction() -> Check if PRODUCTION XS2AStandards can be created for all available BICs in SAD")
public void testXS2AStandardInitialisationProduction(String bic) throws BankNotFoundException, BankLookupFailedException {
SAD sad = new SAD();
Aspsp bank = PersistentSAD.getByBIC(bic);
XS2AStandard xs2AStandard = sad.getBankByBIC(bic);
try {
Assertions.assertAll(() -> {
if (bank.getProductionUrl().getCommonUrl() == null) {
if (bank.getProductionUrl().getAisUrl() != null) {
Assert.assertTrue("AIS Url was specified but no Consent Service was initialized", xs2AStandard.isCSImplemented());
Assert.assertTrue("AIS Url was specified but no related Service was initialized", xs2AStandard.isAISImplemented());
}
if (bank.getProductionUrl().getPisUrl() != null) {
Assert.assertTrue("PIS Url was specified but no related Service was initialized", xs2AStandard.isPISImplemented());
}
if (bank.getProductionUrl().getPiisUrl() != null) {
Assert.assertTrue("PIIS Url was specified but no related Service was initialized", xs2AStandard.isPIISImplemented());
}
} else {
boolean atLeastOneServiceImplemented = false;
if ((xs2AStandard.isAISImplemented() && xs2AStandard.isCSImplemented()) || xs2AStandard.isPIISImplemented() || xs2AStandard.isPISImplemented()) {
atLeastOneServiceImplemented = true;
}
Assert.assertTrue("General Url was specified but no related Service was initialized", atLeastOneServiceImplemented);
}
});
} catch (MultipleFailuresError e) {
if (!bank.isActive()) {
System.err.println("Test failed for bic=" + bic + " but bank is deactivated in styx: ");
e.getFailures().forEach(throwable -> System.err.println(throwable.getMessage()));
Assert.assertTrue(true);
} else {
System.err.println("Test failed for bic=" + bic + ": " + e.getMessage());
e.getFailures().forEach(throwable -> System.err.println(throwable.getMessage()));
Assert.fail();
}
}
}
use of net.petafuel.styx.core.banklookup.sad.entities.Aspsp in project styx by petafuel.
the class SADTest method testPersistentSAD.
@ParameterizedTest
@MethodSource("BICProvider")
public void testPersistentSAD(String bic) throws SQLException {
Aspsp bank = PersistentSAD.getByBIC(bic);
Assert.assertNotNull(bank);
Assert.assertEquals(bic, bank.getBic());
Assert.assertNotNull(bank.getAspspGroup());
Assert.assertNotNull(bank.getConfig());
Connection connection = Persistence.getInstance().getConnection();
ResultSet resultSet;
int sandboxUrlsId = bank.getSandboxUrl().getId();
try (PreparedStatement preparedStatement = connection.prepareStatement("SELECT * from urls WHERE id = ?")) {
preparedStatement.setInt(1, sandboxUrlsId);
resultSet = preparedStatement.executeQuery();
resultSet.next();
Assert.assertNotNull(bank.getSandboxUrl());
if (bank.getSandboxUrl().getCommonUrl() == null) {
Assert.assertNotNull(bank.getSandboxUrl().getAisUrl());
Assert.assertEquals(resultSet.getString("ais_url"), bank.getSandboxUrl().getAisUrl());
Assert.assertNotNull(bank.getSandboxUrl().getPisUrl());
Assert.assertEquals(resultSet.getString("pis_url"), bank.getSandboxUrl().getPisUrl());
Assert.assertNotNull(bank.getSandboxUrl().getPiisUrl());
Assert.assertEquals(resultSet.getString("piis_url"), bank.getSandboxUrl().getPiisUrl());
} else {
Assert.assertNotNull(bank.getSandboxUrl().getCommonUrl());
Assert.assertEquals(resultSet.getString("url"), bank.getSandboxUrl().getCommonUrl());
}
}
int productionUrlsId = bank.getProductionUrl().getId();
try (PreparedStatement preparedStatement = connection.prepareStatement("SELECT * from urls WHERE id = ?")) {
preparedStatement.setInt(1, productionUrlsId);
resultSet = preparedStatement.executeQuery();
resultSet.next();
Assert.assertNotNull(bank.getProductionUrl());
if (bank.getProductionUrl().getCommonUrl() == null) {
Assert.assertNotNull(bank.getProductionUrl().getAisUrl());
Assert.assertEquals(resultSet.getString("ais_url"), bank.getProductionUrl().getAisUrl());
Assert.assertNotNull(bank.getProductionUrl().getPisUrl());
Assert.assertEquals(resultSet.getString("pis_url"), bank.getProductionUrl().getPisUrl());
Assert.assertNotNull(bank.getProductionUrl().getPiisUrl());
Assert.assertEquals(resultSet.getString("piis_url"), bank.getProductionUrl().getPiisUrl());
} else {
Assert.assertNotNull(bank.getProductionUrl().getCommonUrl());
Assert.assertEquals(resultSet.getString("url"), bank.getProductionUrl().getCommonUrl());
}
}
}
use of net.petafuel.styx.core.banklookup.sad.entities.Aspsp in project styx by petafuel.
the class STYX05 method apply.
@Override
public boolean apply(XS2AFactoryInput xs2AFactoryInput, XS2ARequest xs2ARequest, XS2AResponse xs2AResponse) throws ImplementerOptionException {
if (xs2AResponse instanceof StrongAuthenticatableResource) {
Boolean optionRequired = ioParser.getOption(IO, IOParser.Option.REQUIRED);
if (optionRequired != null && optionRequired) {
StrongAuthenticatableResource response = (StrongAuthenticatableResource) xs2AResponse;
String authorizationLink = response.getLinks().getScaRedirect().getUrl();
OAuthSession oAuthSession = OAuthSession.start(response.getxRequestId());
oAuthSession.setScope(SCAHandler.getQueryParameterValue(authorizationLink, "scope"));
oAuthSession.setAuthorizationEndpoint(getBaseUrl(authorizationLink));
boolean isSandbox = WebServer.isSandbox();
Aspsp aspsp = ioParser.getAspsp();
if (isSandbox) {
oAuthSession.setTokenEndpoint(aspsp.getSandboxUrl().getPreauthTokenEndpoint());
} else {
oAuthSession.setTokenEndpoint(aspsp.getProductionUrl().getPreauthTokenEndpoint());
}
PersistentOAuthSession.create(oAuthSession);
String generatedCodeChallenge = OAuthService.getCodeChallengeFromState(oAuthSession.getState());
String codeChallengePlaceholder = SCAHandler.getQueryParameterValue(authorizationLink, "code_challenge");
authorizationLink = authorizationLink.replace(codeChallengePlaceholder, generatedCodeChallenge) + "&state=" + oAuthSession.getState();
response.getLinks().setScaRedirect(new Links.Href(authorizationLink, LinkType.SCA_REDIRECT));
return true;
}
}
return false;
}
use of net.petafuel.styx.core.banklookup.sad.entities.Aspsp in project styx by petafuel.
the class SADResourceTest method GetAspspDataSuccessTest.
@Test
@Category(IntegrationTest.class)
public void GetAspspDataSuccessTest() throws BankLookupFailedException, BankNotFoundException {
Aspsp aspsp = getAspspByBic(BIC);
Map<String, ImplementerOption> implementerOptions = aspsp.getConfig().getImplementerOptions();
Invocation.Builder invocationBuilder = target("/v1/aspsp/" + BIC).request();
invocationBuilder.header("token", pisAccessToken);
invocationBuilder.header("Content-Type", "application/json");
Invocation invocation = invocationBuilder.buildGet();
Response response = invocation.invoke(Response.class);
Assertions.assertEquals(200, response.getStatus());
JsonObject jsonResponse = response.readEntity(JsonObject.class);
JsonObject jsonScaApproaches = (JsonObject) jsonResponse.get("scaApproaches");
JsonObject jsonSupportedServices = (JsonObject) jsonResponse.get("supportedServices");
JsonObject jsonSupportedServicesAis = (JsonObject) jsonSupportedServices.get("ais");
JsonObject jsonSupportedServicesCof = (JsonObject) jsonSupportedServices.get("cof");
JsonObject jsonSupportedServicesPis = (JsonObject) jsonSupportedServices.get("pis");
Assertions.assertEquals(aspsp.isActive(), jsonResponse.getBoolean("active"));
Assertions.assertEquals(aspsp.getName(), jsonResponse.getString("name"));
Assertions.assertFalse(jsonResponse.getBoolean("multicurrencyAccountsSupported"));
Assertions.assertFalse(jsonResponse.getBoolean("prestepRequired"));
Assertions.assertTrue(jsonResponse.containsKey("scaApproaches"));
Assertions.assertEquals(implementerOptions.get("IO5").getOptions().get("decoupled"), jsonScaApproaches.getBoolean("decoupled"));
Assertions.assertEquals(implementerOptions.get("IO5").getOptions().get("embedded"), jsonScaApproaches.getBoolean("embedded"));
Assertions.assertEquals(implementerOptions.get("IO5").getOptions().get("oauth"), jsonScaApproaches.getBoolean("oAuth"));
Assertions.assertEquals(implementerOptions.get("IO5").getOptions().get("redirect"), jsonScaApproaches.getBoolean("redirect"));
Assertions.assertTrue(jsonResponse.containsKey("supportedServices"));
Assertions.assertTrue(jsonSupportedServices.containsKey("ais"));
Assertions.assertTrue(jsonSupportedServicesAis.getBoolean("accountDetails"));
Assertions.assertTrue(jsonSupportedServicesAis.getBoolean("accountList"));
Assertions.assertFalse(jsonSupportedServicesAis.getBoolean("accountsAccountIdTransactionsResourceId"));
Assertions.assertFalse(jsonSupportedServicesAis.getBoolean("accountsAccountIdTransactionsWithBalance"));
Assertions.assertFalse(jsonSupportedServicesAis.getBoolean("accountsAccountIdWithBalance"));
Assertions.assertFalse(jsonSupportedServicesAis.getBoolean("accountsWithBalance"));
Assertions.assertTrue(jsonSupportedServices.containsKey("cof"));
Assertions.assertTrue(jsonSupportedServicesCof.containsKey("fundsConfirmation"));
Assertions.assertTrue(jsonSupportedServices.containsKey("pis"));
Assertions.assertTrue(jsonSupportedServicesPis.getBoolean("bulkPayments"));
Assertions.assertTrue(jsonSupportedServicesPis.getBoolean("futureDatedPayments"));
Assertions.assertTrue(jsonSupportedServicesPis.getBoolean("periodicPayments"));
Assertions.assertTrue(jsonSupportedServicesPis.getBoolean("singlePayments"));
Response response2 = invocation.invoke(Response.class);
Assertions.assertEquals(200, response2.getStatus());
}
use of net.petafuel.styx.core.banklookup.sad.entities.Aspsp in project styx by petafuel.
the class STYX09IntegrationTest method configure.
@Override
protected Application configure() {
styx09Option = new ImplementerOption();
styx09Option.setId("STYX09");
ing = new Aspsp();
ing.setConfig(new Config());
ing.setBic(TEST_BIC);
Url url = new Url();
url.setCommonUrl("https://api.sandbox.ing.com");
ing.setSandboxUrl(url);
ResourceConfig config = setupFiltersAndErrorHandlers();
if (pisAccessToken == null || Objects.equals(pisAccessToken, "")) {
Assertions.fail("test.token.access.pis not set in test properties");
}
return config.register(AuthenticationResource.class).register(PaymentInitiationResource.class);
}
Aggregations