Skip to content

Commit

Permalink
Merge pull request #17448 from dewniMW/i-test
Browse files Browse the repository at this point in the history
Modify organization management integration tests
  • Loading branch information
dewniMW authored Oct 31, 2023
2 parents 59339f2 + 5c5bb31 commit ad25e90
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.hamcrest.Matcher;
import org.wso2.carbon.automation.engine.context.AutomationContext;
import org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient;
import org.wso2.identity.integration.test.restclients.OAuth2RestClient;

import java.rmi.RemoteException;
import java.util.ResourceBundle;
Expand All @@ -38,7 +39,7 @@
*/
public class B2BRESTTestBase extends RESTTestBase {

protected static final String ORGANIZATION_CONTEXT_IN_URL = "/o/%s";
protected static final String TENANT_CONTEXT_IN_ORG_URL = "/t/%s/o";
protected static final String SERVICES = "/services";
private static ResourceBundle errorProperties = ResourceBundle.getBundle("RESTAPIErrors");

Expand All @@ -48,6 +49,7 @@ public class B2BRESTTestBase extends RESTTestBase {
protected AutomationContext context;

protected RemoteUserStoreManagerServiceClient remoteUSMServiceClient;
protected OAuth2RestClient oAuth2RestClient;
protected String swaggerDefinition;

protected String basePath = StringUtils.EMPTY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@
public class B2BRESTAPIServerTestBase extends B2BRESTTestBase {

protected static final String API_SERVER_BASE_PATH = "/api/server/%s";
protected static final String API_SERVER_BASE_PATH_IN_SWAGGER = "/o/\\{organization-domain\\}" +
protected static final String API_SERVER_BASE_PATH_IN_SWAGGER = "/t/\\{tenant-domain\\}" +
API_SERVER_BASE_PATH;
protected static final String API_SERVER_BASE_PATH_WITH_ORGANIZATION_CONTEXT =
ORGANIZATION_CONTEXT_IN_URL + API_SERVER_BASE_PATH;
protected static final String API_SERVER_BASE_PATH_WITH_TENANT_CONTEXT =
TENANT_CONTEXT_IN_ORG_URL + API_SERVER_BASE_PATH;

protected void testInit(String apiVersion, String apiDefinition, String organizationID) throws RemoteException {
protected void testInit(String apiVersion, String apiDefinition, String tenantDomain) throws RemoteException {

String basePathInSwagger = String.format(API_SERVER_BASE_PATH_IN_SWAGGER, apiVersion);
String basePath = String.format(API_SERVER_BASE_PATH_WITH_ORGANIZATION_CONTEXT,
organizationID, apiVersion);
String basePath = String.format(API_SERVER_BASE_PATH_WITH_TENANT_CONTEXT,
tenantDomain, apiVersion);
super.init(apiDefinition, basePathInSwagger, basePath);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.identity.integration.test.rest.api.server.common.B2BRESTAPIServerTestBase;
import org.wso2.identity.integration.test.rest.api.server.organization.management.v1.model.OrganizationLevel;
import org.wso2.identity.integration.test.utils.CarbonUtils;

import java.io.IOException;
import java.util.Set;
Expand All @@ -57,6 +58,7 @@ public class OrganizationManagementBaseTest extends B2BRESTAPIServerTestBase {
protected String subOrganizationId;
protected static final String ORGANIZATION_MANAGEMENT_API_BASE_PATH = "/organizations";
protected static String swaggerDefinition;
static boolean isLegacyRuntimeEnabled;

static {
String apiPackageName = "org.wso2.carbon.identity.api.server.organization.management.v1";
Expand All @@ -81,6 +83,7 @@ public OrganizationManagementBaseTest(TestUserMode userMode, OrganizationLevel o
public void init(ITestContext context) throws Exception {

ISuite suite = context.getSuite();
isLegacyRuntimeEnabled = CarbonUtils.isLegacyAuthzRuntimeEnabled();
String orgId = (String) suite.getAttribute("createdOrgId");
if (orgId == null) {
orgId = SUPER_ORGANIZATION_ID;
Expand All @@ -90,8 +93,9 @@ public void init(ITestContext context) throws Exception {
super.testInitWithoutTenantQualifiedPath(API_VERSION, swaggerDefinition);
} else {
this.tenant = subOrganizationId;
this.authenticatingUserName = "admin@" + SUPER_ORGANIZATION_ID;
super.testInit(API_VERSION, swaggerDefinition, tenant);
String tenantDomain = tenantInfo.getDomain();
this.authenticatingUserName = "admin@" + tenantDomain;
super.testInit(API_VERSION, swaggerDefinition, tenantDomain);
}
}

Expand All @@ -115,7 +119,7 @@ public void testInit(ITestContext context) throws Exception {
}

@AfterMethod(alwaysRun = true)
public void testFinish() {
public void testFinish() throws Exception{

RestAssured.basePath = StringUtils.EMPTY;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public OrganizationManagementFailureTest(TestUserMode userMode, OrganizationLeve

@AfterMethod(alwaysRun = true)
@Override
public void testFinish() {
public void testFinish() throws Exception {

super.testFinish();
}
Expand Down
Loading

0 comments on commit ad25e90

Please sign in to comment.