Skip to content

Commit

Permalink
Fix required tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Akila94 committed Jan 10, 2025
1 parent cb873f7 commit c56de14
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -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)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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\"]";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> paymentProducts,
String payload) {

Expand All @@ -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<String> paymentProducts,
String payload) {

Expand Down

0 comments on commit c56de14

Please sign in to comment.