From 5b52cefe64cfb59b92b7e3a009e8217d992335be Mon Sep 17 00:00:00 2001 From: ThaminduDilshan Date: Fri, 6 Oct 2023 15:18:30 +0530 Subject: [PATCH] Modify client ID tenant unification tests to handle default config enabling --- .../OAuthAppsWithSameClientIdTestCase.java | 27 ++----------- ...alified_url_tenanted_sessions_default.toml | 39 ------------------- ...ified_url_tenanted_sessions_disabled.toml} | 4 +- 3 files changed, 6 insertions(+), 64 deletions(-) delete mode 100644 modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/tenant.qualified/tenant_qualified_url_tenanted_sessions_default.toml rename modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/tenant.qualified/{tenant_qualified_url_tenanted_sessions_enabled.toml => tenant_qualified_url_tenanted_sessions_disabled.toml} (93%) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuthAppsWithSameClientIdTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuthAppsWithSameClientIdTestCase.java index 26a3dfe7720..f8e8dd5d54c 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuthAppsWithSameClientIdTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuthAppsWithSameClientIdTestCase.java @@ -108,7 +108,6 @@ public class OAuthAppsWithSameClientIdTestCase extends OAuth2ServiceAbstractInte private SCIM2RestClient scim2RestClientTenant2; private HttpClient client; - private boolean configurationsRestored = false; private String tenant1UserId = null; private String tenant2UserId = null; private String sessionDataKey; @@ -121,10 +120,6 @@ private void testInit() throws Exception { super.init(); serverConfigurationManager = new ServerConfigurationManager(isServer); - - // Enable tenant qualified urls/ tenanted sessions and restart the server. - changeISConfigurations(); - tenantMgtRestClient = new TenantMgtRestClient(serverURL, tenantInfo); // Create the test tenants. @@ -159,7 +154,7 @@ private void testInit() throws Exception { @AfterClass(alwaysRun = true) public void testClear() throws IOException, AutomationUtilException { - restoreISConfigurations(); + serverConfigurationManager.restoreToLastConfiguration(true); tenantMgtRestClient.closeHttpClient(); oAuth2RestClientTenant1.closeHttpClient(); oAuth2RestClientTenant2.closeHttpClient(); @@ -388,8 +383,8 @@ public void testOAuthApplicationLoginIncorrectTenant() throws Exception { dependsOnMethods = "testOAuthApplicationLoginIncorrectTenant") public void testOAuthApplicationLoginWhenTenantQualifiedUrlsDisabled() throws Exception { - // Restore the server back to the initial state (tenant qualified urls disabled). - restoreISConfigurations(); + // Disable tenant qualified urls/ tenanted sessions and restart the server. + changeISConfigurations(); // Create oauth app and add user. ApplicationResponseModel tenant1App = createApplication(TENANT_1_DOMAIN); @@ -411,22 +406,8 @@ private void changeISConfigurations() throws AutomationUtilException, IOExceptio File defaultTomlFile = getDeploymentTomlFile(carbonHome); File modifiedConfigFile = new File(getISResourceLocation() + File.separator + "tenant.qualified" + File.separator - + "tenant_qualified_url_tenanted_sessions_enabled.toml"); - serverConfigurationManager.applyConfiguration(modifiedConfigFile, defaultTomlFile, true, true); - } - - private void restoreISConfigurations() throws AutomationUtilException, IOException { - - if (configurationsRestored) { - return; - } - String carbonHome = Utils.getResidentCarbonHome(); - File defaultTomlFile = getDeploymentTomlFile(carbonHome); - File modifiedConfigFile = new File(getISResourceLocation() - + File.separator + "tenant.qualified" + File.separator - + "tenant_qualified_url_tenanted_sessions_default.toml"); + + "tenant_qualified_url_tenanted_sessions_disabled.toml"); serverConfigurationManager.applyConfiguration(modifiedConfigFile, defaultTomlFile, true, true); - configurationsRestored = true; } private void addTenant(String tenantDomain, String adminUsername, String adminPassword, diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/tenant.qualified/tenant_qualified_url_tenanted_sessions_default.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/tenant.qualified/tenant_qualified_url_tenanted_sessions_default.toml deleted file mode 100644 index 2a6ee115a7e..00000000000 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/tenant.qualified/tenant_qualified_url_tenanted_sessions_default.toml +++ /dev/null @@ -1,39 +0,0 @@ -[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.jks" -password = "wso2carbon" - -[truststore] -file_name = "client-truststore.jks" -password = "wso2carbon" -type = "JKS" - -[account_recovery.endpoint.auth] -hash = "66cd9688a2ae068244ea01e70f0e230f5623b7fa4cdecb65070a09ec06452262" - -[identity.auth_framework.endpoint] -app_password = "dashboard" diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/tenant.qualified/tenant_qualified_url_tenanted_sessions_enabled.toml b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/tenant.qualified/tenant_qualified_url_tenanted_sessions_disabled.toml similarity index 93% rename from modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/tenant.qualified/tenant_qualified_url_tenanted_sessions_enabled.toml rename to modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/tenant.qualified/tenant_qualified_url_tenanted_sessions_disabled.toml index 8dfe125c8c8..b4a20b941b7 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/tenant.qualified/tenant_qualified_url_tenanted_sessions_enabled.toml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/artifacts/IS/tenant.qualified/tenant_qualified_url_tenanted_sessions_disabled.toml @@ -39,5 +39,5 @@ hash = "66cd9688a2ae068244ea01e70f0e230f5623b7fa4cdecb65070a09ec06452262" app_password = "dashboard" [tenant_context] -enable_tenant_qualified_urls = true -enable_tenanted_sessions = true +enable_tenant_qualified_urls = false +enable_tenanted_sessions = false