From 917b16af7069548fc2003044f28be023af6e27d4 Mon Sep 17 00:00:00 2001
From: asha15 <165079T@uom.lk>
Date: Sat, 3 Feb 2024 09:07:53 +0530
Subject: [PATCH 01/11] fix test failure
---
.../PreferenceAPIIntegrationUITestCase.java | 19 ++++++++--
.../challenge_questions_config.toml | 37 +++++++++++++++++++
.../src/test/resources/testng.xml | 5 +--
3 files changed, 54 insertions(+), 7 deletions(-)
create mode 100644 modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/challenge-questions/challenge_questions_config.toml
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
index 66c0cfa61d7..1920639550b 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
@@ -35,12 +35,15 @@
import org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider;
import org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty;
import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO;
+import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager;
import org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient;
import org.wso2.identity.integration.common.clients.oauth.OauthAdminClient;
import org.wso2.identity.integration.test.oauth2.OAuth2ServiceAbstractIntegrationTest;
+import org.wso2.identity.integration.test.util.Utils;
import org.wso2.identity.integration.test.utils.DataExtractUtil;
import org.wso2.identity.integration.test.utils.OAuth2Constant;
+import java.io.File;
import java.io.IOException;
import static org.wso2.identity.integration.test.utils.CommonConstants.DEFAULT_TOMCAT_PORT;
@@ -51,6 +54,7 @@
public class PreferenceAPIIntegrationUITestCase extends OAuth2ServiceAbstractIntegrationTest {
private static final String ENABLE_SELF_REGISTRATION_PROP_KEY = "SelfRegistration.Enable";
+ public static final String ADD_CHALLENGE_QUESTIONS_CONFIG = "challenge_questions_config.toml";
private static final String ENABLE_USERNAME_RECOVERY_PROP_KEY = "Recovery.Notification.Username.Enable";
private static final String ENABLE_PASSWORD_QS_RECOVERY_PROP_KEY = "Recovery.Question.Password.Enable";
private static final String ENABLE_PASSWORD_NOTIFICATION_RECOVERY_PROP_KEY =
@@ -65,8 +69,9 @@ public class PreferenceAPIIntegrationUITestCase extends OAuth2ServiceAbstractInt
private IdentityProvider superTenantResidentIDP;
private IdentityProviderMgtServiceClient superTenantIDPMgtClient;
+ private ServerConfigurationManager serverConfigurationManager;
private String recoveryEndpoint;
- private final String activeTenant;
+ private String activeTenant;
private final String OIDC_APP_NAME = "playground23";
private String oidcAppClientId = "";
@@ -82,12 +87,20 @@ public PreferenceAPIIntegrationUITestCase(TestUserMode userMode) throws Exceptio
super.init(userMode);
AutomationContext context = new AutomationContext("IDENTITY", userMode);
this.activeTenant = context.getContextTenant().getDomain();
-
}
@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
+ super.init();
+ String carbonHome = Utils.getResidentCarbonHome();
+ File defaultConfigFile = getDeploymentTomlFile(carbonHome);
+ File challengeQuestionsConfigFile = new File(
+ getISResourceLocation() + File.separator + "challenge-questions" + File.separator + ADD_CHALLENGE_QUESTIONS_CONFIG);
+ serverConfigurationManager = new ServerConfigurationManager(isServer);
+ serverConfigurationManager.applyConfigurationWithoutRestart(challengeQuestionsConfigFile, defaultConfigFile, true);
+ serverConfigurationManager.restartGracefully();
+
super.init();
superTenantIDPMgtClient = new IdentityProviderMgtServiceClient(sessionCookie, backendURL);
superTenantResidentIDP = superTenantIDPMgtClient.getResidentIdP();
@@ -247,4 +260,4 @@ private String sendRecoveryRequest() throws IOException {
return content;
}
-}
+}
\ No newline at end of file
diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/challenge-questions/challenge_questions_config.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/challenge-questions/challenge_questions_config.toml
new file mode 100644
index 00000000000..764cd944a99
--- /dev/null
+++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/challenge-questions/challenge_questions_config.toml
@@ -0,0 +1,37 @@
+[server]
+hostname = "localhost"
+node_ip = "127.0.0.1"
+base_path = "https://$ref{server.hostname}:${carbon.management.port}"
+
+[super_admin]
+username = "admin"
+password = "admin"
+create_admin_account = true
+
+[user_store]
+type = "database_unique_id"
+
+[database.identity_db]
+driver = "$env{IDENTITY_DATABASE_DRIVER}"
+url = "$env{IDENTITY_DATABASE_URL}"
+username = "$env{IDENTITY_DATABASE_USERNAME}"
+password = "$env{IDENTITY_DATABASE_PASSWORD}"
+
+[database.shared_db]
+driver = "$env{SHARED_DATABASE_DRIVER}"
+url = "$env{SHARED_DATABASE_URL}"
+username = "$env{SHARED_DATABASE_USERNAME}"
+password = "$env{SHARED_DATABASE_PASSWORD}"
+
+[keystore.primary]
+file_name = "wso2carbon.p12"
+password = "wso2carbon"
+type = "PKCS12"
+
+[truststore]
+file_name = "client-truststore.p12"
+password = "wso2carbon"
+type = "PKCS12"
+
+[connector.challenge_questions]
+enable = true
diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml b/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml
index e631af8e8e8..8443e92944a 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml
+++ b/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml
@@ -92,10 +92,6 @@
-
-
@@ -354,6 +350,7 @@
+
From 6def721eea8bae875a6e55cd53c78b0ccdde707b Mon Sep 17 00:00:00 2001
From: asha15 <165079T@uom.lk>
Date: Tue, 6 Feb 2024 10:51:21 +0530
Subject: [PATCH 02/11] restart then server when initiating the testcase
---
.../test/idp/mgt/PreferenceAPIIntegrationUITestCase.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
index 1920639550b..1d76b5c36f4 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
@@ -87,10 +87,6 @@ public PreferenceAPIIntegrationUITestCase(TestUserMode userMode) throws Exceptio
super.init(userMode);
AutomationContext context = new AutomationContext("IDENTITY", userMode);
this.activeTenant = context.getContextTenant().getDomain();
- }
-
- @BeforeClass(alwaysRun = true)
- public void testInit() throws Exception {
super.init();
String carbonHome = Utils.getResidentCarbonHome();
@@ -100,7 +96,11 @@ public void testInit() throws Exception {
serverConfigurationManager = new ServerConfigurationManager(isServer);
serverConfigurationManager.applyConfigurationWithoutRestart(challengeQuestionsConfigFile, defaultConfigFile, true);
serverConfigurationManager.restartGracefully();
+ super.init(userMode);
+ }
+ @BeforeClass(alwaysRun = true)
+ public void testInit() throws Exception {
super.init();
superTenantIDPMgtClient = new IdentityProviderMgtServiceClient(sessionCookie, backendURL);
superTenantResidentIDP = superTenantIDPMgtClient.getResidentIdP();
From 6624d0f14d9a370f6a46330af93c2a3522398ef5 Mon Sep 17 00:00:00 2001
From: asha15 <165079T@uom.lk>
Date: Tue, 6 Feb 2024 10:52:14 +0530
Subject: [PATCH 03/11] add a new line
---
.../test/idp/mgt/PreferenceAPIIntegrationUITestCase.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
index 1d76b5c36f4..a3c11ce1b47 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
@@ -101,6 +101,7 @@ public PreferenceAPIIntegrationUITestCase(TestUserMode userMode) throws Exceptio
@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
+
super.init();
superTenantIDPMgtClient = new IdentityProviderMgtServiceClient(sessionCookie, backendURL);
superTenantResidentIDP = superTenantIDPMgtClient.getResidentIdP();
From 341e2eeaa9b26d36420f51adaff92d11c3588a67 Mon Sep 17 00:00:00 2001
From: asha15 <165079T@uom.lk>
Date: Tue, 6 Feb 2024 10:52:53 +0530
Subject: [PATCH 04/11] add a new line
---
.../test/idp/mgt/PreferenceAPIIntegrationUITestCase.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
index a3c11ce1b47..353e95280e8 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
@@ -261,4 +261,4 @@ private String sendRecoveryRequest() throws IOException {
return content;
}
-}
\ No newline at end of file
+}
From 0119912e435cfe8b349d7498ce2d0935e27df052 Mon Sep 17 00:00:00 2001
From: asha15 <165079T@uom.lk>
Date: Tue, 6 Feb 2024 11:05:09 +0530
Subject: [PATCH 05/11] make activeTenant as final
---
.../test/idp/mgt/PreferenceAPIIntegrationUITestCase.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
index 353e95280e8..a43df14160c 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
@@ -71,7 +71,7 @@ public class PreferenceAPIIntegrationUITestCase extends OAuth2ServiceAbstractInt
private IdentityProviderMgtServiceClient superTenantIDPMgtClient;
private ServerConfigurationManager serverConfigurationManager;
private String recoveryEndpoint;
- private String activeTenant;
+ private final String activeTenant;
private final String OIDC_APP_NAME = "playground23";
private String oidcAppClientId = "";
From 1e67e3d7a5c13ba649e904ffd30ed77536597792 Mon Sep 17 00:00:00 2001
From: asha15 <165079T@uom.lk>
Date: Tue, 6 Feb 2024 22:11:36 +0530
Subject: [PATCH 06/11] start the server only when super admin ligged in
---
.../PreferenceAPIIntegrationUITestCase.java | 34 +++++++++++++------
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
index a43df14160c..b0093c08d1f 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
@@ -35,6 +35,7 @@
import org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider;
import org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty;
import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO;
+import org.wso2.carbon.integration.common.utils.exceptions.AutomationUtilException;
import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager;
import org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient;
import org.wso2.identity.integration.common.clients.oauth.OauthAdminClient;
@@ -70,6 +71,7 @@ public class PreferenceAPIIntegrationUITestCase extends OAuth2ServiceAbstractInt
private IdentityProvider superTenantResidentIDP;
private IdentityProviderMgtServiceClient superTenantIDPMgtClient;
private ServerConfigurationManager serverConfigurationManager;
+ private TestUserMode userMode;
private String recoveryEndpoint;
private final String activeTenant;
private final String OIDC_APP_NAME = "playground23";
@@ -84,19 +86,13 @@ public static Object[][] configProvider() {
@Factory(dataProvider = "configProvider")
public PreferenceAPIIntegrationUITestCase(TestUserMode userMode) throws Exception {
+ this.userMode = userMode;
super.init(userMode);
AutomationContext context = new AutomationContext("IDENTITY", userMode);
this.activeTenant = context.getContextTenant().getDomain();
-
- super.init();
- String carbonHome = Utils.getResidentCarbonHome();
- File defaultConfigFile = getDeploymentTomlFile(carbonHome);
- File challengeQuestionsConfigFile = new File(
- getISResourceLocation() + File.separator + "challenge-questions" + File.separator + ADD_CHALLENGE_QUESTIONS_CONFIG);
- serverConfigurationManager = new ServerConfigurationManager(isServer);
- serverConfigurationManager.applyConfigurationWithoutRestart(challengeQuestionsConfigFile, defaultConfigFile, true);
- serverConfigurationManager.restartGracefully();
- super.init(userMode);
+ if (userMode == TestUserMode.SUPER_TENANT_ADMIN) {
+ changeISConfiguration();
+ }
}
@BeforeClass(alwaysRun = true)
@@ -130,6 +126,9 @@ private void createOIDCApplication() throws Exception {
public void atEnd() throws Exception {
adminClient.removeOAuthApplicationData(oidcAppClientId);
+ if (userMode == TestUserMode.SUPER_TENANT_ADMIN) {
+ restoreDefaultConfig();
+ }
}
@AfterMethod
@@ -261,4 +260,19 @@ private String sendRecoveryRequest() throws IOException {
return content;
}
+ private void restoreDefaultConfig() throws IOException, AutomationUtilException {
+ serverConfigurationManager.restoreToLastConfiguration(false);
+ }
+
+ private void changeISConfiguration() throws Exception {
+ super.init();
+ String carbonHome = Utils.getResidentCarbonHome();
+ File defaultConfigFile = getDeploymentTomlFile(carbonHome);
+ File challengeQuestionsConfigFile = new File(
+ getISResourceLocation() + File.separator + "challenge-questions" + File.separator + ADD_CHALLENGE_QUESTIONS_CONFIG);
+ serverConfigurationManager = new ServerConfigurationManager(isServer);
+ serverConfigurationManager.applyConfigurationWithoutRestart(challengeQuestionsConfigFile, defaultConfigFile, true);
+ serverConfigurationManager.restartGracefully();
+ super.init();
+ }
}
From 1cf59fbc903de489e6d2a48c21a6cd268cc8cb6d Mon Sep 17 00:00:00 2001
From: asha15 <165079T@uom.lk>
Date: Wed, 7 Feb 2024 06:44:22 +0530
Subject: [PATCH 07/11] move testReocvery test to a new class
---
.../idp/mgt/ChallengeQuestionsUITestCase.java | 163 ++++++++++++++++++
.../PreferenceAPIIntegrationUITestCase.java | 35 ----
.../src/test/resources/testng.xml | 3 +-
3 files changed, 165 insertions(+), 36 deletions(-)
create mode 100644 modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ChallengeQuestionsUITestCase.java
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ChallengeQuestionsUITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ChallengeQuestionsUITestCase.java
new file mode 100644
index 00000000000..582657e4ca8
--- /dev/null
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ChallengeQuestionsUITestCase.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
+ *
+ * WSO2 LLC. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.wso2.identity.integration.test.idp.mgt;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.testng.Assert;
+import org.testng.annotations.*;
+import org.wso2.carbon.automation.engine.context.AutomationContext;
+import org.wso2.carbon.automation.engine.context.TestUserMode;
+import org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig;
+import org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider;
+import org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty;
+import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO;
+import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager;
+import org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient;
+import org.wso2.identity.integration.common.clients.oauth.OauthAdminClient;
+import org.wso2.identity.integration.test.oauth2.OAuth2ServiceAbstractIntegrationTest;
+import org.wso2.identity.integration.test.util.Utils;
+import org.wso2.identity.integration.test.utils.DataExtractUtil;
+import org.wso2.identity.integration.test.utils.OAuth2Constant;
+
+import java.io.File;
+import java.io.IOException;
+
+import static org.wso2.identity.integration.test.utils.CommonConstants.DEFAULT_TOMCAT_PORT;
+
+public class ChallengeQuestionsUITestCase extends OAuth2ServiceAbstractIntegrationTest {
+
+ public static final String ADD_CHALLENGE_QUESTIONS_CONFIG = "challenge_questions_config.toml";
+ private static final String RECOVERY_ENDPOINT_URL = "/accountrecoveryendpoint/recoveraccountrouter.do";
+ private static final String RECOVERY_ENDPOINT_QS_CONTENT = "name=\"recoveryOption\" value=\"SECURITY_QUESTIONS\"";
+ private static final String RECOVERY_ENDPOINT_NOTIFICATION_CONTENT = "name=\"recoveryOption\" value=\"EMAIL\"";
+ private static final String ENABLE_PASSWORD_QS_RECOVERY_PROP_KEY = "Recovery.Question.Password.Enable";
+ private static final String ENABLE_PASSWORD_NOTIFICATION_RECOVERY_PROP_KEY =
+ "Recovery.Notification.Password.Enable";
+ private final String OIDC_APP_NAME = "playground23";
+ private IdentityProvider superTenantResidentIDP;
+ private ServerConfigurationManager serverConfigurationManager;
+ private IdentityProviderMgtServiceClient superTenantIDPMgtClient;
+ private String oidcAppClientId = "";
+ private String activeTenant;
+ private String recoveryEndpoint;
+
+ @DataProvider(name = "configProvider")
+ public static Object[][] configProvider() {
+
+ return new Object[][]{{TestUserMode.SUPER_TENANT_ADMIN}, {TestUserMode.TENANT_ADMIN}};
+ }
+
+ @Factory(dataProvider = "configProvider")
+ public ChallengeQuestionsUITestCase(TestUserMode userMode) throws Exception {
+ super.init(userMode);
+ AutomationContext context = new AutomationContext("IDENTITY", userMode);
+ this.activeTenant = context.getContextTenant().getDomain();
+ }
+
+ @BeforeClass(alwaysRun = true)
+ public void testInit() throws Exception {
+
+ super.init();
+ String carbonHome = Utils.getResidentCarbonHome();
+ File defaultConfigFile = getDeploymentTomlFile(carbonHome);
+ File challengeQuestionsConfigFile = new File(
+ getISResourceLocation() + File.separator + "challenge-questions" + File.separator + ADD_CHALLENGE_QUESTIONS_CONFIG);
+ serverConfigurationManager = new ServerConfigurationManager(isServer);
+ serverConfigurationManager.applyConfigurationWithoutRestart(challengeQuestionsConfigFile, defaultConfigFile, true);
+ serverConfigurationManager.restartGracefully();
+
+ super.init();
+ superTenantIDPMgtClient = new IdentityProviderMgtServiceClient(sessionCookie, backendURL);
+ superTenantResidentIDP = superTenantIDPMgtClient.getResidentIdP();
+ adminClient = new OauthAdminClient(backendURL, sessionCookie);
+ String isServerBackendUrl = isServer.getContextUrls().getWebAppURLHttps();
+ recoveryEndpoint = getTenantQualifiedURL(isServerBackendUrl + RECOVERY_ENDPOINT_URL, tenantInfo.getDomain());
+ createOIDCApplication();
+ }
+
+ private void createOIDCApplication() throws Exception {
+
+ OAuthConsumerAppDTO appDTO = new OAuthConsumerAppDTO();
+ appDTO.setApplicationName(OIDC_APP_NAME + activeTenant);
+ appDTO.setCallbackUrl(OAuth2Constant.CALLBACK_URL);
+ appDTO.setOAuthVersion(OAuth2Constant.OAUTH_VERSION_2);
+ appDTO.setGrantTypes(OAuth2Constant.OAUTH2_GRANT_TYPE_AUTHORIZATION_CODE);
+ appDTO.setBackChannelLogoutUrl("http://localhost:" + DEFAULT_TOMCAT_PORT + "/playground2/bclogout");
+
+ adminClient.registerOAuthApplicationData(appDTO);
+ OAuthConsumerAppDTO createdApp = adminClient.getOAuthAppByName(OIDC_APP_NAME + activeTenant);
+ Assert.assertNotNull(createdApp, "Adding OIDC app failed.");
+ oidcAppClientId = createdApp.getOauthConsumerKey();
+ }
+
+ @Test(groups = "wso2.is", description = "Check Password recovery option recovery Page")
+ public void testRecovery() throws Exception {
+
+ updateResidentIDPProperty(superTenantResidentIDP, ENABLE_PASSWORD_NOTIFICATION_RECOVERY_PROP_KEY, "true");
+ updateResidentIDPProperty(superTenantResidentIDP, ENABLE_PASSWORD_QS_RECOVERY_PROP_KEY, "true");
+ String content = sendRecoveryRequest();
+ Assert.assertTrue(content.contains(RECOVERY_ENDPOINT_QS_CONTENT));
+ Assert.assertTrue(content.contains(RECOVERY_ENDPOINT_NOTIFICATION_CONTENT));
+ }
+
+ private void updateResidentIDPProperty(IdentityProvider residentIdp, String propertyKey, String value) throws Exception {
+
+ IdentityProviderProperty[] idpProperties = residentIdp.getIdpProperties();
+ for (IdentityProviderProperty providerProperty : idpProperties) {
+ if (propertyKey.equalsIgnoreCase(providerProperty.getName())) {
+ providerProperty.setValue(value);
+ }
+ }
+ updateResidentIDP(residentIdp);
+ }
+
+ private void updateResidentIDP(IdentityProvider residentIdentityProvider) throws Exception {
+
+ FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs =
+ residentIdentityProvider.getFederatedAuthenticatorConfigs();
+ for (FederatedAuthenticatorConfig authenticatorConfig : federatedAuthenticatorConfigs) {
+ if (!authenticatorConfig.getName().equalsIgnoreCase("samlsso")) {
+ federatedAuthenticatorConfigs = (FederatedAuthenticatorConfig[])
+ ArrayUtils.removeElement(federatedAuthenticatorConfigs,
+ authenticatorConfig);
+ }
+ }
+ residentIdentityProvider.setFederatedAuthenticatorConfigs(federatedAuthenticatorConfigs);
+ superTenantIDPMgtClient.updateResidentIdP(residentIdentityProvider);
+ }
+
+ private String sendRecoveryRequest() throws IOException {
+
+ HttpClient client = HttpClientBuilder.create().build();
+ HttpResponse response = sendGetRequest(client, recoveryEndpoint);
+ String content = DataExtractUtil.getContentData(response);
+ Assert.assertNotNull(content);
+ return content;
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void atEnd() throws Exception {
+
+ adminClient.removeOAuthApplicationData(oidcAppClientId);
+ serverConfigurationManager.restoreToLastConfiguration(false);
+ }
+}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
index b0093c08d1f..54ccd99ed1f 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
@@ -55,7 +55,6 @@
public class PreferenceAPIIntegrationUITestCase extends OAuth2ServiceAbstractIntegrationTest {
private static final String ENABLE_SELF_REGISTRATION_PROP_KEY = "SelfRegistration.Enable";
- public static final String ADD_CHALLENGE_QUESTIONS_CONFIG = "challenge_questions_config.toml";
private static final String ENABLE_USERNAME_RECOVERY_PROP_KEY = "Recovery.Notification.Username.Enable";
private static final String ENABLE_PASSWORD_QS_RECOVERY_PROP_KEY = "Recovery.Question.Password.Enable";
private static final String ENABLE_PASSWORD_NOTIFICATION_RECOVERY_PROP_KEY =
@@ -71,7 +70,6 @@ public class PreferenceAPIIntegrationUITestCase extends OAuth2ServiceAbstractInt
private IdentityProvider superTenantResidentIDP;
private IdentityProviderMgtServiceClient superTenantIDPMgtClient;
private ServerConfigurationManager serverConfigurationManager;
- private TestUserMode userMode;
private String recoveryEndpoint;
private final String activeTenant;
private final String OIDC_APP_NAME = "playground23";
@@ -86,13 +84,9 @@ public static Object[][] configProvider() {
@Factory(dataProvider = "configProvider")
public PreferenceAPIIntegrationUITestCase(TestUserMode userMode) throws Exception {
- this.userMode = userMode;
super.init(userMode);
AutomationContext context = new AutomationContext("IDENTITY", userMode);
this.activeTenant = context.getContextTenant().getDomain();
- if (userMode == TestUserMode.SUPER_TENANT_ADMIN) {
- changeISConfiguration();
- }
}
@BeforeClass(alwaysRun = true)
@@ -126,9 +120,6 @@ private void createOIDCApplication() throws Exception {
public void atEnd() throws Exception {
adminClient.removeOAuthApplicationData(oidcAppClientId);
- if (userMode == TestUserMode.SUPER_TENANT_ADMIN) {
- restoreDefaultConfig();
- }
}
@AfterMethod
@@ -182,16 +173,6 @@ public void testNotificationPasswordRecovery() throws Exception {
Assert.assertTrue(content.contains(RECOVERY_PASSWORD_CONTENT));
}
- @Test(groups = "wso2.is", description = "Check Password recovery option recovery Page")
- public void testRecovery() throws Exception {
-
- updateResidentIDPProperty(superTenantResidentIDP, ENABLE_PASSWORD_NOTIFICATION_RECOVERY_PROP_KEY, "true");
- updateResidentIDPProperty(superTenantResidentIDP, ENABLE_PASSWORD_QS_RECOVERY_PROP_KEY, "true");
- String content = sendRecoveryRequest();
- Assert.assertTrue(content.contains(RECOVERY_ENDPOINT_QS_CONTENT));
- Assert.assertTrue(content.contains(RECOVERY_ENDPOINT_NOTIFICATION_CONTENT));
- }
-
@Test(groups = "wso2.is", description = "Check QS recovery option recovery Page")
public void testRecoveryQSOnly() throws Exception {
@@ -259,20 +240,4 @@ private String sendRecoveryRequest() throws IOException {
Assert.assertNotNull(content);
return content;
}
-
- private void restoreDefaultConfig() throws IOException, AutomationUtilException {
- serverConfigurationManager.restoreToLastConfiguration(false);
- }
-
- private void changeISConfiguration() throws Exception {
- super.init();
- String carbonHome = Utils.getResidentCarbonHome();
- File defaultConfigFile = getDeploymentTomlFile(carbonHome);
- File challengeQuestionsConfigFile = new File(
- getISResourceLocation() + File.separator + "challenge-questions" + File.separator + ADD_CHALLENGE_QUESTIONS_CONFIG);
- serverConfigurationManager = new ServerConfigurationManager(isServer);
- serverConfigurationManager.applyConfigurationWithoutRestart(challengeQuestionsConfigFile, defaultConfigFile, true);
- serverConfigurationManager.restartGracefully();
- super.init();
- }
}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml b/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml
index 8443e92944a..5ac345d3acc 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml
+++ b/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml
@@ -91,6 +91,7 @@
+
@@ -350,7 +351,7 @@
-
+
From 592f8f444dce870daa756c3c7b391e4a9603d12b Mon Sep 17 00:00:00 2001
From: asha15 <165079T@uom.lk>
Date: Wed, 7 Feb 2024 06:46:52 +0530
Subject: [PATCH 08/11] remove unwanted imports
---
.../test/idp/mgt/PreferenceAPIIntegrationUITestCase.java | 5 -----
1 file changed, 5 deletions(-)
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
index 54ccd99ed1f..504096b8563 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/PreferenceAPIIntegrationUITestCase.java
@@ -35,16 +35,12 @@
import org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider;
import org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty;
import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO;
-import org.wso2.carbon.integration.common.utils.exceptions.AutomationUtilException;
-import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager;
import org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient;
import org.wso2.identity.integration.common.clients.oauth.OauthAdminClient;
import org.wso2.identity.integration.test.oauth2.OAuth2ServiceAbstractIntegrationTest;
-import org.wso2.identity.integration.test.util.Utils;
import org.wso2.identity.integration.test.utils.DataExtractUtil;
import org.wso2.identity.integration.test.utils.OAuth2Constant;
-import java.io.File;
import java.io.IOException;
import static org.wso2.identity.integration.test.utils.CommonConstants.DEFAULT_TOMCAT_PORT;
@@ -69,7 +65,6 @@ public class PreferenceAPIIntegrationUITestCase extends OAuth2ServiceAbstractInt
private IdentityProvider superTenantResidentIDP;
private IdentityProviderMgtServiceClient superTenantIDPMgtClient;
- private ServerConfigurationManager serverConfigurationManager;
private String recoveryEndpoint;
private final String activeTenant;
private final String OIDC_APP_NAME = "playground23";
From 362ebf5dd6201d50dfc0168f35d44aa4e7c176dc Mon Sep 17 00:00:00 2001
From: asha15 <165079T@uom.lk>
Date: Wed, 7 Feb 2024 10:27:06 +0530
Subject: [PATCH 09/11] change the access modifier of
ADD_CHALLENGE_QUESTIONS_CONFIG string
---
.../integration/test/idp/mgt/ChallengeQuestionsUITestCase.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ChallengeQuestionsUITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ChallengeQuestionsUITestCase.java
index 582657e4ca8..7b3d92f21fd 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ChallengeQuestionsUITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ChallengeQuestionsUITestCase.java
@@ -45,7 +45,7 @@
public class ChallengeQuestionsUITestCase extends OAuth2ServiceAbstractIntegrationTest {
- public static final String ADD_CHALLENGE_QUESTIONS_CONFIG = "challenge_questions_config.toml";
+ private static final String ADD_CHALLENGE_QUESTIONS_CONFIG = "challenge_questions_config.toml";
private static final String RECOVERY_ENDPOINT_URL = "/accountrecoveryendpoint/recoveraccountrouter.do";
private static final String RECOVERY_ENDPOINT_QS_CONTENT = "name=\"recoveryOption\" value=\"SECURITY_QUESTIONS\"";
private static final String RECOVERY_ENDPOINT_NOTIFICATION_CONTENT = "name=\"recoveryOption\" value=\"EMAIL\"";
From facd2f58dd3e2f4837888fa12b94ce1466559b95 Mon Sep 17 00:00:00 2001
From: asha15 <165079T@uom.lk>
Date: Wed, 7 Feb 2024 10:39:58 +0530
Subject: [PATCH 10/11] fix typo in OIDC app name
---
.../integration/test/idp/mgt/ChallengeQuestionsUITestCase.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ChallengeQuestionsUITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ChallengeQuestionsUITestCase.java
index 7b3d92f21fd..dc08cf41831 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ChallengeQuestionsUITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ChallengeQuestionsUITestCase.java
@@ -52,7 +52,7 @@ public class ChallengeQuestionsUITestCase extends OAuth2ServiceAbstractIntegrati
private static final String ENABLE_PASSWORD_QS_RECOVERY_PROP_KEY = "Recovery.Question.Password.Enable";
private static final String ENABLE_PASSWORD_NOTIFICATION_RECOVERY_PROP_KEY =
"Recovery.Notification.Password.Enable";
- private final String OIDC_APP_NAME = "playground23";
+ private final String OIDC_APP_NAME = "playground2";
private IdentityProvider superTenantResidentIDP;
private ServerConfigurationManager serverConfigurationManager;
private IdentityProviderMgtServiceClient superTenantIDPMgtClient;
From 5f3c24682b23c011d1be7bad48c852ee9cf290ac Mon Sep 17 00:00:00 2001
From: asha15 <165079T@uom.lk>
Date: Wed, 7 Feb 2024 10:49:41 +0530
Subject: [PATCH 11/11] make OIDC_APP_NAME static
---
.../integration/test/idp/mgt/ChallengeQuestionsUITestCase.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ChallengeQuestionsUITestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ChallengeQuestionsUITestCase.java
index dc08cf41831..f3211f14d33 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ChallengeQuestionsUITestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/idp/mgt/ChallengeQuestionsUITestCase.java
@@ -52,7 +52,7 @@ public class ChallengeQuestionsUITestCase extends OAuth2ServiceAbstractIntegrati
private static final String ENABLE_PASSWORD_QS_RECOVERY_PROP_KEY = "Recovery.Question.Password.Enable";
private static final String ENABLE_PASSWORD_NOTIFICATION_RECOVERY_PROP_KEY =
"Recovery.Notification.Password.Enable";
- private final String OIDC_APP_NAME = "playground2";
+ private static final String OIDC_APP_NAME = "playground2";
private IdentityProvider superTenantResidentIDP;
private ServerConfigurationManager serverConfigurationManager;
private IdentityProviderMgtServiceClient superTenantIDPMgtClient;