Skip to content

Commit

Permalink
Modify test to enable tenant qualified urls
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaminduDilshan committed Sep 19, 2023
1 parent b049692 commit de1d6b7
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.wso2.carbon.automation.engine.context.beans.User;
import org.wso2.carbon.integration.common.utils.exceptions.AutomationUtilException;
import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager;
import org.wso2.identity.integration.test.EmailOTPTestCase;
import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationListItem;
import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationListResponse;
import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationModel;
Expand All @@ -68,13 +69,16 @@
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 java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.xml.xpath.XPathExpressionException;

/**
* This class contains tests for OAuth apps with same client id in multiple tenants.
*/
Expand Down Expand Up @@ -118,9 +122,7 @@ private void testInit() throws Exception {

super.init();
serverConfigurationManager = new ServerConfigurationManager(isServer);

// TODO: See whether tenant qualified urls and tenanted sessions can be enabled with below method.
// serverConfigurationManager.applyConfiguration();
changeISConfigurations();

tenantMgtRestClient = new TenantMgtRestClient(serverURL, tenantInfo);

Expand Down Expand Up @@ -156,7 +158,7 @@ private void testInit() throws Exception {
@AfterClass(alwaysRun = true)
public void testClear() throws IOException, AutomationUtilException {

serverConfigurationManager.restoreToLastConfiguration(false);
serverConfigurationManager.restoreToLastConfiguration(true);
tenantMgtRestClient.closeHttpClient();
oAuth2RestClientTenant1.closeHttpClient();
oAuth2RestClientTenant2.closeHttpClient();
Expand Down Expand Up @@ -374,6 +376,16 @@ public void testOAuthApplicationLoginIncorrectTenant() throws Exception {
Assert.fail("Expected exception not received.");
}

private void changeISConfigurations() throws AutomationUtilException, IOException {

String carbonHome = Utils.getResidentCarbonHome();
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 addTenant(String tenantDomain, String adminUsername, String adminPassword,
String adminTenantAwareUsername) throws Exception {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[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"

[tenant_context]
enable_tenant_qualified_urls = true
enable_tenanted_sessions = true

0 comments on commit de1d6b7

Please sign in to comment.