Skip to content

Commit

Permalink
Change the client ID tenant unification test order
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaminduDilshan committed Oct 3, 2023
1 parent dfec624 commit 3408448
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ private void testInit() throws Exception {
@AfterClass(alwaysRun = true)
public void testClear() throws IOException, AutomationUtilException {

if (!configurationsRestored) {
serverConfigurationManager.restoreToLastConfiguration(true);
}
restoreISConfigurations();
tenantMgtRestClient.closeHttpClient();
oAuth2RestClientTenant1.closeHttpClient();
oAuth2RestClientTenant2.closeHttpClient();
Expand All @@ -188,7 +186,7 @@ public void afterMethod() throws IOException {
accessToken = null;
}

@Test(description = "Create two OAuth apps in the same tenant with same client id.", priority = 0)
@Test(description = "Create two OAuth apps in the same tenant with same client id.")
public void testCreateAppsWithSameClientIdInSameTenant() throws Exception {

// Create first app.
Expand All @@ -200,7 +198,8 @@ public void testCreateAppsWithSameClientIdInSameTenant() throws Exception {
Assert.assertEquals(statusLine.getStatusCode(), HttpStatus.SC_CONFLICT, "Expected status code not received.");
}

@Test(description = "Create two OAuth apps in two tenants with the same client id.", priority = 1)
@Test(description = "Create two OAuth apps in two tenants with the same client id.",
dependsOnMethods = "testCreateAppsWithSameClientIdInSameTenant")
public void testCreateAppsWithSameClientIdInMultipleTenants() throws Exception {

// Create oauth apps in both tenants.
Expand All @@ -222,7 +221,7 @@ public void testCreateAppsWithSameClientIdInMultipleTenants() throws Exception {
}

@Test(description = "Create two OAuth apps in two tenants with the same client id and retrieve " +
"tenant app by client id.", priority = 2)
"tenant app by client id.", dependsOnMethods = "testCreateAppsWithSameClientIdInMultipleTenants")
public void testRetrieveTenantAppByClientId() throws JSONException, IOException {

// Create oauth apps in both tenants.
Expand All @@ -241,7 +240,7 @@ public void testRetrieveTenantAppByClientId() throws JSONException, IOException
}

@Test(description = "Create two OAuth apps in two tenants with the same client id and update " +
"inbound configurations of one app.", priority = 3)
"inbound configurations of one app.", dependsOnMethods = "testRetrieveTenantAppByClientId")
public void testCreateAppsAndUpdateInboundConfigurationsOfOne() throws Exception {

// Create oauth apps in both tenants.
Expand Down Expand Up @@ -292,7 +291,7 @@ public void testCreateAppsAndUpdateInboundConfigurationsOfOne() throws Exception
}

@Test(description = "Create two OAuth apps in two tenants with the same client id and delete an app " +
"in one tenant.", priority = 4)
"in one tenant.", dependsOnMethods = "testCreateAppsAndUpdateInboundConfigurationsOfOne")
public void testCreateAppsAndDeleteOne() throws Exception {

// Create oauth apps in both tenants.
Expand All @@ -312,7 +311,7 @@ public void testCreateAppsAndDeleteOne() throws Exception {
}

@Test(description = "Create two OAuth apps in two tenants with the same client id and delete " +
"inbound configurations of one app.", priority = 5)
"inbound configurations of one app.", dependsOnMethods = "testCreateAppsAndDeleteOne")
public void testCreateAppsAndDeleteInboundConfigurationsOfOne() throws Exception {

// Create oauth apps in both tenants.
Expand Down Expand Up @@ -343,7 +342,7 @@ public void testCreateAppsAndDeleteInboundConfigurationsOfOne() throws Exception
}

@Test(description = "Create two OAuth apps in two tenants with the same client id and try to login " +
"with the user for the tenant.", priority = 6)
"with the user for the tenant.", dependsOnMethods = "testCreateAppsAndDeleteInboundConfigurationsOfOne")
public void testOAuthApplicationLoginSuccess() throws Exception {

// Create oauth apps in both tenants.
Expand All @@ -365,7 +364,8 @@ public void testOAuthApplicationLoginSuccess() throws Exception {
}

@Test(description = "Create two OAuth apps in two tenants with the same client id and try to login " +
"with the user from the other tenant.", priority = 7, expectedExceptions = AssertionError.class)
"with the user from the other tenant.", dependsOnMethods = "testOAuthApplicationLoginSuccess",
expectedExceptions = AssertionError.class)
public void testOAuthApplicationLoginIncorrectTenant() throws Exception {

// Create oauth apps in both tenants.
Expand All @@ -385,12 +385,11 @@ public void testOAuthApplicationLoginIncorrectTenant() throws Exception {
}

@Test(description = "Create an OAuth app in tenant 1 and try to login when tenant qualified urls are disabled.",
priority = 8)
dependsOnMethods = "testOAuthApplicationLoginIncorrectTenant")
public void testOAuthApplicationLoginWhenTenantQualifiedUrlsDisabled() throws Exception {

// Restore the server back to the initial state (tenant qualified urls disabled).
serverConfigurationManager.restoreToLastConfiguration(true);
configurationsRestored = true;
restoreISConfigurations();

// Create oauth app and add user.
ApplicationResponseModel tenant1App = createApplication(TENANT_1_DOMAIN);
Expand All @@ -416,6 +415,20 @@ private void changeISConfigurations() throws AutomationUtilException, IOExceptio
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");
serverConfigurationManager.applyConfiguration(modifiedConfigFile, defaultTomlFile, true, true);
configurationsRestored = 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,39 @@
[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"
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
<class name="org.wso2.identity.integration.test.oauth2.OAuth2ScopesTestCase"/>
<class name="org.wso2.identity.integration.test.oauth2.OAuth2XACMLScopeValidatorTestCase"/>
<class name="org.wso2.identity.integration.test.oauth2.PermissionBasedScopeValidatorTestCase"/>
<class name="org.wso2.identity.integration.test.oauth2.OAuthAppsWithSameClientIdTestCase"/>
<class name="org.wso2.identity.integration.test.oidc.OIDCAuthzCodeIdTokenValidationTestCase"/>
<class name="org.wso2.identity.integration.test.oidc.OIDCSPWiseSkipLoginConsentTestCase"/>

Expand Down Expand Up @@ -347,6 +346,7 @@
<class name="org.wso2.identity.integration.test.rest.api.user.liteUserRegister.LiteUserRegisterTestCase"/>
<class name="org.wso2.identity.integration.test.oauth2.OAuth2TokenScopeValidatorTestCase" />
<class name="org.wso2.identity.integration.test.saml.SAMLSSOForAdminLoginTestCase"/>
<class name="org.wso2.identity.integration.test.oauth2.OAuthAppsWithSameClientIdTestCase"/>
</classes>
</test>

Expand Down

0 comments on commit 3408448

Please sign in to comment.