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

Modify actions restapi tests #21870

Merged
merged 4 commits into from
Dec 2, 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,6 @@
import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.ActionModel;
import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.ActionUpdateModel;
import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.AuthenticationType;
import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.AuthenticationTypeProperties;
import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.Endpoint;

import java.io.IOException;
Expand Down Expand Up @@ -159,6 +158,18 @@ public void testCreateActionAfterReachingMaxActionCount() {
}

@Test(dependsOnMethods = {"testCreateActionAfterReachingMaxActionCount"})
public void testGetActionByActionIdWithInvalidID() {

Response responseOfGet = getResponseOfGet(ACTION_MANAGEMENT_API_BASE_PATH +
PRE_ISSUE_ACCESS_TOKEN_PATH + "/" + TEST_ACTION_INVALID_ID);

responseOfGet.then()
.log().ifValidationFails()
.assertThat().statusCode(HttpStatus.SC_NOT_FOUND)
.body("description", equalTo("No action is found for given action id and action type"));
}

@Test(dependsOnMethods = {"testGetActionByActionIdWithInvalidID"})
public void testCreateActionWithNotImplementedActionTypes() {

for (String actionTypePath : NOT_IMPLEMENTED_ACTION_TYPE_PATHS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.ActionModel;
import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.ActionUpdateModel;
import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.AuthenticationType;
import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.AuthenticationTypeProperties;
import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.Endpoint;
import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.EndpointUpdateModel;

Expand Down Expand Up @@ -113,7 +112,7 @@ public void testCreateAction() {
}

@Test(dependsOnMethods = {"testCreateAction"})
public void testGetActionByActionType() {
public void testGetActionsByActionType() {

Response responseOfGet = getResponseOfGet(ACTION_MANAGEMENT_API_BASE_PATH +
PRE_ISSUE_ACCESS_TOKEN_PATH);
Expand All @@ -124,14 +123,33 @@ public void testGetActionByActionType() {
.body( "find { it.id == '" + testActionId + "' }.name", equalTo(TEST_ACTION_NAME))
.body( "find { it.id == '" + testActionId + "' }.description", equalTo(TEST_ACTION_DESCRIPTION))
.body( "find { it.id == '" + testActionId + "' }.status", equalTo(TEST_ACTION_ACTIVE_STATUS))
.body( "find { it.id == '" + testActionId + "' }.endpoint.uri", equalTo(TEST_ENDPOINT_URI))
.body( "find { it.id == '" + testActionId + "' }.endpoint.authentication.type",
equalTo(AuthenticationType.TypeEnum.BASIC.toString()))
.body( "find { it.id == '" + testActionId + "' }.endpoint.authentication",
not(hasKey(TEST_PROPERTIES_AUTH_ATTRIBUTE)));
.body("find { it.id == '" + testActionId + "' }.links", notNullValue())
.body("find { it.id == '" + testActionId + "' }.links.find { it.rel == 'self' }.href",
equalTo(buildBaseURL() + ACTION_MANAGEMENT_API_BASE_PATH +
PRE_ISSUE_ACCESS_TOKEN_PATH + "/" + testActionId))
.body("find { it.id == '" + testActionId + "' }.links.find { it.rel == 'self' }.method",
equalTo("GET"));
}

@Test(dependsOnMethods = {"testGetActionByActionType"})
@Test(dependsOnMethods = {"testGetActionsByActionType"})
public void testGetActionByActionId() {

Response responseOfGet = getResponseOfGet(ACTION_MANAGEMENT_API_BASE_PATH +
PRE_ISSUE_ACCESS_TOKEN_PATH + "/" + testActionId);
responseOfGet.then()
.log().ifValidationFails()
.assertThat()
.statusCode(HttpStatus.SC_OK)
.body("id", equalTo(testActionId))
.body("name", equalTo(TEST_ACTION_NAME))
.body("description", equalTo(TEST_ACTION_DESCRIPTION))
.body("status", equalTo(TEST_ACTION_ACTIVE_STATUS))
.body("endpoint.uri", equalTo(TEST_ENDPOINT_URI))
.body("endpoint.authentication.type", equalTo(AuthenticationType.TypeEnum.BASIC.toString()))
.body("endpoint.authentication", not(hasKey(TEST_PROPERTIES_AUTH_ATTRIBUTE)));
}

@Test(dependsOnMethods = {"testGetActionByActionId"})
public void testGetActionTypes() {

Response responseOfGet = getResponseOfGet(ACTION_MANAGEMENT_API_BASE_PATH + TYPES_API_PATH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
import org.wso2.identity.integration.test.rest.api.server.common.RESTAPIServerTestBase;

import java.io.IOException;
Expand All @@ -44,8 +45,6 @@ public class ActionsTestBase extends RESTAPIServerTestBase {
protected static final String PRE_ISSUE_ACCESS_TOKEN_PATH = "/preIssueAccessToken";
protected static final String ACTION_DEACTIVATE_PATH = "/deactivate";
protected static final String ACTION_ACTIVATE_PATH = "/activate";
protected static final String ACTION_BEARER_AUTH_PATH = "/bearer";
protected static final String ACTION_BASIC_AUTH_PATH = "/basic";

protected static final String PRE_ISSUE_ACCESS_TOKEN_ACTION_TYPE = "PRE_ISSUE_ACCESS_TOKEN";

Expand Down Expand Up @@ -140,5 +139,19 @@ protected String toJSONString(Object object) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
return gson.toJson(object);
}

/**
* Build the base URL for the REST API.
*
* @return Base URL.
*/
public String buildBaseURL() {

if (this.tenant.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) {
return String.format(API_SERVER_BASE_PATH, "v1");
} else {
return "/t/" + this.tenant + String.format(API_SERVER_BASE_PATH, "v1");
}
}
}

This file was deleted.

4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2456,7 +2456,7 @@

<!-- Identity REST API feature -->
<identity.api.dispatcher.version>2.0.17</identity.api.dispatcher.version>
<identity.server.api.version>1.2.257</identity.server.api.version>
<identity.server.api.version>1.3.0</identity.server.api.version>
<identity.user.api.version>1.3.45</identity.user.api.version>

<identity.agent.sso.version>5.5.9</identity.agent.sso.version>
Expand All @@ -2466,7 +2466,7 @@
<conditional.authentication.functions.version>1.2.67</conditional.authentication.functions.version>

<!-- Identity Portal Versions -->
<identity.apps.console.version>2.35.15</identity.apps.console.version>
<identity.apps.console.version>2.35.16</identity.apps.console.version>
<identity.apps.myaccount.version>2.13.21</identity.apps.myaccount.version>
<identity.apps.core.version>2.8.3</identity.apps.core.version>
<identity.apps.tests.version>1.6.378</identity.apps.tests.version>
Expand Down