Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 62 additions & 3 deletions ui-test/src/main/java/base/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
import java.time.Duration;
import java.util.Base64;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.json.JSONObject;
import org.openqa.selenium.JavascriptExecutor;
Expand Down Expand Up @@ -79,6 +83,37 @@ public static void beforeAll() {
}
}

private static final Map<String, String[]> CLIENT_CONFIG_MAP = new HashMap<>();

static {
CLIENT_CONFIG_MAP.put("@PurposeLogin",
new String[] { "$ID:CreateOIDCClient_with_purpose_type_login_Smoke_sid_clientId$",
"$CLIENT_ASSERTION_PAR_JWT_PURPOSE_LOGIN$" });

CLIENT_CONFIG_MAP.put("@PurposeLink",
new String[] { "$ID:CreateOIDCClient_with_purpose_type_link_Smoke_sid_clientId$",
"$CLIENT_ASSERTION_PAR_JWT_PURPOSE_LINK$" });

CLIENT_CONFIG_MAP.put("@PurposeNone",
new String[] { "$ID:CreateOIDCClient_with_purpose_type_none_Smoke_sid_clientId$",
"$CLIENT_ASSERTION_PAR_JWT_PURPOSE_NONE$" });

CLIENT_CONFIG_MAP.put("@NoPurpose", new String[] { "$ID:CreateOIDCClient_with_no_purpose_Smoke_sid_clientId$",
"$CLIENT_ASSERTION_PAR_JWT_NO_PURPOSE$" });

CLIENT_CONFIG_MAP.put("@NoTitleAndSubTitle",
new String[] { "$ID:CreateOIDCClient_with_purpose_title_and_subtitle_null_Smoke_sid_clientId$",
"$CLIENT_ASSERTION_PAR_JWT_NO_TITLE$" });

CLIENT_CONFIG_MAP.put("@EmptyTitleAndSubTitle",
new String[] { "$ID:CreateOIDCClient_with_purpose_title_and_subtitle_empty_Smoke_sid_clientId$",
"$CLIENT_ASSERTION_PAR_JWT_EMPTY_TITLE$" });

CLIENT_CONFIG_MAP.put("@SingleAuthFactor",
new String[] { "$ID:CreateOIDCClient_with_single_auth_factor_Smoke_sid_clientId$",
"$CLIENT_ASSERTION_PAR_JWT_SINGLE_ACR_VALUE$" });
}

