Skip to content

Commit

Permalink
Merge pull request #16872 from ThaminduDilshan/thamindu-clientId
Browse files Browse the repository at this point in the history
Modify client ID tenant unification tests to handle new default behavior of tenant qualified URLs
  • Loading branch information
Thisara-Welmilla authored Oct 25, 2023
2 parents 30eb37a + 5b52cef commit 0001eda
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand Down

This file was deleted.

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

0 comments on commit 0001eda

Please sign in to comment.