From f344d68858307465633083ac388aac44b9d06966 Mon Sep 17 00:00:00 2001 From: Bhuvanashree B S Date: Mon, 6 Apr 2026 22:37:35 +0530 Subject: [PATCH 1/5] MOSIP-44833:Resolved codeRabbit comment Signed-off-by: Bhuvanashree B S --- ui-test/src/main/java/pages/ConsentPage.java | 157 ++++++++++++++++++ .../ConsentStepDefinition.java | 125 ++++++++++++++ .../featurefiles/ConsentPage.feature | 45 +++++ 3 files changed, 327 insertions(+) diff --git a/ui-test/src/main/java/pages/ConsentPage.java b/ui-test/src/main/java/pages/ConsentPage.java index a09ae1cf3..04060b9d3 100644 --- a/ui-test/src/main/java/pages/ConsentPage.java +++ b/ui-test/src/main/java/pages/ConsentPage.java @@ -120,6 +120,54 @@ public ConsentPage(WebDriver driver) { @FindBy(xpath = "//p[@class='text-[#4E4E4E] font-semibold']") WebElement actionMessage; + @FindBy(xpath = "//div[@class='header my-2']") + WebElement headerInConsentUpdateProfileScreen; + + @FindBy(xpath = "//p[@class='sub-header m-0 mt-1 md:mx-5 md:mb-1 md:mt-3']") + WebElement subHeaderInConsentUpdateProfileScreen; + + @FindBy(xpath = "(//div[@class='font-semibold mb-1'])[1]") + WebElement essentialClaimHeaderInConsentUpdateProfileScreen; + + @FindBy(xpath = "(//div[@class='font-semibold mb-1'])[2]") + WebElement voluntaryClaimHeaderInConsentUpdateProfileScreen; + + @FindBy(xpath = "(//*[name()='svg' and contains(@class,'cursor-pointer')])[1]") + WebElement essentialInfoIconInConsentUpdateProfileScreen; + + @FindBy(xpath = "(//*[name()='svg' and contains(@class,'cursor-pointer')])[2]") + WebElement voluntaryInfoIconInConsentUpdateProfileScreen; + + @FindBy(id = "cancel-button") + WebElement cancelButtonInConsentUpdateProfileScreen; + + @FindBy(xpath = "(//div[@class='divide-y'])[2]") + WebElement voluntaryClaimsList; + + @FindBy(xpath = "//span[@class='available-claim']") + WebElement availableClaimsStatus; + + @FindBy(xpath = "//span[@class='not-available-claim']") + WebElement notAvailableClaimStatus; + + @FindBy(xpath = "(//p[@class='mb-1'])[1]") + WebElement infoIconMeassage; + + @FindBy(xpath = "//div[@class='message mx-0 px-2 mt-2 md:mx-5']") + WebElement messageAboveProceedBtn; + + @FindBy(xpath = "//div[@class='relative text-center text-dark font-semibold text-xl text-[#2B3840] mt-9']") + WebElement attentionHeaderInWarningPopup; + + @FindBy(xpath = "//p[@class='text-base text-[#707070]']") + WebElement subHeaderInWarningPopup; + + @FindBy(id = "stay-button") + WebElement stayButtonInConsentUpdateProfileScreen; + + @FindBy(id = "discontinue-button") + WebElement discontinueButtonInConsentUpdateProfileScreen; + public void clickOnLoginWithOtp() { clickOnElement(loginWithOtpButton, "Clicked on login with Otp button"); } @@ -329,4 +377,113 @@ public boolean isVerifyOtpButtonEnabled() { return isButtonEnabled(verifyOtpButton, "Verified otp verification button is enabled"); } + public boolean isHeaderInConsentUpdateProfileScreenVisible() { + return isElementVisible(headerInConsentUpdateProfileScreen, "Verified header in consent update profile screen"); + } + + public boolean isSubHeaderInConsentUpdateProfileScreenVisible() { + return isElementVisible(subHeaderInConsentUpdateProfileScreen, + "Verified sub header in consent update profile screen"); + } + + public boolean isEssentialClaimsHeaderInConsentUpdateProfileScreenVisible() { + return isElementVisible(essentialClaimHeaderInConsentUpdateProfileScreen, + "Verified essential claims header in consent update profile screen"); + } + + public boolean isVoluntaryClaimsHeaderInConsentUpdateProfileScreenVisible() { + return isElementVisible(voluntaryClaimHeaderInConsentUpdateProfileScreen, + "Verified voluntary claims header in consent update profile screen"); + } + + public boolean isInfoIconInConsentUpdateProfileScreenVisible() { + return isElementVisible(essentialInfoIconInConsentUpdateProfileScreen, + "Verified info icon in consent update profile screen"); + } + + public boolean isProceedButtonInConsentUpdateProfileScreenVisible() { + return isElementVisible(proceedButtonInAttentionPage, + "Verified procced button in consent update profile screen"); + } + + public boolean isCancelButtonInConsentUpdateProfileScreenVisible() { + return isElementVisible(cancelButtonInConsentUpdateProfileScreen, + "Verified cancel button in consent update profile screen"); + } + + public boolean isEssentialClaimListInConsentUpdateProfileScreenVisible() { + return isElementVisible(essentialClaimsList, "Verified essential claim list in consent update profile screen"); + } + + public boolean isVoluntaryClaimListInConsentUpdateProfileScreenVisible() { + return isElementVisible(voluntaryClaimsList, "Verified voluntary claim list in consent update profile screen"); + } + + public boolean isAvailableClaimStausDisplayed() { + return isElementVisible(availableClaimsStatus, + "Verified available claim status in consent update profile screen"); + } + + public boolean isNotAvailableClaimStausDisplayed() { + return isElementVisible(notAvailableClaimStatus, + "Verified not available claim status in consent update profile screen"); + } + + public void clickOnEssentialInfoIcon() { + clickOnElement(essentialInfoIconInConsentUpdateProfileScreen, + "Clicked on Info icon in consent update profile screen"); + } + + public void clickOnVoluntaryInfoIcon() { + clickOnElement(voluntaryInfoIconInConsentUpdateProfileScreen, + "Clicked on Info icon in consent update profile screen"); + } + + public void clickOnAttentionHeader() { + clickOnElement(headerInConsentUpdateProfileScreen, "Clicked on header in consent update profile screen"); + } + + public boolean isEssentialClaimInformationDisplayed() { + return isElementVisible(infoIconMeassage, "Verified essential claim information is displayed"); + } + + public boolean isVoluntaryClaimInformationDisplayed() { + return isElementVisible(infoIconMeassage, "Verified voluntary claim information is displayed"); + } + + public boolean isMessageAboveProceedButtonDisplayed() { + return isElementVisible(messageAboveProceedBtn, + "Verified message above the proceed button in consent update profile screen"); + } + + public void clickOnCancelButtonInUpdateProfilePage() { + clickOnElement(cancelButtonInConsentUpdateProfileScreen, + "Clicked on cancel button in consent update profile screen"); + } + + public boolean isAttentionWarningPopupDisplayed() { + return isElementVisible(attentionHeaderInWarningPopup, "Verified header in warning popup"); + } + + public boolean isSubHeaderInWarningPopupDisplayed() { + return isElementVisible(subHeaderInWarningPopup, "Verified sub header in warning popup"); + } + + public boolean isStayButtonInWaninPopupScreenDisplayed() { + return isElementVisible(stayButtonInConsentUpdateProfileScreen, + "Verified stay button in warning popup is displayed"); + } + + public void clickOnStayButton() { + clickOnElement(stayButtonInConsentUpdateProfileScreen, "Clicked on stay button"); + } + + public boolean isDiscontinueButtonInWaninPopupScreenDisplayed() { + return isElementVisible(discontinueButtonInConsentUpdateProfileScreen, + "Verified discontinue button in warning popup is displayed"); + } + + public void clickOnDiscontinueButton() { + clickOnElement(discontinueButtonInConsentUpdateProfileScreen, "Clicked on discontinue button"); + } } \ No newline at end of file diff --git a/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java b/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java index 3a3dca364..4f6be4f89 100644 --- a/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java +++ b/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java @@ -364,4 +364,129 @@ public void verifyOtpVerificationButtonIsEnabled() { Assert.assertTrue(consentPage.isVerifyOtpButtonEnabled(), "Otp verification button is not enabled"); } + + @Then("verify the header Attention in the consent to profile update screen") + public void verifyHeaderInConsentProfileUpdateScreenDisplayed() { + Assert.assertTrue(consentPage.isHeaderInConsentUpdateProfileScreenVisible(), + "Header in consent to profile update screen is not displayed"); + } + + @Then("verify the sub header in the consent to profile update screen") + public void verifySubHeaderInConsentProfileUpdateScreenDisplayed() { + Assert.assertTrue(consentPage.isSubHeaderInConsentUpdateProfileScreenVisible(), + "Sub header in consent to profile update screen is not displayed"); + } + + @Then("verify the essential claim header in consent to update profile screen") + public void verifyEssentialClaimHeaderInConsentProfileUpdateScreenDisplayed() { + Assert.assertTrue(consentPage.isEssentialClaimsHeaderInConsentUpdateProfileScreenVisible(), + "Essential cliams header in consent to profile update screen is not displayed"); + } + + @Then("verify the voluntary claim header in the consent to profile update screen") + public void verifyVoluntaryClaimHeaderInConsentProfileUpdateScreenDisplayed() { + Assert.assertTrue(consentPage.isVoluntaryClaimsHeaderInConsentUpdateProfileScreenVisible(), + "Voluntary cliams header in consent to profile update screen is not displayed"); + } + + @Then("verify info icon is available in consent to update profile screen") + public void verifyInfoIconInConsentProfileUpdateScreenDisplayed() { + Assert.assertTrue(consentPage.isInfoIconInConsentUpdateProfileScreenVisible(), + "Info icon in consent to profile update screen is not displayed"); + } + + @Then("verify proceed button is visible in consent to update profile screen") + public void verifyProceedBtnInConsentProfileUpdateScreenDisplayed() { + Assert.assertTrue(consentPage.isProceedButtonInConsentUpdateProfileScreenVisible(), + "Proceed in consent to profile update screen is not displayed"); + } + + @Then("verify cancel button is visible in consent to update profile screen") + public void verifyCancelBtnInConsentProfileUpdateScreenDisplayed() { + Assert.assertTrue(consentPage.isCancelButtonInConsentUpdateProfileScreenVisible(), + "Cancel in consent to profile update screen is not displayed"); + } + + @Then("user verify the essential claims list") + public void verifyEssentialClaimListInConsentProfileUpdateScreenDisplayed() { + Assert.assertTrue(consentPage.isEssentialClaimListInConsentUpdateProfileScreenVisible(), + "Essential claims list in consent to profile update screen is not displayed"); + } + + @Then("user verify the voluntary claims list") + public void verifyVoluntaryClaimListInConsentProfileUpdateScreenDisplayed() { + Assert.assertTrue(consentPage.isVoluntaryClaimListInConsentUpdateProfileScreenVisible(), + "Voluntary claims list in consent to profile update screen is not displayed"); + } + + @Then("user click on essential claim info icon") + public void userClickOnEssentialInfoIcon() { + consentPage.clickOnEssentialInfoIcon(); + } + + @Then("verify the essential claim information displayed on clicking the info icon") + public void verifyEssentialClaimInfoInConsentProfileUpdateScreenDisplayed() { + Assert.assertTrue(consentPage.isEssentialClaimInformationDisplayed(), + "Essential claims information in consent to profile update screen is not displayed"); + } + + @Then("user tab outside the info icon") + public void userClickOutsideInfoIcon() { + consentPage.clickOnAttentionHeader(); + } + + @Then("user click on voluntary claim info icon") + public void userClickOnVoluntaryInfoIcon() { + consentPage.clickOnVoluntaryInfoIcon(); + } + + @Then("verify the voluntary claim information displayed on clicking the info icon") + public void verifyVoluntaryClaimInfoInConsentProfileUpdateScreenDisplayed() { + Assert.assertTrue(consentPage.isVoluntaryClaimInformationDisplayed(), + "Voluntary claims information in consent to profile update screen is not displayed"); + } + + @Then("verify the message click on proceed to begin with the verification process is displayed below") + public void verifyMessageInConsentProfileUpdateScreenDisplayed() { + Assert.assertTrue(consentPage.isMessageAboveProceedButtonDisplayed(), + "Message above proceed in consent to profile update screen is not displayed"); + } + + @When("user click on cancel button in consent update to profile screen") + public void userClickOnCancelButton() { + consentPage.clickOnCancelButtonInUpdateProfilePage(); + } + + @Then("verify warning popup with header attention is displayed") + public void verifyAttentionWarningPopupDisplayed() { + Assert.assertTrue(consentPage.isAttentionWarningPopupDisplayed(), "Header in warning popup is not displayed"); + } + + @Then("verify the sub header in warning popup is displayed") + public void verifySubHeaderWarningPopupDisplayed() { + Assert.assertTrue(consentPage.isSubHeaderInWarningPopupDisplayed(), + "Sub-header in warning popup is not displayed"); + } + + @Then("verify stay button is available in the warning popup") + public void verifyStayButtonInWarningPopupAvailable() { + Assert.assertTrue(consentPage.isStayButtonInWaninPopupScreenDisplayed(), + "Stay button in warning popup is not displayed"); + } + + @Then("verify discontinue button is available in the warning popup") + public void verifyDiscontinueButtonInWarningPopupAvailable() { + Assert.assertTrue(consentPage.isDiscontinueButtonInWaninPopupScreenDisplayed(), + "Discontinue button warning popup is not displayed"); + } + + @When("user click on stay button in warning popup") + public void userClickStayButtonInWarningPopup() { + consentPage.clickOnStayButton(); + } + + @When("user click on discontinue button in warning popup screen") + public void userClickDiscontinueButtonInWarningPopup() { + consentPage.clickOnDiscontinueButton(); + } } \ No newline at end of file diff --git a/ui-test/src/main/resources/featurefiles/ConsentPage.feature b/ui-test/src/main/resources/featurefiles/ConsentPage.feature index 9b8fdcd4f..90803b649 100644 --- a/ui-test/src/main/resources/featurefiles/ConsentPage.feature +++ b/ui-test/src/main/resources/featurefiles/ConsentPage.feature @@ -92,3 +92,48 @@ Feature: Esignet Consent Page And user verify the action message in consent screen And user verify the timer is displayed in consent screen + + @smoke @ConsentToUpdateProfile + Scenario: Verifying user consent to proceed with profile update + Given user captures the authorize url + When click on Language selection option + And select the mandatory language + And user click on Login with Otp + Then user enters Registered mobile number into the mobile number field + And user click on get otp button + When user enters the correct otp + And click on verify Otp button + Then verify user is navigated to consent to profile update screen + And verify the header Attention in the consent to profile update screen + And verify the sub header in the consent to profile update screen + And verify the essential claim header in consent to update profile screen + And verify info icon is available in consent to update profile screen + And verify proceed button is visible in consent to update profile screen + And verify cancel button is visible in consent to update profile screen + And user verify the essential claims list + And user verify the voluntary claims list + And user click on essential claim info icon + And verify the essential claim information displayed on clicking the info icon + And user tab outside the info icon + And user click on voluntary claim info icon + And verify the voluntary claim information displayed on clicking the info icon + And user tab outside the info icon + And verify the message click on proceed to begin with the verification process is displayed below + When user click on cancel button in consent update to profile screen + Then verify warning popup with header attention is displayed + And verify the sub header in warning popup is displayed + And verify stay button is available in the warning popup + And verify discontinue button is available in the warning popup + When user click on stay button in warning popup + Then verify user is navigated to consent to profile update screen + And user click on cancel button in consent update to profile screen + When user click on discontinue button in warning popup screen + Then user verify user is redirected to relying party login page + When user clicks on sign in with esignet button + And user click on Login with Otp + Then user enters Registered mobile number into the mobile number field + And user click on get otp button + When user enters the correct otp + And click on verify Otp button + And clicks on proceed button in attention page + Then verify user navigate to eKYC process steps screen \ No newline at end of file From df49f65305f5cbec4dcd537f9917ad0799782039 Mon Sep 17 00:00:00 2001 From: Bhuvanashree B S Date: Mon, 6 Apr 2026 22:47:25 +0530 Subject: [PATCH 2/5] MOSIP-44833:Resolved codeRabbit comment Signed-off-by: Bhuvanashree B S --- ui-test/src/main/java/pages/ConsentPage.java | 4 ++-- .../src/main/java/stepdefinitions/ConsentStepDefinition.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ui-test/src/main/java/pages/ConsentPage.java b/ui-test/src/main/java/pages/ConsentPage.java index 04060b9d3..f07b2d030 100644 --- a/ui-test/src/main/java/pages/ConsentPage.java +++ b/ui-test/src/main/java/pages/ConsentPage.java @@ -469,7 +469,7 @@ public boolean isSubHeaderInWarningPopupDisplayed() { return isElementVisible(subHeaderInWarningPopup, "Verified sub header in warning popup"); } - public boolean isStayButtonInWaninPopupScreenDisplayed() { + public boolean isStayButtonInWarningPopupScreenDisplayed() { return isElementVisible(stayButtonInConsentUpdateProfileScreen, "Verified stay button in warning popup is displayed"); } @@ -478,7 +478,7 @@ public void clickOnStayButton() { clickOnElement(stayButtonInConsentUpdateProfileScreen, "Clicked on stay button"); } - public boolean isDiscontinueButtonInWaninPopupScreenDisplayed() { + public boolean isDiscontinueButtonInWarningPopupScreenDisplayed() { return isElementVisible(discontinueButtonInConsentUpdateProfileScreen, "Verified discontinue button in warning popup is displayed"); } diff --git a/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java b/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java index 4f6be4f89..bc24f0465 100644 --- a/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java +++ b/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java @@ -470,13 +470,13 @@ public void verifySubHeaderWarningPopupDisplayed() { @Then("verify stay button is available in the warning popup") public void verifyStayButtonInWarningPopupAvailable() { - Assert.assertTrue(consentPage.isStayButtonInWaninPopupScreenDisplayed(), + Assert.assertTrue(consentPage.isStayButtonInWarningPopupScreenDisplayed(), "Stay button in warning popup is not displayed"); } @Then("verify discontinue button is available in the warning popup") public void verifyDiscontinueButtonInWarningPopupAvailable() { - Assert.assertTrue(consentPage.isDiscontinueButtonInWaninPopupScreenDisplayed(), + Assert.assertTrue(consentPage.isDiscontinueButtonInWarningPopupScreenDisplayed(), "Discontinue button warning popup is not displayed"); } From 035a6009f0a2992cbcbed57eba5fc5deae254405 Mon Sep 17 00:00:00 2001 From: Bhuvanashree B S Date: Wed, 22 Apr 2026 12:29:40 +0530 Subject: [PATCH 3/5] MOSIP-44873: Automated the tesctcases for OIDC client purpose-based scenarios Signed-off-by: Bhuvanashree B S --- ui-test/src/main/java/base/BaseTest.java | 65 ++++- ui-test/src/main/java/pages/ConsentPage.java | 41 +++ .../src/main/java/pages/VideoPreviewPage.java | 1 - .../ConsentStepDefinition.java | 119 +++++++- .../InvalidUrlStepDefinition.java | 6 +- ui-test/src/main/java/utils/EsignetUtil.java | 204 ++++++++++++-- .../main/java/utils/ResourceBundleLoader.java | 7 +- .../CreateClientMock/CreateOIDCClient.yml | 260 +++++++++++++++++- .../CreateClientMock/CreateOIDCClient1.hbs | 44 +++ .../featurefiles/ConsentPage.feature | 50 +++- 10 files changed, 751 insertions(+), 46 deletions(-) create mode 100644 ui-test/src/main/resources/esignetUI/CreateClientMock/CreateOIDCClient1.hbs diff --git a/ui-test/src/main/java/base/BaseTest.java b/ui-test/src/main/java/base/BaseTest.java index 551e063e6..d7d7ca89a 100644 --- a/ui-test/src/main/java/base/BaseTest.java +++ b/ui-test/src/main/java/base/BaseTest.java @@ -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; @@ -79,6 +83,37 @@ public static void beforeAll() { } } + private static final Map 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) { @@ -97,6 +132,18 @@ public void beforeAll(Scenario scenario) { } isKnownIssueScenario.set(false); + String pluginName = EsignetUtil.getPluginName(); + + if ("mosipid".equalsIgnoreCase(pluginName)) { + Set 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(); @@ -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; diff --git a/ui-test/src/main/java/pages/ConsentPage.java b/ui-test/src/main/java/pages/ConsentPage.java index f07b2d030..36b9592df 100644 --- a/ui-test/src/main/java/pages/ConsentPage.java +++ b/ui-test/src/main/java/pages/ConsentPage.java @@ -168,6 +168,18 @@ public ConsentPage(WebDriver driver) { @FindBy(id = "discontinue-button") WebElement discontinueButtonInConsentUpdateProfileScreen; + @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; + public void clickOnLoginWithOtp() { clickOnElement(loginWithOtpButton, "Clicked on login with Otp button"); } @@ -486,4 +498,33 @@ public boolean isDiscontinueButtonInWarningPopupScreenDisplayed() { public void clickOnDiscontinueButton() { clickOnElement(discontinueButtonInConsentUpdateProfileScreen, "Clicked on discontinue button"); } + + public boolean isLoginWithOtpDisplayed(String expectedText) { + return loginWithOtpButton.isDisplayed() && 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(); + } + } \ No newline at end of file diff --git a/ui-test/src/main/java/pages/VideoPreviewPage.java b/ui-test/src/main/java/pages/VideoPreviewPage.java index f203c2b6d..8e8258991 100644 --- a/ui-test/src/main/java/pages/VideoPreviewPage.java +++ b/ui-test/src/main/java/pages/VideoPreviewPage.java @@ -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; diff --git a/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java b/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java index bc24f0465..c8900eee2 100644 --- a/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java +++ b/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java @@ -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 { @@ -352,19 +355,17 @@ 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"); } - + @Then("verify the header Attention in the consent to profile update screen") public void verifyHeaderInConsentProfileUpdateScreenDisplayed() { Assert.assertTrue(consentPage.isHeaderInConsentUpdateProfileScreenVisible(), @@ -439,7 +440,7 @@ public void userClickOutsideInfoIcon() { public void userClickOnVoluntaryInfoIcon() { consentPage.clickOnVoluntaryInfoIcon(); } - + @Then("verify the voluntary claim information displayed on clicking the info icon") public void verifyVoluntaryClaimInfoInConsentProfileUpdateScreenDisplayed() { Assert.assertTrue(consentPage.isVoluntaryClaimInformationDisplayed(), @@ -489,4 +490,106 @@ public void userClickStayButtonInWarningPopup() { public void userClickDiscontinueButtonInWarningPopup() { consentPage.clickOnDiscontinueButton(); } + + @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 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 when purpose is none"); + Assert.assertFalse(consentPage.isLoginSubTitleDisplayed(), "Subtitle is displayed when purpose is none"); + } + + @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")); + } + + @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 + } + + @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 authFactors = ClaimsUtil.getAuthFactors(); + Assert.assertFalse(authFactors.isEmpty(), "No auth factors were parsed from the authorize URL"); + + if (authFactors.size() > 1) { + 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 authFactors = ClaimsUtil.getAuthFactors(); + Assert.assertFalse(authFactors.isEmpty(), "No auth factors were parsed from the authorize URL"); + + if (authFactors.size() == 1) { + String expectedText = ResourceBundleLoader.get("otp.login_with_id_multiple"); + Assert.assertEquals(consentPage.getSelectPreferredIdHeaderText(), expectedText, "Expected text mismatch"); + } + } + + @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"); + } } \ No newline at end of file diff --git a/ui-test/src/main/java/stepdefinitions/InvalidUrlStepDefinition.java b/ui-test/src/main/java/stepdefinitions/InvalidUrlStepDefinition.java index d2a75916b..af6d743ef 100644 --- a/ui-test/src/main/java/stepdefinitions/InvalidUrlStepDefinition.java +++ b/ui-test/src/main/java/stepdefinitions/InvalidUrlStepDefinition.java @@ -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; @@ -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; diff --git a/ui-test/src/main/java/utils/EsignetUtil.java b/ui-test/src/main/java/utils/EsignetUtil.java index 3863679a2..780aa92f0 100644 --- a/ui-test/src/main/java/utils/EsignetUtil.java +++ b/ui-test/src/main/java/utils/EsignetUtil.java @@ -15,6 +15,7 @@ import java.util.Random; import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; +import java.util.function.Consumer; import javax.ws.rs.core.MediaType; @@ -71,8 +72,28 @@ public class EsignetUtil extends AdminTestUtil { private static String partnerCookie = null; private static String mobileAuthCookie = null; protected static boolean triggerESignetKeyGenForPAR = true; + protected static boolean triggerESignetKeyGenForPARPurposeLogin = true; + protected static boolean triggerESignetKeyGenForPARPurposeLink = true; + protected static boolean triggerESignetKeyGenForPARPurposeNone = true; + protected static boolean triggerESignetKeyGenForPARNoPurpose = true; + protected static boolean triggerESignetKeyGenForPARNoTitle = true; + protected static boolean triggerESignetKeyGenForPAREmptyTitle = true; + protected static boolean triggerESignetKeyGenForPARSingleAcrValue = true; protected static final String OIDC_JWK_FOR_PAR = "oidcJWKForPAR"; + protected static final String OIDC_JWK_FOR_PAR_PURPOSE_LOGIN = "oidcJWKForPARPurposeLogin"; + protected static final String OIDC_JWK_FOR_PAR_PURPOSE_LINK = "oidcJWKForPARPurposeLink"; + protected static final String OIDC_JWK_FOR_PAR_PURPOSE_NONE = "oidcJWKForPARPurposeNone"; + protected static final String OIDC_JWK_FOR_PAR_NO_PURPOSE = "oidcJWKForPARNoPurposeType"; + protected static final String OIDC_JWK_FOR_PAR_NO_TITLE = "oidcJWKForPARNoTitle"; + protected static final String OIDC_JWK_FOR_PAR_EMPTY_TITLE = "oidcJWKForPAREmptyTitle"; + protected static final String OIDC_JWK_FOR_PAR_SINGLE_ACR_VALUE = "oidcJWKForPARSingleAcrValue"; protected static RSAKey oidc_JWK_Key_For_PAR = null; + protected static RSAKey oidc_JWK_Key_For_PAR_Purpose_Login = null; + protected static RSAKey oidc_JWK_Key_For_PAR_Purpose_Link = null; + protected static RSAKey oidc_JWK_Key_For_PAR_Purpose_None = null; + protected static RSAKey oidc_JWK_Key_For_PAR_No_Purpose = null; + protected static RSAKey oidc_JWK_Key_For_PAR_No_Title = null; + protected static RSAKey oidc_JWK_Key_For_PAR_Acr_Value = null; protected static final String CLAIMS_REQUEST = "config/claims.json"; private static final String display = "popup"; @@ -663,6 +684,62 @@ private static void setTriggerESignetKeyGenForPAR(boolean value) { triggerESignetKeyGenForPAR = value; } + private static boolean getTriggerESignetKeyGenForPARPurposeLogin() { + return triggerESignetKeyGenForPARPurposeLogin; + } + + private static void setTriggerESignetKeyGenForPARPurposeLogin(boolean value) { + triggerESignetKeyGenForPARPurposeLogin = value; + } + + private static boolean getTriggerESignetKeyGenForPARPurposeLink() { + return triggerESignetKeyGenForPARPurposeLink; + } + + private static void setTriggerESignetKeyGenForPARPurposeLink(boolean value) { + triggerESignetKeyGenForPARPurposeLink = value; + } + + private static boolean getTriggerESignetKeyGenForPARPurposeNone() { + return triggerESignetKeyGenForPARPurposeNone; + } + + private static void setTriggerESignetKeyGenForPARPurposeNone(boolean value) { + triggerESignetKeyGenForPARPurposeNone = value; + } + + private static boolean getTriggerESignetKeyGenForPARNoPurpose() { + return triggerESignetKeyGenForPARNoPurpose; + } + + private static void setTriggerESignetKeyGenForPARNoPurpose(boolean value) { + triggerESignetKeyGenForPARNoPurpose = value; + } + + private static boolean getTriggerESignetKeyGenForPARNoTitle() { + return triggerESignetKeyGenForPARNoTitle; + } + + private static void setTriggerESignetKeyGenForPARNoTitle(boolean value) { + triggerESignetKeyGenForPARNoTitle = value; + } + + private static boolean getTriggerESignetKeyGenForPARSingleAcrValue() { + return triggerESignetKeyGenForPARSingleAcrValue; + } + + private static void setTriggerESignetKeyGenForPARSingleAcrValue(boolean value) { + triggerESignetKeyGenForPARSingleAcrValue = value; + } + + private static boolean getTriggerESignetKeyGenForPAREmptyTitle() { + return triggerESignetKeyGenForPAREmptyTitle; + } + + private static void setTriggerESignetKeyGenForPAREmptyTitle(boolean value) { + triggerESignetKeyGenForPAREmptyTitle = value; + } + public static void getSupportedLanguage() { if (EsignetConfigManager.getproperty("esignetSupportedLanguage") != null) { @@ -689,15 +766,82 @@ public static String inputstringKeyWordHandler(String jsonString, String testCas String.valueOf(Calendar.getInstance().getTimeInMillis())); } - if (jsonString.contains("$CLIENT_ASSERTION_PAR_JWT$")) { - String oidcJWKKeyString = JWKKeyUtil.getJWKKey(OIDC_JWK_FOR_PAR); - logger.info("oidcJWKKeyString =" + oidcJWKKeyString); + jsonString = processClientAssertion(jsonString, "$CLIENT_ASSERTION_PAR_JWT$", OIDC_JWK_FOR_PAR, "PAR error"); + + jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR$", OIDC_JWK_FOR_PAR, getTriggerESignetKeyGenForPAR(), + EsignetUtil::setTriggerESignetKeyGenForPAR); + + // PURPOSE_LOGIN + jsonString = processClientAssertion(jsonString, "$CLIENT_ASSERTION_PAR_JWT_PURPOSE_LOGIN$", + OIDC_JWK_FOR_PAR_PURPOSE_LOGIN, "LOGIN error"); + + jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_PURPOSE_LOGIN$", OIDC_JWK_FOR_PAR_PURPOSE_LOGIN, + getTriggerESignetKeyGenForPARPurposeLogin(), EsignetUtil::setTriggerESignetKeyGenForPARPurposeLogin); + + // PURPOSE_LINK + jsonString = processClientAssertion(jsonString, "$CLIENT_ASSERTION_PAR_JWT_PURPOSE_LINK$", + OIDC_JWK_FOR_PAR_PURPOSE_LINK, "LINK error"); + + jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_PURPOSE_LINK$", OIDC_JWK_FOR_PAR_PURPOSE_LINK, + getTriggerESignetKeyGenForPARPurposeLink(), EsignetUtil::setTriggerESignetKeyGenForPARPurposeLink); + + // PURPOSE_NONE + jsonString = processClientAssertion(jsonString, "$CLIENT_ASSERTION_PAR_JWT_PURPOSE_NONE$", + OIDC_JWK_FOR_PAR_PURPOSE_NONE, "NONE error"); + + jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_PURPOSE_NONE$", OIDC_JWK_FOR_PAR_PURPOSE_NONE, + getTriggerESignetKeyGenForPARPurposeNone(), EsignetUtil::setTriggerESignetKeyGenForPARPurposeNone); + + // NO PURPOSE + jsonString = processClientAssertion(jsonString, "$CLIENT_ASSERTION_PAR_JWT_NO_PURPOSE$", + OIDC_JWK_FOR_PAR_NO_PURPOSE, "Purpose error"); + + jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_NO_PURPOSE$", OIDC_JWK_FOR_PAR_NO_PURPOSE, + getTriggerESignetKeyGenForPARNoPurpose(), EsignetUtil::setTriggerESignetKeyGenForPARNoPurpose); + + // NO TITLE + jsonString = processClientAssertion(jsonString, "$CLIENT_ASSERTION_PAR_JWT_NO_TITLE$", + OIDC_JWK_FOR_PAR_NO_TITLE, "Title error"); + + jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_NO_TITLE$", OIDC_JWK_FOR_PAR_NO_TITLE, + getTriggerESignetKeyGenForPARNoTitle(), EsignetUtil::setTriggerESignetKeyGenForPARNoTitle); + + // EMPTY TITLE + jsonString = processClientAssertion(jsonString, "$CLIENT_ASSERTION_PAR_JWT_EMPTY_TITLE$", + OIDC_JWK_FOR_PAR_EMPTY_TITLE, "Title error"); + + jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_EMPTY_TITLE$", OIDC_JWK_FOR_PAR_EMPTY_TITLE, + getTriggerESignetKeyGenForPAREmptyTitle(), EsignetUtil::setTriggerESignetKeyGenForPAREmptyTitle); + + // SINGLE AUTH FACTOR + jsonString = processClientAssertion(jsonString, "$CLIENT_ASSERTION_PAR_JWT_SINGLE_ACR_VALUE$", + OIDC_JWK_FOR_PAR_SINGLE_ACR_VALUE, "ACR error"); + + jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_SINGLE_ACR_VALUE$", OIDC_JWK_FOR_PAR_SINGLE_ACR_VALUE, + getTriggerESignetKeyGenForPARSingleAcrValue(), + EsignetUtil::setTriggerESignetKeyGenForPARSingleAcrValue); + + if (jsonString.contains("$ESIGNET_REDIRECT_URI$")) { + jsonString = replaceKeywordWithValue(jsonString, "$ESIGNET_REDIRECT_URI$", + EsignetConfigManager.getproperty("baseurl") + "userprofile"); + } + + return jsonString; + + } + + private static String processClientAssertion(String jsonString, String placeholder, String jwkKeyName, + String errorMessage) { + + if (jsonString.contains(placeholder)) { + + String keyString = JWKKeyUtil.getJWKKey(jwkKeyName); + RSAKey rsaKey; + try { - oidc_JWK_Key_For_PAR = RSAKey.parse(oidcJWKKeyString); - logger.info("oidc_JWK_Key_For_PAR =" + oidc_JWK_Key_For_PAR); - } catch (java.text.ParseException e) { - logger.error(e.getMessage()); - throw new RuntimeException("Failed to parse OIDC JWK key for PAR", e); + rsaKey = RSAKey.parse(keyString); + } catch (Exception e) { + throw new RuntimeException(errorMessage, e); } JSONObject root = new JSONObject(jsonString); @@ -710,30 +854,31 @@ public static String inputstringKeyWordHandler(String jsonString, String testCas jsonString = root.toString(); } - String tempUrl = getValueFromEsignetWellKnownEndPoint(audKey, EsignetConfigManager.getEsignetBaseUrl()); + String url = getValueFromEsignetWellKnownEndPoint(audKey, EsignetConfigManager.getEsignetBaseUrl()); if (clientId != null) { - jsonString = replaceKeywordWithValue(jsonString, "$CLIENT_ASSERTION_PAR_JWT$", - signJWKKey(clientId, oidc_JWK_Key_For_PAR, tempUrl)); - } else { - logger.error("Client ID not found in JSON for $CLIENT_ASSERTION_PAR_JWT$."); + jsonString = replaceKeywordWithValue(jsonString, placeholder, signJWKKey(clientId, rsaKey, url)); } } - if (jsonString.contains("$OIDC_JWK_KEY_PAR$")) { - String jwkKey = ""; - if (getTriggerESignetKeyGenForPAR()) { - jwkKey = JWKKeyUtil.generateAndCacheJWKKey(OIDC_JWK_FOR_PAR); - setTriggerESignetKeyGenForPAR(false); + return jsonString; + } + + private static String processJWKKey(String jsonString, String placeholder, String jwkKeyName, boolean trigger, + Consumer setter) { + + if (jsonString.contains(placeholder)) { + + String jwkKey; + + if (trigger) { + jwkKey = JWKKeyUtil.generateAndCacheJWKKey(jwkKeyName); + setter.accept(false); } else { - jwkKey = JWKKeyUtil.getJWKKey(OIDC_JWK_FOR_PAR); + jwkKey = JWKKeyUtil.getJWKKey(jwkKeyName); } - jsonString = replaceKeywordWithValue(jsonString, "$OIDC_JWK_KEY_PAR$", jwkKey); - } - if (jsonString.contains("$ESIGNET_REDIRECT_URI$")) { - jsonString = replaceKeywordWithValue(jsonString, "$ESIGNET_REDIRECT_URI$", - EsignetConfigManager.getproperty("baseurl") + "userprofile"); + jsonString = replaceKeywordWithValue(jsonString, placeholder, jwkKey); } return jsonString; @@ -950,7 +1095,8 @@ protected static Response postWithBodyAndCookieForAutoGeneratedIdForUrlEncoded(S } } - public static String generateParRequestUri() throws SecurityXSSException, JsonProcessingException { + public static String generateParRequestUri(String clientIdKey, String clientAssertionPlaceholder) + throws SecurityXSSException, JsonProcessingException { String baseUrl = EsignetConfigManager.getproperty("eSignetbaseurl"); String parUrl = baseUrl + "/v1/esignet/oauth/par"; @@ -961,8 +1107,10 @@ public static String generateParRequestUri() throws SecurityXSSException, JsonPr requestBody.put("display", display); requestBody.put("response_type", responseType); requestBody.put("nonce", "$UNIQUENONCEVALUEFORESIGNET$"); - requestBody.put("client_id", AdminTestUtil - .replaceIdWithAutogeneratedId("$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$", "$ID:")); + if (clientIdKey == null || clientIdKey.isEmpty()) { + clientIdKey = "$ID:CreateOIDCClient_all_Valid_Smoke_sid_clientId$"; + } + requestBody.put("client_id", AdminTestUtil.replaceIdWithAutogeneratedId(clientIdKey, "$ID:")); requestBody.put("requestTime", "$TIMESTAMP$"); requestBody.put("client_assertion_type", client_assertion_type); requestBody.put("claim_locales", claim_locales); @@ -972,7 +1120,7 @@ public static String generateParRequestUri() throws SecurityXSSException, JsonPr "mosip:idp:acr:generated-code mosip:idp:acr:biometrics mosip:idp:acr:linked-wallet mosip:idp:acr:password"); requestBody.put("redirect_uri", "$ESIGNET_REDIRECT_URI$"); requestBody.put("state", state); - requestBody.put("client_assertion", "$CLIENT_ASSERTION_PAR_JWT$"); + requestBody.put("client_assertion", clientAssertionPlaceholder); requestBody.put("prompt", prompt); requestBody.put("aud_key", aud_key); diff --git a/ui-test/src/main/java/utils/ResourceBundleLoader.java b/ui-test/src/main/java/utils/ResourceBundleLoader.java index ac78eb3ca..da7f101cc 100644 --- a/ui-test/src/main/java/utils/ResourceBundleLoader.java +++ b/ui-test/src/main/java/utils/ResourceBundleLoader.java @@ -41,7 +41,7 @@ private static void loadResourceBundleJson(String currentLang) { logger.warn("No ISO mapping found for language: " + currentLang + ", falling back to: " + currentLang); twoLetterCode = currentLang; } - String url = EsignetConfigManager.getproperty("baseurl") + "/locales/" + twoLetterCode + ".json"; + String url = EsignetConfigManager.getproperty("eSignetbaseurl") + "/locales/" + twoLetterCode + ".json"; String jsonContent = downloadJson(url); Map nestedMap = new ObjectMapper().readValue(jsonContent, new TypeReference<>() { @@ -74,4 +74,9 @@ private static void flatten(Map source, String prefix, Map Date: Wed, 22 Apr 2026 12:41:26 +0530 Subject: [PATCH 4/5] MOSIP-44873: Automated the tesctcases for OIDC client purpose-based scenarios Signed-off-by: Bhuvanashree B S --- ui-test/src/main/java/pages/ConsentPage.java | 158 ------------------ .../ConsentStepDefinition.java | 125 -------------- .../featurefiles/ConsentPage.feature | 45 ----- 3 files changed, 328 deletions(-) diff --git a/ui-test/src/main/java/pages/ConsentPage.java b/ui-test/src/main/java/pages/ConsentPage.java index 36b9592df..e37ab6aee 100644 --- a/ui-test/src/main/java/pages/ConsentPage.java +++ b/ui-test/src/main/java/pages/ConsentPage.java @@ -120,54 +120,6 @@ public ConsentPage(WebDriver driver) { @FindBy(xpath = "//p[@class='text-[#4E4E4E] font-semibold']") WebElement actionMessage; - @FindBy(xpath = "//div[@class='header my-2']") - WebElement headerInConsentUpdateProfileScreen; - - @FindBy(xpath = "//p[@class='sub-header m-0 mt-1 md:mx-5 md:mb-1 md:mt-3']") - WebElement subHeaderInConsentUpdateProfileScreen; - - @FindBy(xpath = "(//div[@class='font-semibold mb-1'])[1]") - WebElement essentialClaimHeaderInConsentUpdateProfileScreen; - - @FindBy(xpath = "(//div[@class='font-semibold mb-1'])[2]") - WebElement voluntaryClaimHeaderInConsentUpdateProfileScreen; - - @FindBy(xpath = "(//*[name()='svg' and contains(@class,'cursor-pointer')])[1]") - WebElement essentialInfoIconInConsentUpdateProfileScreen; - - @FindBy(xpath = "(//*[name()='svg' and contains(@class,'cursor-pointer')])[2]") - WebElement voluntaryInfoIconInConsentUpdateProfileScreen; - - @FindBy(id = "cancel-button") - WebElement cancelButtonInConsentUpdateProfileScreen; - - @FindBy(xpath = "(//div[@class='divide-y'])[2]") - WebElement voluntaryClaimsList; - - @FindBy(xpath = "//span[@class='available-claim']") - WebElement availableClaimsStatus; - - @FindBy(xpath = "//span[@class='not-available-claim']") - WebElement notAvailableClaimStatus; - - @FindBy(xpath = "(//p[@class='mb-1'])[1]") - WebElement infoIconMeassage; - - @FindBy(xpath = "//div[@class='message mx-0 px-2 mt-2 md:mx-5']") - WebElement messageAboveProceedBtn; - - @FindBy(xpath = "//div[@class='relative text-center text-dark font-semibold text-xl text-[#2B3840] mt-9']") - WebElement attentionHeaderInWarningPopup; - - @FindBy(xpath = "//p[@class='text-base text-[#707070]']") - WebElement subHeaderInWarningPopup; - - @FindBy(id = "stay-button") - WebElement stayButtonInConsentUpdateProfileScreen; - - @FindBy(id = "discontinue-button") - WebElement discontinueButtonInConsentUpdateProfileScreen; - @FindBy(id = "login-header") WebElement loginTitle; @@ -389,116 +341,6 @@ public boolean isVerifyOtpButtonEnabled() { return isButtonEnabled(verifyOtpButton, "Verified otp verification button is enabled"); } - public boolean isHeaderInConsentUpdateProfileScreenVisible() { - return isElementVisible(headerInConsentUpdateProfileScreen, "Verified header in consent update profile screen"); - } - - public boolean isSubHeaderInConsentUpdateProfileScreenVisible() { - return isElementVisible(subHeaderInConsentUpdateProfileScreen, - "Verified sub header in consent update profile screen"); - } - - public boolean isEssentialClaimsHeaderInConsentUpdateProfileScreenVisible() { - return isElementVisible(essentialClaimHeaderInConsentUpdateProfileScreen, - "Verified essential claims header in consent update profile screen"); - } - - public boolean isVoluntaryClaimsHeaderInConsentUpdateProfileScreenVisible() { - return isElementVisible(voluntaryClaimHeaderInConsentUpdateProfileScreen, - "Verified voluntary claims header in consent update profile screen"); - } - - public boolean isInfoIconInConsentUpdateProfileScreenVisible() { - return isElementVisible(essentialInfoIconInConsentUpdateProfileScreen, - "Verified info icon in consent update profile screen"); - } - - public boolean isProceedButtonInConsentUpdateProfileScreenVisible() { - return isElementVisible(proceedButtonInAttentionPage, - "Verified procced button in consent update profile screen"); - } - - public boolean isCancelButtonInConsentUpdateProfileScreenVisible() { - return isElementVisible(cancelButtonInConsentUpdateProfileScreen, - "Verified cancel button in consent update profile screen"); - } - - public boolean isEssentialClaimListInConsentUpdateProfileScreenVisible() { - return isElementVisible(essentialClaimsList, "Verified essential claim list in consent update profile screen"); - } - - public boolean isVoluntaryClaimListInConsentUpdateProfileScreenVisible() { - return isElementVisible(voluntaryClaimsList, "Verified voluntary claim list in consent update profile screen"); - } - - public boolean isAvailableClaimStausDisplayed() { - return isElementVisible(availableClaimsStatus, - "Verified available claim status in consent update profile screen"); - } - - public boolean isNotAvailableClaimStausDisplayed() { - return isElementVisible(notAvailableClaimStatus, - "Verified not available claim status in consent update profile screen"); - } - - public void clickOnEssentialInfoIcon() { - clickOnElement(essentialInfoIconInConsentUpdateProfileScreen, - "Clicked on Info icon in consent update profile screen"); - } - - public void clickOnVoluntaryInfoIcon() { - clickOnElement(voluntaryInfoIconInConsentUpdateProfileScreen, - "Clicked on Info icon in consent update profile screen"); - } - - public void clickOnAttentionHeader() { - clickOnElement(headerInConsentUpdateProfileScreen, "Clicked on header in consent update profile screen"); - } - - public boolean isEssentialClaimInformationDisplayed() { - return isElementVisible(infoIconMeassage, "Verified essential claim information is displayed"); - } - - public boolean isVoluntaryClaimInformationDisplayed() { - return isElementVisible(infoIconMeassage, "Verified voluntary claim information is displayed"); - } - - public boolean isMessageAboveProceedButtonDisplayed() { - return isElementVisible(messageAboveProceedBtn, - "Verified message above the proceed button in consent update profile screen"); - } - - public void clickOnCancelButtonInUpdateProfilePage() { - clickOnElement(cancelButtonInConsentUpdateProfileScreen, - "Clicked on cancel button in consent update profile screen"); - } - - public boolean isAttentionWarningPopupDisplayed() { - return isElementVisible(attentionHeaderInWarningPopup, "Verified header in warning popup"); - } - - public boolean isSubHeaderInWarningPopupDisplayed() { - return isElementVisible(subHeaderInWarningPopup, "Verified sub header in warning popup"); - } - - public boolean isStayButtonInWarningPopupScreenDisplayed() { - return isElementVisible(stayButtonInConsentUpdateProfileScreen, - "Verified stay button in warning popup is displayed"); - } - - public void clickOnStayButton() { - clickOnElement(stayButtonInConsentUpdateProfileScreen, "Clicked on stay button"); - } - - public boolean isDiscontinueButtonInWarningPopupScreenDisplayed() { - return isElementVisible(discontinueButtonInConsentUpdateProfileScreen, - "Verified discontinue button in warning popup is displayed"); - } - - public void clickOnDiscontinueButton() { - clickOnElement(discontinueButtonInConsentUpdateProfileScreen, "Clicked on discontinue button"); - } - public boolean isLoginWithOtpDisplayed(String expectedText) { return loginWithOtpButton.isDisplayed() && loginWithOtpButton.getText().trim().startsWith(expectedText); } diff --git a/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java b/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java index c8900eee2..b91f519ad 100644 --- a/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java +++ b/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java @@ -366,131 +366,6 @@ public void verifyOtpVerificationButtonIsEnabled() { Assert.assertTrue(consentPage.isVerifyOtpButtonEnabled(), "Otp verification button is not enabled"); } - @Then("verify the header Attention in the consent to profile update screen") - public void verifyHeaderInConsentProfileUpdateScreenDisplayed() { - Assert.assertTrue(consentPage.isHeaderInConsentUpdateProfileScreenVisible(), - "Header in consent to profile update screen is not displayed"); - } - - @Then("verify the sub header in the consent to profile update screen") - public void verifySubHeaderInConsentProfileUpdateScreenDisplayed() { - Assert.assertTrue(consentPage.isSubHeaderInConsentUpdateProfileScreenVisible(), - "Sub header in consent to profile update screen is not displayed"); - } - - @Then("verify the essential claim header in consent to update profile screen") - public void verifyEssentialClaimHeaderInConsentProfileUpdateScreenDisplayed() { - Assert.assertTrue(consentPage.isEssentialClaimsHeaderInConsentUpdateProfileScreenVisible(), - "Essential cliams header in consent to profile update screen is not displayed"); - } - - @Then("verify the voluntary claim header in the consent to profile update screen") - public void verifyVoluntaryClaimHeaderInConsentProfileUpdateScreenDisplayed() { - Assert.assertTrue(consentPage.isVoluntaryClaimsHeaderInConsentUpdateProfileScreenVisible(), - "Voluntary cliams header in consent to profile update screen is not displayed"); - } - - @Then("verify info icon is available in consent to update profile screen") - public void verifyInfoIconInConsentProfileUpdateScreenDisplayed() { - Assert.assertTrue(consentPage.isInfoIconInConsentUpdateProfileScreenVisible(), - "Info icon in consent to profile update screen is not displayed"); - } - - @Then("verify proceed button is visible in consent to update profile screen") - public void verifyProceedBtnInConsentProfileUpdateScreenDisplayed() { - Assert.assertTrue(consentPage.isProceedButtonInConsentUpdateProfileScreenVisible(), - "Proceed in consent to profile update screen is not displayed"); - } - - @Then("verify cancel button is visible in consent to update profile screen") - public void verifyCancelBtnInConsentProfileUpdateScreenDisplayed() { - Assert.assertTrue(consentPage.isCancelButtonInConsentUpdateProfileScreenVisible(), - "Cancel in consent to profile update screen is not displayed"); - } - - @Then("user verify the essential claims list") - public void verifyEssentialClaimListInConsentProfileUpdateScreenDisplayed() { - Assert.assertTrue(consentPage.isEssentialClaimListInConsentUpdateProfileScreenVisible(), - "Essential claims list in consent to profile update screen is not displayed"); - } - - @Then("user verify the voluntary claims list") - public void verifyVoluntaryClaimListInConsentProfileUpdateScreenDisplayed() { - Assert.assertTrue(consentPage.isVoluntaryClaimListInConsentUpdateProfileScreenVisible(), - "Voluntary claims list in consent to profile update screen is not displayed"); - } - - @Then("user click on essential claim info icon") - public void userClickOnEssentialInfoIcon() { - consentPage.clickOnEssentialInfoIcon(); - } - - @Then("verify the essential claim information displayed on clicking the info icon") - public void verifyEssentialClaimInfoInConsentProfileUpdateScreenDisplayed() { - Assert.assertTrue(consentPage.isEssentialClaimInformationDisplayed(), - "Essential claims information in consent to profile update screen is not displayed"); - } - - @Then("user tab outside the info icon") - public void userClickOutsideInfoIcon() { - consentPage.clickOnAttentionHeader(); - } - - @Then("user click on voluntary claim info icon") - public void userClickOnVoluntaryInfoIcon() { - consentPage.clickOnVoluntaryInfoIcon(); - } - - @Then("verify the voluntary claim information displayed on clicking the info icon") - public void verifyVoluntaryClaimInfoInConsentProfileUpdateScreenDisplayed() { - Assert.assertTrue(consentPage.isVoluntaryClaimInformationDisplayed(), - "Voluntary claims information in consent to profile update screen is not displayed"); - } - - @Then("verify the message click on proceed to begin with the verification process is displayed below") - public void verifyMessageInConsentProfileUpdateScreenDisplayed() { - Assert.assertTrue(consentPage.isMessageAboveProceedButtonDisplayed(), - "Message above proceed in consent to profile update screen is not displayed"); - } - - @When("user click on cancel button in consent update to profile screen") - public void userClickOnCancelButton() { - consentPage.clickOnCancelButtonInUpdateProfilePage(); - } - - @Then("verify warning popup with header attention is displayed") - public void verifyAttentionWarningPopupDisplayed() { - Assert.assertTrue(consentPage.isAttentionWarningPopupDisplayed(), "Header in warning popup is not displayed"); - } - - @Then("verify the sub header in warning popup is displayed") - public void verifySubHeaderWarningPopupDisplayed() { - Assert.assertTrue(consentPage.isSubHeaderInWarningPopupDisplayed(), - "Sub-header in warning popup is not displayed"); - } - - @Then("verify stay button is available in the warning popup") - public void verifyStayButtonInWarningPopupAvailable() { - Assert.assertTrue(consentPage.isStayButtonInWarningPopupScreenDisplayed(), - "Stay button in warning popup is not displayed"); - } - - @Then("verify discontinue button is available in the warning popup") - public void verifyDiscontinueButtonInWarningPopupAvailable() { - Assert.assertTrue(consentPage.isDiscontinueButtonInWarningPopupScreenDisplayed(), - "Discontinue button warning popup is not displayed"); - } - - @When("user click on stay button in warning popup") - public void userClickStayButtonInWarningPopup() { - consentPage.clickOnStayButton(); - } - - @When("user click on discontinue button in warning popup screen") - public void userClickDiscontinueButtonInWarningPopup() { - consentPage.clickOnDiscontinueButton(); - } - @When("user creates the client with purpose type login") public void userCreateClientIdPurposeLogin() { // Purpose is already handled via scenario tags in BaseTest diff --git a/ui-test/src/main/resources/featurefiles/ConsentPage.feature b/ui-test/src/main/resources/featurefiles/ConsentPage.feature index 13495b05c..d38cb167a 100644 --- a/ui-test/src/main/resources/featurefiles/ConsentPage.feature +++ b/ui-test/src/main/resources/featurefiles/ConsentPage.feature @@ -93,51 +93,6 @@ Feature: Esignet Consent Page And user verify the action message in consent screen And user verify the timer is displayed in consent screen - @smoke @ConsentToUpdateProfile - Scenario: Verifying user consent to proceed with profile update - Given user captures the authorize url - When click on Language selection option - And select the mandatory language - And user click on Login with Otp - Then user enters Registered mobile number into the mobile number field - And user click on get otp button - When user enters the correct otp - And click on verify Otp button - Then verify user is navigated to consent to profile update screen - And verify the header Attention in the consent to profile update screen - And verify the sub header in the consent to profile update screen - And verify the essential claim header in consent to update profile screen - And verify info icon is available in consent to update profile screen - And verify proceed button is visible in consent to update profile screen - And verify cancel button is visible in consent to update profile screen - And user verify the essential claims list - And user verify the voluntary claims list - And user click on essential claim info icon - And verify the essential claim information displayed on clicking the info icon - And user tab outside the info icon - And user click on voluntary claim info icon - And verify the voluntary claim information displayed on clicking the info icon - And user tab outside the info icon - And verify the message click on proceed to begin with the verification process is displayed below - When user click on cancel button in consent update to profile screen - Then verify warning popup with header attention is displayed - And verify the sub header in warning popup is displayed - And verify stay button is available in the warning popup - And verify discontinue button is available in the warning popup - When user click on stay button in warning popup - Then verify user is navigated to consent to profile update screen - And user click on cancel button in consent update to profile screen - When user click on discontinue button in warning popup screen - Then user verify user is redirected to relying party login page - When user clicks on sign in with esignet button - And user click on Login with Otp - Then user enters Registered mobile number into the mobile number field - And user click on get otp button - When user enters the correct otp - And click on verify Otp button - And clicks on proceed button in attention page - Then verify user navigate to eKYC process steps screen - @smoke @PurposeLogin Scenario: Verifying auth factors for a client ID with purpose type login When user creates the client with purpose type login From 0155937eb347cae7b3cabfa14e56ae316deedc44 Mon Sep 17 00:00:00 2001 From: Bhuvanashree B S Date: Wed, 22 Apr 2026 13:37:54 +0530 Subject: [PATCH 5/5] MOSIP-44873:Resolved codeRabbit comments Signed-off-by: Bhuvanashree B S --- ui-test/src/main/java/pages/ConsentPage.java | 2 +- .../ConsentStepDefinition.java | 23 +++--- ui-test/src/main/java/utils/EsignetUtil.java | 81 +++++++------------ .../main/java/utils/ResourceBundleLoader.java | 3 + .../CreateClientMock/CreateOIDCClient.yml | 4 +- .../featurefiles/ConsentPage.feature | 6 +- 6 files changed, 51 insertions(+), 68 deletions(-) diff --git a/ui-test/src/main/java/pages/ConsentPage.java b/ui-test/src/main/java/pages/ConsentPage.java index e37ab6aee..817283ed7 100644 --- a/ui-test/src/main/java/pages/ConsentPage.java +++ b/ui-test/src/main/java/pages/ConsentPage.java @@ -342,7 +342,7 @@ public boolean isVerifyOtpButtonEnabled() { } public boolean isLoginWithOtpDisplayed(String expectedText) { - return loginWithOtpButton.isDisplayed() && loginWithOtpButton.getText().trim().startsWith(expectedText); + return isElementDisplayed(loginWithOtpButton) && loginWithOtpButton.getText().trim().startsWith(expectedText); } public boolean isLoginTitleDisplayed() { diff --git a/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java b/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java index b91f519ad..4aa6527fb 100644 --- a/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java +++ b/ui-test/src/main/java/stepdefinitions/ConsentStepDefinition.java @@ -377,6 +377,11 @@ public void verifyLoginPurposeReflectedInUI() { 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() { @@ -409,8 +414,8 @@ public void userCreateClientIdPurposeNone() { @Then("verify no title or subtitle should be displayed") public void verifyTitleNotDisplayed() { - Assert.assertFalse(consentPage.isLoginTitleDisplayed(), "Title is displayed when purpose is none"); - Assert.assertFalse(consentPage.isLoginSubTitleDisplayed(), "Subtitle is displayed when purpose is none"); + Assert.assertFalse(consentPage.isLoginTitleDisplayed(), "Title is displayed"); + Assert.assertFalse(consentPage.isLoginSubTitleDisplayed(), "Subtitle is displayed"); } @Then("verify title and subtitle should be displayed as per text given during client creation") @@ -440,10 +445,9 @@ public void verifySelectPreferredIdHeaderText() { List authFactors = ClaimsUtil.getAuthFactors(); Assert.assertFalse(authFactors.isEmpty(), "No auth factors were parsed from the authorize URL"); - if (authFactors.size() > 1) { - String expectedText = ResourceBundleLoader.get("otp.login_with_id_multiple"); - Assert.assertEquals(consentPage.getSelectPreferredIdHeaderText(), expectedText, "Expected text mismatch"); - } + 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") @@ -456,10 +460,9 @@ public void verifySelectIdTypeHeaderText() { List authFactors = ClaimsUtil.getAuthFactors(); Assert.assertFalse(authFactors.isEmpty(), "No auth factors were parsed from the authorize URL"); - if (authFactors.size() == 1) { - String expectedText = ResourceBundleLoader.get("otp.login_with_id_multiple"); - Assert.assertEquals(consentPage.getSelectPreferredIdHeaderText(), expectedText, "Expected text mismatch"); - } + 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"); } @Then("verify select preferred ID text based on purpose type is displayed") diff --git a/ui-test/src/main/java/utils/EsignetUtil.java b/ui-test/src/main/java/utils/EsignetUtil.java index 780aa92f0..daad5a15b 100644 --- a/ui-test/src/main/java/utils/EsignetUtil.java +++ b/ui-test/src/main/java/utils/EsignetUtil.java @@ -13,7 +13,9 @@ import java.util.Map; import java.util.Optional; import java.util.Random; +import java.util.Set; import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; import java.util.function.Consumer; @@ -88,12 +90,6 @@ public class EsignetUtil extends AdminTestUtil { protected static final String OIDC_JWK_FOR_PAR_EMPTY_TITLE = "oidcJWKForPAREmptyTitle"; protected static final String OIDC_JWK_FOR_PAR_SINGLE_ACR_VALUE = "oidcJWKForPARSingleAcrValue"; protected static RSAKey oidc_JWK_Key_For_PAR = null; - protected static RSAKey oidc_JWK_Key_For_PAR_Purpose_Login = null; - protected static RSAKey oidc_JWK_Key_For_PAR_Purpose_Link = null; - protected static RSAKey oidc_JWK_Key_For_PAR_Purpose_None = null; - protected static RSAKey oidc_JWK_Key_For_PAR_No_Purpose = null; - protected static RSAKey oidc_JWK_Key_For_PAR_No_Title = null; - protected static RSAKey oidc_JWK_Key_For_PAR_Acr_Value = null; protected static final String CLAIMS_REQUEST = "config/claims.json"; private static final String display = "popup"; @@ -766,60 +762,52 @@ public static String inputstringKeyWordHandler(String jsonString, String testCas String.valueOf(Calendar.getInstance().getTimeInMillis())); } - jsonString = processClientAssertion(jsonString, "$CLIENT_ASSERTION_PAR_JWT$", OIDC_JWK_FOR_PAR, "PAR error"); + jsonString = processClientAssertion(jsonString, "$CLIENT_ASSERTION_PAR_JWT$", OIDC_JWK_FOR_PAR); - jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR$", OIDC_JWK_FOR_PAR, getTriggerESignetKeyGenForPAR(), - EsignetUtil::setTriggerESignetKeyGenForPAR); + jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR$", OIDC_JWK_FOR_PAR); // PURPOSE_LOGIN jsonString = processClientAssertion(jsonString, "$CLIENT_ASSERTION_PAR_JWT_PURPOSE_LOGIN$", - OIDC_JWK_FOR_PAR_PURPOSE_LOGIN, "LOGIN error"); + OIDC_JWK_FOR_PAR_PURPOSE_LOGIN); - jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_PURPOSE_LOGIN$", OIDC_JWK_FOR_PAR_PURPOSE_LOGIN, - getTriggerESignetKeyGenForPARPurposeLogin(), EsignetUtil::setTriggerESignetKeyGenForPARPurposeLogin); + jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_PURPOSE_LOGIN$", OIDC_JWK_FOR_PAR_PURPOSE_LOGIN); // PURPOSE_LINK jsonString = processClientAssertion(jsonString, "$CLIENT_ASSERTION_PAR_JWT_PURPOSE_LINK$", - OIDC_JWK_FOR_PAR_PURPOSE_LINK, "LINK error"); + OIDC_JWK_FOR_PAR_PURPOSE_LINK); - jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_PURPOSE_LINK$", OIDC_JWK_FOR_PAR_PURPOSE_LINK, - getTriggerESignetKeyGenForPARPurposeLink(), EsignetUtil::setTriggerESignetKeyGenForPARPurposeLink); + jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_PURPOSE_LINK$", OIDC_JWK_FOR_PAR_PURPOSE_LINK); // PURPOSE_NONE jsonString = processClientAssertion(jsonString, "$CLIENT_ASSERTION_PAR_JWT_PURPOSE_NONE$", - OIDC_JWK_FOR_PAR_PURPOSE_NONE, "NONE error"); + OIDC_JWK_FOR_PAR_PURPOSE_NONE); - jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_PURPOSE_NONE$", OIDC_JWK_FOR_PAR_PURPOSE_NONE, - getTriggerESignetKeyGenForPARPurposeNone(), EsignetUtil::setTriggerESignetKeyGenForPARPurposeNone); + jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_PURPOSE_NONE$", OIDC_JWK_FOR_PAR_PURPOSE_NONE); // NO PURPOSE jsonString = processClientAssertion(jsonString, "$CLIENT_ASSERTION_PAR_JWT_NO_PURPOSE$", - OIDC_JWK_FOR_PAR_NO_PURPOSE, "Purpose error"); + OIDC_JWK_FOR_PAR_NO_PURPOSE); - jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_NO_PURPOSE$", OIDC_JWK_FOR_PAR_NO_PURPOSE, - getTriggerESignetKeyGenForPARNoPurpose(), EsignetUtil::setTriggerESignetKeyGenForPARNoPurpose); + jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_NO_PURPOSE$", OIDC_JWK_FOR_PAR_NO_PURPOSE); // NO TITLE jsonString = processClientAssertion(jsonString, "$CLIENT_ASSERTION_PAR_JWT_NO_TITLE$", - OIDC_JWK_FOR_PAR_NO_TITLE, "Title error"); + OIDC_JWK_FOR_PAR_NO_TITLE); - jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_NO_TITLE$", OIDC_JWK_FOR_PAR_NO_TITLE, - getTriggerESignetKeyGenForPARNoTitle(), EsignetUtil::setTriggerESignetKeyGenForPARNoTitle); + jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_NO_TITLE$", OIDC_JWK_FOR_PAR_NO_TITLE); // EMPTY TITLE jsonString = processClientAssertion(jsonString, "$CLIENT_ASSERTION_PAR_JWT_EMPTY_TITLE$", - OIDC_JWK_FOR_PAR_EMPTY_TITLE, "Title error"); + OIDC_JWK_FOR_PAR_EMPTY_TITLE); - jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_EMPTY_TITLE$", OIDC_JWK_FOR_PAR_EMPTY_TITLE, - getTriggerESignetKeyGenForPAREmptyTitle(), EsignetUtil::setTriggerESignetKeyGenForPAREmptyTitle); + jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_EMPTY_TITLE$", OIDC_JWK_FOR_PAR_EMPTY_TITLE); // SINGLE AUTH FACTOR jsonString = processClientAssertion(jsonString, "$CLIENT_ASSERTION_PAR_JWT_SINGLE_ACR_VALUE$", - OIDC_JWK_FOR_PAR_SINGLE_ACR_VALUE, "ACR error"); + OIDC_JWK_FOR_PAR_SINGLE_ACR_VALUE); - jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_SINGLE_ACR_VALUE$", OIDC_JWK_FOR_PAR_SINGLE_ACR_VALUE, - getTriggerESignetKeyGenForPARSingleAcrValue(), - EsignetUtil::setTriggerESignetKeyGenForPARSingleAcrValue); + jsonString = processJWKKey(jsonString, "$OIDC_JWK_KEY_PAR_SINGLE_ACR_VALUE$", + OIDC_JWK_FOR_PAR_SINGLE_ACR_VALUE); if (jsonString.contains("$ESIGNET_REDIRECT_URI$")) { jsonString = replaceKeywordWithValue(jsonString, "$ESIGNET_REDIRECT_URI$", @@ -830,8 +818,7 @@ public static String inputstringKeyWordHandler(String jsonString, String testCas } - private static String processClientAssertion(String jsonString, String placeholder, String jwkKeyName, - String errorMessage) { + private static String processClientAssertion(String jsonString, String placeholder, String jwkKeyName) { if (jsonString.contains(placeholder)) { @@ -841,7 +828,8 @@ private static String processClientAssertion(String jsonString, String placehold try { rsaKey = RSAKey.parse(keyString); } catch (Exception e) { - throw new RuntimeException(errorMessage, e); + throw new RuntimeException( + "Failed to parse JWK for placeholder " + placeholder + " (key=" + jwkKeyName + ")", e); } JSONObject root = new JSONObject(jsonString); @@ -864,25 +852,14 @@ private static String processClientAssertion(String jsonString, String placehold return jsonString; } - private static String processJWKKey(String jsonString, String placeholder, String jwkKeyName, boolean trigger, - Consumer setter) { - - if (jsonString.contains(placeholder)) { - - String jwkKey; - - if (trigger) { - jwkKey = JWKKeyUtil.generateAndCacheJWKKey(jwkKeyName); - setter.accept(false); - } else { - jwkKey = JWKKeyUtil.getJWKKey(jwkKeyName); - } - - jsonString = replaceKeywordWithValue(jsonString, placeholder, jwkKey); - } - - return jsonString; + private static final Set generatedJwkKeys = ConcurrentHashMap.newKeySet(); + private static String processJWKKey(String jsonString, String placeholder, String jwkKeyName) { + if (!jsonString.contains(placeholder)) + return jsonString; + String jwkKey = generatedJwkKeys.add(jwkKeyName) ? JWKKeyUtil.generateAndCacheJWKKey(jwkKeyName) + : JWKKeyUtil.getJWKKey(jwkKeyName); + return replaceKeywordWithValue(jsonString, placeholder, jwkKey); } public static String getValueFromEsignetWellKnownEndPoint(String key, String baseURL) { diff --git a/ui-test/src/main/java/utils/ResourceBundleLoader.java b/ui-test/src/main/java/utils/ResourceBundleLoader.java index da7f101cc..5575fbbbf 100644 --- a/ui-test/src/main/java/utils/ResourceBundleLoader.java +++ b/ui-test/src/main/java/utils/ResourceBundleLoader.java @@ -77,6 +77,9 @@ private static void flatten(Map source, String prefix, Map