@Before(order = 2)
public void beforeAll(Scenario scenario) {
if (isMobileMode.get() == null) {
Expand All @@ -97,6 +132,18 @@ public void beforeAll(Scenario scenario) {
}
isKnownIssueScenario.set(false);

String pluginName = EsignetUtil.getPluginName();

if ("mosipid".equalsIgnoreCase(pluginName)) {
Set<String> skipTags = new HashSet<>(CLIENT_CONFIG_MAP.keySet());

for (String tag : scenario.getSourceTagNames()) {
if (skipTags.contains(tag)) {
throw new SkipException("Skipped for mosipid");
}
}
}

totalCount++;
String browser = BaseTestUtil.getBrowserForScenario(scenario); // Start logging for the scenario
String lang = BaseTestUtil.getThreadLocalLanguage();
Expand Down Expand Up @@ -129,11 +176,23 @@ public void beforeAll(Scenario scenario) {
String baseUrl = EsignetConfigManager.getproperty("eSignetbaseurl");
String template = EsignetConfigManager.getproperty("authorizeUrlTemplate");

String requestUri = EsignetUtil.generateParRequestUri();
String clientIdKey = "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$";
String clientAssertion = "$CLIENT_ASSERTION_PAR_JWT$";

for (String tag : scenario.getSourceTagNames()) {
if (CLIENT_CONFIG_MAP.containsKey(tag)) {
String[] values = CLIENT_CONFIG_MAP.get(tag);
clientIdKey = values[0];
clientAssertion = values[1];
break;
}
}

String requestUri = EsignetUtil.generateParRequestUri(clientIdKey, clientAssertion);

String updatedTemplate = template.replace("$REQUEST_URI$", requestUri);
String clientId = AdminTestUtil.replaceIdWithAutogeneratedId(clientIdKey, "$ID:");

updatedTemplate = AdminTestUtil.replaceIdWithAutogeneratedId(updatedTemplate, "$ID:");
String updatedTemplate = template.replace("$REQUEST_URI$", requestUri).replace("$CLIENT_ID$", clientId);

String authorizeUrl = baseUrl + updatedTemplate;

Expand Down
39 changes: 39 additions & 0 deletions ui-test/src/main/java/pages/ConsentPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ public ConsentPage(WebDriver driver) {
@FindBy(xpath = "//p[@class='text-[#4E4E4E] font-semibold']")
WebElement actionMessage;

@FindBy(id = "login-header")
WebElement loginTitle;

@FindBy(id = "login-subheader")
WebElement loginSubTitle;

@FindBy(xpath = "//h1[@class='text-base leading-5 font-sans font-medium my-2']")
WebElement selectPreferredModeHeader;

@FindBy(xpath = "//div[@class='inline mx-2 font-semibold my-3']")
WebElement selectPreferredIdHeader;
@FindBy(xpath = "//div[@class='header my-2']")
WebElement headerInConsentUpdateProfileScreen;

Expand Down Expand Up @@ -377,6 +388,34 @@ public boolean isVerifyOtpButtonEnabled() {
return isButtonEnabled(verifyOtpButton, "Verified otp verification button is enabled");
}

public boolean isLoginWithOtpDisplayed(String expectedText) {
return isElementDisplayed(loginWithOtpButton) && loginWithOtpButton.getText().trim().startsWith(expectedText);
}

public boolean isLoginTitleDisplayed() {
return isElementDisplayed(loginTitle);
}

public boolean isLoginSubTitleDisplayed() {
return isElementDisplayed(loginSubTitle);
}

public String getLoginTitleText() {
return loginTitle.getText().trim();
}

public String getLoginSubTitleText() {
return loginSubTitle.getText().trim();
}

public String getSelectPreferredModeHeaderText() {
return selectPreferredModeHeader.getText().trim();
}

public String getSelectPreferredIdHeaderText() {
return selectPreferredIdHeader.getText().trim();
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

public boolean isHeaderInConsentUpdateProfileScreenVisible() {
return isElementVisible(headerInConsentUpdateProfileScreen, "Verified header in consent update profile screen");
}
Expand Down
1 change: 0 additions & 1 deletion ui-test/src/main/java/pages/VideoPreviewPage.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package pages;

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
Expand Down
118 changes: 112 additions & 6 deletions ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
import pages.LoginOptionsPage;
import pages.SignUpPage;
import pages.SignupFormDynamicFiller;
import utils.BaseTestUtil;
import utils.ClaimsUtil;
import utils.EsignetUtil;
import utils.EsignetUtil.RegisteredDetails;
import utils.ResourceBundleLoader;

public class ConsentStepDefinition {

Expand Down Expand Up @@ -352,17 +355,120 @@ public void verifyTheActionMessage() {
public void verifyTheTimerInConsentScreen() {
Assert.assertTrue(consentPage.isTimerDisplayed(), "The timer is not displayed in the consent screen");
}

@Then("verify the otp verification button is disabled on the verification screen")
public void verifyOtpVerificationButtonIsDisabled() {
Assert.assertFalse(consentPage.isVerifyOtpButtonEnabled(),
"Otp verification button is enabled");
Assert.assertFalse(consentPage.isVerifyOtpButtonEnabled(), "Otp verification button is enabled");
}

@Then("verify the otp verification button is enabled on the verification screen")
public void verifyOtpVerificationButtonIsEnabled() {
Assert.assertTrue(consentPage.isVerifyOtpButtonEnabled(),
"Otp verification button is not enabled");
Assert.assertTrue(consentPage.isVerifyOtpButtonEnabled(), "Otp verification button is not enabled");
}

@When("user creates the client with purpose type login")
public void userCreateClientIdPurposeLogin() {
// Purpose is already handled via scenario tags in BaseTest
}

@Then("all auth factors should start with login")
public void verifyLoginPurposeReflectedInUI() {
String expectedText = ResourceBundleLoader.getPrefixText("otp.login_with_id");
Assert.assertTrue(consentPage.isLoginWithOtpDisplayed(expectedText),
"Expected text not displayed: " + expectedText);
}

@When("user creates the client without purpose field")
public void userCreateClientIdWithoutPurpose() {
// Purpose is already handled via scenario tags in BaseTest
}

@When("user creates the client with purpose type link")
public void userCreateClientIdPurposeLink() {
// Purpose is already handled via scenario tags in BaseTest
}

@Then("all auth factors should start with link")
public void verifyLinkPurposeReflectedInUI() {
String expectedText = ResourceBundleLoader.getPrefixText("otp.link_using_id");
Assert.assertTrue(consentPage.isLoginWithOtpDisplayed(expectedText),
"Expected text not displayed: " + expectedText);
}

@When("user creates the client with purpose type verify")
public void userCreateClientIdPurposeVerify() {
// Purpose is already handled via scenario tags in BaseTest
}

@Then("all auth factors should start with verify")
public void validateVerifyPurposeReflectedInUI() {
String expectedText = ResourceBundleLoader.getPrefixText("otp.verify_with_id");
Assert.assertTrue(consentPage.isLoginWithOtpDisplayed(expectedText),
"Expected text not displayed: " + expectedText);
}

@When("user creates the client with purpose type none")
public void userCreateClientIdPurposeNone() {
// Purpose is already handled via scenario tags in BaseTest
}

@Then("verify no title or subtitle should be displayed")
public void verifyTitleNotDisplayed() {
Assert.assertFalse(consentPage.isLoginTitleDisplayed(), "Title is displayed");
Assert.assertFalse(consentPage.isLoginSubTitleDisplayed(), "Subtitle is displayed");
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

@Then("verify title and subtitle should be displayed as per text given during client creation")
public void verifyDefaultLoginTitleAndSubtitle() {
Assert.assertTrue(consentPage.getLoginTitleText().equals("Verify using eSignet"));
Assert.assertTrue(consentPage.getLoginSubTitleText().contains("is requesting authentication for verification"));
}
Comment thread
BhuvanaShreeBS marked this conversation as resolved.

@When("user creates the client with null title and subtitle values")
public void userCreateClientIdWithNullTitle() {
// Title is already handled via scenario tags in BaseTest
}

@When("user creates the client with empty title and subtitle values")
public void userCreateClientIdWithEmptyTitle() {
// Title is already handled via scenario tags in BaseTest
}
Comment thread
BhuvanaShreeBS marked this conversation as resolved.

@Then("verify select preferred mode text is displayed")
public void verifySelectPreferredModeText() {
String expectedText = ResourceBundleLoader.get("signInOption.preferred_mode_to_continue");
Assert.assertEquals(consentPage.getSelectPreferredModeHeaderText(), expectedText, "Expected text mismatch");
}

@Then("verify select preferred ID text based on purpose type when more than one auth factor is present")
public void verifySelectPreferredIdHeaderText() {
List<String> authFactors = ClaimsUtil.getAuthFactors();
Assert.assertFalse(authFactors.isEmpty(), "No auth factors were parsed from the authorize URL");

Assert.assertTrue(authFactors.size() > 1, "Expected multiple auth factors, got " + authFactors.size());
String expectedText = ResourceBundleLoader.get("otp.login_with_id_multiple");
Assert.assertEquals(consentPage.getSelectPreferredIdHeaderText(), expectedText, "Expected text mismatch");
}

@When("user creates the client with single auth factor")
public void userCreateClientIdWithSingleAuthFactor() {
// It is already handled via scenario tags in BaseTest
}

@Then("verify select ID type text based on purpose type when one auth factor is displayed")
public void verifySelectIdTypeHeaderText() {
List<String> authFactors = ClaimsUtil.getAuthFactors();
Assert.assertFalse(authFactors.isEmpty(), "No auth factors were parsed from the authorize URL");

Assert.assertTrue(authFactors.size() == 1, "Expected multiple auth factors, got " + authFactors.size());
String expectedText = ResourceBundleLoader.get("otp.login_with_id_multiple");
Assert.assertEquals(consentPage.getSelectPreferredIdHeaderText(), expectedText, "Expected text mismatch");
}
Comment thread
BhuvanaShreeBS marked this conversation as resolved.

@Then("verify select preferred ID text based on purpose type is displayed")
public void verifySelectPreferredIdHeaderTextDisplayed() {
String expectedText = ResourceBundleLoader.get("otp.login_with_id_multiple");
Assert.assertEquals(consentPage.getSelectPreferredIdHeaderText(), expectedText, "Expected text mismatch");
}

@Then("verify the header Attention in the consent to profile update screen")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ public void verifyPageDoesNotExistErrorDisplayed() {
public void userModifiesAuthorizeValue() throws Exception {
String baseUrl = EsignetConfigManager.getproperty("eSignetbaseurl");
String template = EsignetConfigManager.getproperty("authorizeUrlTemplate");
String requestUri = EsignetUtil.generateParRequestUri();
String requestUri = EsignetUtil.generateParRequestUri("$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$",
"$CLIENT_ASSERTION_PAR_JWT$");
String updatedTemplate = template.replace("$REQUEST_URI$", requestUri);
updatedTemplate = AdminTestUtil.replaceIdWithAutogeneratedId(updatedTemplate, "$ID:");
String url = baseUrl + updatedTemplate;
Expand All @@ -152,7 +153,8 @@ public void userModifiesAuthorizeValue() throws Exception {
public void userRemovesAuthorizeInUrl() throws Exception {
String baseUrl = EsignetConfigManager.getproperty("eSignetbaseurl");
String template = EsignetConfigManager.getproperty("authorizeUrlTemplate");
String requestUri = EsignetUtil.generateParRequestUri();
String requestUri = EsignetUtil.generateParRequestUri("$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$",
"$CLIENT_ASSERTION_PAR_JWT$");
String updatedTemplate = template.replace("$REQUEST_URI$", requestUri);
updatedTemplate = AdminTestUtil.replaceIdWithAutogeneratedId(updatedTemplate, "$ID:");
String url = baseUrl + updatedTemplate;
Expand Down
Loading
Loading