Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the actionRestClient invoke implementation #21061

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}