From c56de1426ec8d0e8067c535511fde993d89c5a2f Mon Sep 17 00:00:00 2001 From: akila94 Date: Fri, 10 Jan 2025 15:19:51 +0530 Subject: [PATCH] Fix required tests --- .../automation/BasicAuthAutomationStep.java | 8 ++++++-- .../automation/BasicAuthRejectStep.java | 7 ++++++- .../BasicWithdrawalAutomationStep.java | 7 ++++++- .../ConfigurableBasicAuthAutomationStep.java | 6 +++++- .../ConfigurableBasicAuthRejectStep.java | 6 +++++- .../automation/DevPortalLoginStep.java | 16 ++++++++++++--- .../model/ApplicationAccessTokenDto.java | 20 ------------------- .../request/AccessToken.java | 8 +------- .../util/ConfigParser.java | 4 ++++ .../util/TestConstants.java | 4 +++- .../common/utils/BerlinRequestBuilder.groovy | 6 +----- .../AccountsExplicitAuthorisation.groovy | 2 +- ...tiationRequestHeaderValidationTests.groovy | 6 ++---- 13 files changed, 53 insertions(+), 47 deletions(-) diff --git a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/BasicAuthAutomationStep.java b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/BasicAuthAutomationStep.java index cfe1e130..8c5c2320 100644 --- a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/BasicAuthAutomationStep.java +++ b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/BasicAuthAutomationStep.java @@ -53,8 +53,12 @@ public void execute(RemoteWebDriver webDriver, BrowserAutomation.AutomationConte webDriver.navigate().to(authorizeUrl); WebElement username; - //Enter Username - username = webDriver.findElement(By.id(TestConstants.USERNAME_FIELD_ID)); + //Enter User Name + if (TestConstants.APIM_VERSION_420.equals(com.wso2.openbanking.test.framework.util.ConfigParser.getInstance().getAPIMVersion())) { + username = webDriver.findElement(By.id(TestConstants.USERNAME_FIELD_ID_420)); + } else { + username = webDriver.findElement(By.id(TestConstants.USERNAME_FIELD_ID)); + } username.clear(); username.sendKeys(PsuConfigReader.getPSU()); diff --git a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/BasicAuthRejectStep.java b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/BasicAuthRejectStep.java index fd664436..3a4902fe 100644 --- a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/BasicAuthRejectStep.java +++ b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/BasicAuthRejectStep.java @@ -56,7 +56,12 @@ public void execute(RemoteWebDriver webDriver, BrowserAutomation.AutomationConte WebElement username; WebDriverWait wait = new WebDriverWait(webDriver, 30); - username = webDriver.findElement(By.id(TestConstants.USERNAME_FIELD_ID)); + if (TestConstants.APIM_VERSION_420.equals(com.wso2.openbanking.test.framework.util.ConfigParser.getInstance() + .getAPIMVersion())) { + username = webDriver.findElement(By.id(TestConstants.USERNAME_FIELD_ID_420)); + } else { + username = webDriver.findElement(By.id(TestConstants.USERNAME_FIELD_ID)); + } username.clear(); username.sendKeys(PsuConfigReader.getPSU()); diff --git a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/BasicWithdrawalAutomationStep.java b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/BasicWithdrawalAutomationStep.java index ba3b0d09..9eadb425 100644 --- a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/BasicWithdrawalAutomationStep.java +++ b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/BasicWithdrawalAutomationStep.java @@ -50,7 +50,12 @@ public void execute(RemoteWebDriver webDriver, BrowserAutomation.AutomationConte webDriver.navigate().to(consentWithdrawalUrl); WebElement username; - username = webDriver.findElement(By.id(TestConstants.USERNAME_FIELD_ID)); + if (TestConstants.APIM_VERSION_420.equals(com.wso2.openbanking.test.framework.util.ConfigParser.getInstance() + .getAPIMVersion())) { + username = webDriver.findElement(By.id(TestConstants.USERNAME_FIELD_ID_420)); + } else { + username = webDriver.findElement(By.id(TestConstants.USERNAME_FIELD_ID)); + } username.clear(); username.sendKeys(PsuConfigReader.getPSU()); diff --git a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/ConfigurableBasicAuthAutomationStep.java b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/ConfigurableBasicAuthAutomationStep.java index 99cc1ed5..cb123c91 100644 --- a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/ConfigurableBasicAuthAutomationStep.java +++ b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/ConfigurableBasicAuthAutomationStep.java @@ -52,7 +52,11 @@ public void execute(RemoteWebDriver webDriver, BrowserAutomation.AutomationConte webDriver.navigate().to(authorizeUrl); WebElement username; - username = webDriver.findElement(By.id(TestConstants.USERNAME_FIELD_ID)); + if (TestConstants.APIM_VERSION_420.equals(com.wso2.openbanking.test.framework.util.ConfigParser.getInstance().getAPIMVersion())) { + username = webDriver.findElement(By.id(TestConstants.USERNAME_FIELD_ID_420)); + } else { + username = webDriver.findElement(By.id(TestConstants.USERNAME_FIELD_ID)); + } username.clear(); username.sendKeys(userName); diff --git a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/ConfigurableBasicAuthRejectStep.java b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/ConfigurableBasicAuthRejectStep.java index 4fd46484..a07af3af 100644 --- a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/ConfigurableBasicAuthRejectStep.java +++ b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/ConfigurableBasicAuthRejectStep.java @@ -59,7 +59,11 @@ public void execute(RemoteWebDriver webDriver, BrowserAutomation.AutomationConte WebElement username; WebDriverWait wait = new WebDriverWait(webDriver, 30); - username = webDriver.findElement(By.id(TestConstants.USERNAME_FIELD_ID)); + if (TestConstants.APIM_VERSION_420.equals(com.wso2.openbanking.test.framework.util.ConfigParser.getInstance().getAPIMVersion())) { + username = webDriver.findElement(By.id(TestConstants.USERNAME_FIELD_ID_420)); + } else { + username = webDriver.findElement(By.id(TestConstants.USERNAME_FIELD_ID)); + } username.clear(); username.sendKeys(userName); diff --git a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/DevPortalLoginStep.java b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/DevPortalLoginStep.java index 1b40fdd6..f98cfe80 100644 --- a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/DevPortalLoginStep.java +++ b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/automation/DevPortalLoginStep.java @@ -51,7 +51,11 @@ public void execute(RemoteWebDriver webDriver, BrowserAutomation.AutomationConte WebElement username; //Enter User Name - username = webDriver.findElement(By.id(TestConstants.APIM_USERNAME)); + if (TestConstants.APIM_VERSION_420.equals(ConfigParser.getInstance().getAPIMVersion())) { + username = webDriver.findElement(By.id(TestConstants.USERNAME_FIELD_ID_420)); + } else { + username = webDriver.findElement(By.id(TestConstants.USERNAME_FIELD_ID)); + } username.clear(); username.sendKeys(ConfigParser.getInstance().getTppUserName()); @@ -63,7 +67,13 @@ public void execute(RemoteWebDriver webDriver, BrowserAutomation.AutomationConte webDriver.findElement(By.xpath(TestConstants.BTN_APIM_CONTINUE)).submit(); WebDriverWait wait = new WebDriverWait(webDriver, 30); - wait.until(ExpectedConditions.invisibilityOfElementLocated( - By.id(TestConstants.APIM_USERNAME))); + + if (TestConstants.APIM_VERSION_420.equals(ConfigParser.getInstance().getAPIMVersion())) { + wait.until(ExpectedConditions.invisibilityOfElementLocated( + By.id(TestConstants.USERNAME_FIELD_ID_420))); + } else { + wait.until(ExpectedConditions.invisibilityOfElementLocated( + By.id(TestConstants.USERNAME_FIELD_ID))); + } } } diff --git a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/model/ApplicationAccessTokenDto.java b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/model/ApplicationAccessTokenDto.java index 6336c1c9..05b47cc1 100644 --- a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/model/ApplicationAccessTokenDto.java +++ b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/model/ApplicationAccessTokenDto.java @@ -158,31 +158,11 @@ public String getPayload(String clientId) throws TestFrameworkException { setScopes(TestConstants.ACCOUNTS_DEFAULT_SCOPES); } - if (clientAssertionType == null) { - setClientAssertionType(TestConstants.CLIENT_ASSERTION_TYPE); - } - - if (clientAssertion == null) { - if (accessTokenJwtDto == null) { - setAccessTokenJwtDto(new AccessTokenJwtDto()); - } - if (clientId == null) { - setClientAssertion(accessTokenJwtDto.getJwt()); - } else { - //use jwk thumbprint - setClientAssertion(accessTokenJwtDto.getJwt(clientId)); - } - } - String payload = ""; String delimiter = "&"; return payload.concat(TestConstants.GRANT_TYPE_KEY + "=" + getGrantType() + delimiter) .concat(TestConstants.SCOPE_KEY + "=" + TestUtil.getParamListAsString(getScopes(), ' ') + delimiter) - .concat(TestConstants.CLIENT_ASSERTION_TYPE_KEY + "=" - + getClientAssertionType() + delimiter) - .concat(TestConstants.CLIENT_ASSERTION_KEY + "=" + getClientAssertion() + delimiter) - .concat(TestConstants.REDIRECT_URI_KEY + "=" + getRedirectUri() + delimiter) .concat(TestConstants.CLIENT_ID + "=" + clientId); } diff --git a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/request/AccessToken.java b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/request/AccessToken.java index 6e3caf0a..eb997d83 100644 --- a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/request/AccessToken.java +++ b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/request/AccessToken.java @@ -64,13 +64,7 @@ public static Response getApplicationAccessToken( ApplicationAccessTokenDto applicationAccessTokenDto, String clientId) throws TestFrameworkException { - String payload; - - if (clientId == null) { - payload = applicationAccessTokenDto.getPayload(); - } else { - payload = applicationAccessTokenDto.getPayload(clientId); - } + String payload = applicationAccessTokenDto.getPayload(clientId); return TestSuite.buildRequest().contentType(TestConstants.ACCESS_TOKEN_CONTENT_TYPE) .body(payload) .baseUri(ConfigParser.getInstance().getAuthorisationServerURL()) diff --git a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/util/ConfigParser.java b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/util/ConfigParser.java index 0e55ec91..c6f03c74 100644 --- a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/util/ConfigParser.java +++ b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/util/ConfigParser.java @@ -397,6 +397,10 @@ public String getSolutionVersion() { return String.valueOf(ConfigParser.getInstance().getConfiguration().get("SolutionVersion")); } + public String getAPIMVersion() { + return String.valueOf(ConfigParser.getInstance().getConfiguration().get("APIMVersion")); + } + public String getOBSpec() { return String.valueOf(ConfigParser.getInstance().getConfiguration().get("OBSpec")); } diff --git a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/util/TestConstants.java b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/util/TestConstants.java index a5585233..4b76ff06 100644 --- a/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/util/TestConstants.java +++ b/open-banking-test-suite/open-banking-test-framework/src/main/java/com.wso2.openbanking.test.framework/util/TestConstants.java @@ -24,6 +24,7 @@ public class TestConstants { public static final String SOLUTION_VERSION_130 = "1.3.0"; public static final String SOLUTION_VERSION_140 = "1.4.0"; public static final String SOLUTION_VERSION_150 = "1.5.0"; + public static final String APIM_VERSION_420 = "4.2.0"; public static final String CLIENT_CREDENTIALS = "client_credentials"; public static final String AUTH_CODE = "authorization_code"; @@ -116,7 +117,8 @@ public class TestConstants { public static final String PASSWORD = "password"; //Selenium constants - public static final String USERNAME_FIELD_ID = "username"; + public static final String USERNAME_FIELD_ID = "usernameUserInput"; + public static final String USERNAME_FIELD_ID_420 = "username"; public static final String PASSWORD_FIELD_ID = "password"; public static final String HEADLESS_TAG = "--headless"; public static final String ACCOUNT_SELECT_DROPDOWN_XPATH = "//*[@id=\"accselect\"]"; diff --git a/open-banking-test-suite/toolkit-berlin-test/com.wso2.openbanking.toolkit.berlin.test/berlin.common.utils/src/main/groovy/com/wso2/openbanking/berlin/common/utils/BerlinRequestBuilder.groovy b/open-banking-test-suite/toolkit-berlin-test/com.wso2.openbanking.toolkit.berlin.test/berlin.common.utils/src/main/groovy/com/wso2/openbanking/berlin/common/utils/BerlinRequestBuilder.groovy index 8b1aaef3..fc451e63 100644 --- a/open-banking-test-suite/toolkit-berlin-test/com.wso2.openbanking.toolkit.berlin.test/berlin.common.utils/src/main/groovy/com/wso2/openbanking/berlin/common/utils/BerlinRequestBuilder.groovy +++ b/open-banking-test-suite/toolkit-berlin-test/com.wso2.openbanking.toolkit.berlin.test/berlin.common.utils/src/main/groovy/com/wso2/openbanking/berlin/common/utils/BerlinRequestBuilder.groovy @@ -116,13 +116,9 @@ class BerlinRequestBuilder { ClientID clientID = new ClientID(AppConfigReader.getClientId()) - String assertionString = new AccessTokenJwtDto().getJwt() - - ClientAuthentication clientAuth = new PrivateKeyJWT(SignedJWT.parse(assertionString)) - URI tokenEndpoint = new URI("${config.getAuthorisationServerURL()}/oauth2/token") - TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, codeGrant) + TokenRequest request = new TokenRequest(tokenEndpoint, clientID, codeGrant); HTTPRequest httpRequest = request.toHTTPRequest() diff --git a/open-banking-test-suite/toolkit-berlin-test/com.wso2.openbanking.toolkit.berlin.test/integration.tests/accounts/src/test/groovy/com.wso2.openbanking.toolkit.berlin.integration.test.accounts/common_test/Accounts_Authorization_Tests/AccountsExplicitAuthorisation.groovy b/open-banking-test-suite/toolkit-berlin-test/com.wso2.openbanking.toolkit.berlin.test/integration.tests/accounts/src/test/groovy/com.wso2.openbanking.toolkit.berlin.integration.test.accounts/common_test/Accounts_Authorization_Tests/AccountsExplicitAuthorisation.groovy index 05ed747b..0709d7cf 100644 --- a/open-banking-test-suite/toolkit-berlin-test/com.wso2.openbanking.toolkit.berlin.test/integration.tests/accounts/src/test/groovy/com.wso2.openbanking.toolkit.berlin.integration.test.accounts/common_test/Accounts_Authorization_Tests/AccountsExplicitAuthorisation.groovy +++ b/open-banking-test-suite/toolkit-berlin-test/com.wso2.openbanking.toolkit.berlin.test/integration.tests/accounts/src/test/groovy/com.wso2.openbanking.toolkit.berlin.integration.test.accounts/common_test/Accounts_Authorization_Tests/AccountsExplicitAuthorisation.groovy @@ -84,7 +84,7 @@ class AccountsExplicitAuthorisation extends AbstractAccountsFlow{ //Check the Authorisation status getAuthorizationStatus(consentPath) String scaStatus = authorisationResponse.jsonPath().get(BerlinConstants.SCA_STATUS_PARAM) - Assert.assertEquals(scaStatus, AccountsConstants.CONSENT_STATUS_PSUAUTHENTICATED) + Assert.assertEquals(scaStatus, AccountsConstants.SCA_STATUS_FINALISED) } @Test(groups = ["SmokeTest", "1.3.6"], dependsOnMethods = ["Authenticate PSU on SCA Flow"]) diff --git a/open-banking-test-suite/toolkit-berlin-test/com.wso2.openbanking.toolkit.berlin.test/integration.tests/payments/src/test/groovy/com/wso2/openbanking/toolkit/berlin/integration/test/payments/common_test/Payments_Initiation_Tests/InitiationRequestHeaderValidationTests.groovy b/open-banking-test-suite/toolkit-berlin-test/com.wso2.openbanking.toolkit.berlin.test/integration.tests/payments/src/test/groovy/com/wso2/openbanking/toolkit/berlin/integration/test/payments/common_test/Payments_Initiation_Tests/InitiationRequestHeaderValidationTests.groovy index baa4abfc..624efdeb 100644 --- a/open-banking-test-suite/toolkit-berlin-test/com.wso2.openbanking.toolkit.berlin.test/integration.tests/payments/src/test/groovy/com/wso2/openbanking/toolkit/berlin/integration/test/payments/common_test/Payments_Initiation_Tests/InitiationRequestHeaderValidationTests.groovy +++ b/open-banking-test-suite/toolkit-berlin-test/com.wso2.openbanking.toolkit.berlin.test/integration.tests/payments/src/test/groovy/com/wso2/openbanking/toolkit/berlin/integration/test/payments/common_test/Payments_Initiation_Tests/InitiationRequestHeaderValidationTests.groovy @@ -260,8 +260,7 @@ class InitiationRequestHeaderValidationTests extends AbstractPaymentsFlow{ } } - //todo: fix https://github.com/wso2-enterprise/financial-open-banking/issues/7561 -// @Test (groups = ["1.3.3", "1.3.6"], dataProvider = "PaymentsTypes", dataProviderClass = PaymentsDataProviders.class) + @Test (groups = ["1.3.3", "1.3.6"], dataProvider = "PaymentsTypes", dataProviderClass = PaymentsDataProviders.class) void "TC0301014_Initiation Request without Authorization Header"(String consentPath, List paymentProducts, String payload) { @@ -287,8 +286,7 @@ class InitiationRequestHeaderValidationTests extends AbstractPaymentsFlow{ } } - //todo: fix https://github.com/wso2-enterprise/financial-open-banking/issues/7561 -// @Test (groups = ["1.3.3", "1.3.6"], dataProvider = "PaymentsTypes", dataProviderClass = PaymentsDataProviders.class) + @Test (groups = ["1.3.3", "1.3.6"], dataProvider = "PaymentsTypes", dataProviderClass = PaymentsDataProviders.class) void "TC0301015_Initiation Request with invalid Authorization Header"(String consentPath, List paymentProducts, String payload) {