Skip to content

Commit

Permalink
Merge pull request #21061 from Shenali-SJ/actions-integration-tests
Browse files Browse the repository at this point in the history
Refactor the actionRestClient invoke implementation
  • Loading branch information
malithie committed Sep 5, 2024
2 parents 77b6486 + f7f828c commit 7053b98
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
public class ActionsBaseTestCase extends OAuth2ServiceAbstractIntegrationTest {

protected ActionsRestClient restClient;
protected ActionsRestClient actionsRestClient;

/**
* Initialize the test case.
Expand All @@ -44,7 +44,7 @@ protected void init(TestUserMode userMode) throws Exception {

super.init(userMode);

restClient = new ActionsRestClient(serverURL, tenantInfo);
actionsRestClient = new ActionsRestClient(serverURL, tenantInfo);

setSystemproperties();
}
Expand All @@ -59,7 +59,7 @@ protected void init(TestUserMode userMode) throws Exception {
*/
public String createAction(String actionType, ActionModel actionModel) throws IOException {

return restClient.createActionType(actionModel, actionType);
return actionsRestClient.createActionType(actionModel, actionType);
}

/**
Expand All @@ -72,6 +72,6 @@ public String createAction(String actionType, ActionModel actionModel) throws IO
*/
public int deleteAction(String actionType, String actionId) throws IOException {

return restClient.deleteActionType(actionType, actionId);
return actionsRestClient.deleteActionType(actionType, actionId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import org.wso2.identity.integration.test.rest.api.user.common.model.PatchOperationRequestObject;
import org.wso2.identity.integration.test.rest.api.user.common.model.RoleItemAddGroupobj;
import org.wso2.identity.integration.test.rest.api.user.common.model.UserObject;
import org.wso2.identity.integration.test.restclients.ActionsRestClient;
import org.wso2.identity.integration.test.restclients.SCIM2RestClient;
import org.wso2.identity.integration.test.utils.CarbonUtils;
import org.wso2.identity.integration.test.utils.OAuth2Constant;
Expand Down Expand Up @@ -171,8 +170,6 @@ protected boolean isRedirectable(String method) {
}).build();

scim2RestClient = new SCIM2RestClient(serverURL, tenantInfo);
restClient = new ActionsRestClient(serverURL, tenantInfo);
// TODO: Review if ActionsRestClient should be instantiated, or if the superclass initialization is sufficient

customScopes = Arrays.asList(CUSTOM_SCOPE_1, CUSTOM_SCOPE_2, CUSTOM_SCOPE_3);

Expand All @@ -198,13 +195,15 @@ protected boolean isRedirectable(String method) {
public void atEnd() throws Exception {

deleteAction(PRE_ISSUE_ACCESS_TOKEN_API_PATH, actionId);
restClient = null;
deleteRole(roleId);
deleteApp(applicationId);
deleteDomainAPI(domainAPIId);
scim2RestClient.deleteUser(userId);
scim2RestClient = null;
MockServer.shutDownMockServer();
restClient.closeHttpClient();
scim2RestClient.closeHttpClient();
actionsRestClient.closeHttpClient();
client.close();
accessToken = null;
jwtClaims = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.wso2.identity.integration.test.rest.api.user.common.model.PatchOperationRequestObject;
import org.wso2.identity.integration.test.rest.api.user.common.model.RoleItemAddGroupobj;
import org.wso2.identity.integration.test.rest.api.user.common.model.UserObject;
import org.wso2.identity.integration.test.restclients.ActionsRestClient;
import org.wso2.identity.integration.test.restclients.SCIM2RestClient;
import org.wso2.identity.integration.test.utils.CarbonUtils;
import org.wso2.identity.integration.test.utils.OAuth2Constant;
Expand Down Expand Up @@ -127,8 +126,6 @@ public void testInit() throws Exception {
super.init(TestUserMode.TENANT_USER);

scim2RestClient = new SCIM2RestClient(serverURL, tenantInfo);
restClient = new ActionsRestClient(serverURL, tenantInfo);
// TODO: Review if ActionsRestClient should be instantiated, or if the superclass initialization is sufficient

List<String> customScopes = Arrays.asList(CUSTOM_SCOPE_1, CUSTOM_SCOPE_2, CUSTOM_SCOPE_3);

Expand All @@ -154,13 +151,14 @@ public void testInit() throws Exception {
public void atEnd() throws Exception {

deleteAction(PRE_ISSUE_ACCESS_TOKEN_API_PATH, actionId);
restClient = null;
deleteRole(roleId);
deleteApp(applicationId);
deleteDomainAPI(domainAPIId);
scim2RestClient.deleteUser(userId);
scim2RestClient = null;
MockServer.shutDownMockServer();
restClient.closeHttpClient();
scim2RestClient.closeHttpClient();
actionsRestClient.closeHttpClient();
accessToken = null;
jwtClaims = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,14 @@ private Header[] getHeaders() {

return headerList;
}

/**
* Close the HTTP client.
*
* @throws IOException If an error occurred while closing the Http Client.
*/
public void closeHttpClient() throws IOException {

client.close();
}
}

0 comments on commit 7053b98

Please sign in to comment.