diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/action/management/v1/ActionsFailureTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/action/management/v1/ActionsFailureTest.java index ba2ee638790..ba3094badae 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/action/management/v1/ActionsFailureTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/action/management/v1/ActionsFailureTest.java @@ -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; @@ -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) { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/action/management/v1/ActionsSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/action/management/v1/ActionsSuccessTest.java index f438275cde4..6211f02cd37 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/action/management/v1/ActionsSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/action/management/v1/ActionsSuccessTest.java @@ -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; @@ -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); @@ -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); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/action/management/v1/ActionsTestBase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/action/management/v1/ActionsTestBase.java index 0770b8ae09f..3832d2f4a75 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/action/management/v1/ActionsTestBase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/action/management/v1/ActionsTestBase.java @@ -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; @@ -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"; @@ -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"); + } + } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/action/management/v1/model/AuthenticationTypeProperties.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/action/management/v1/model/AuthenticationTypeProperties.java deleted file mode 100644 index 48f7fec9257..00000000000 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/action/management/v1/model/AuthenticationTypeProperties.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.identity.integration.test.rest.api.server.action.management.v1.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import javax.validation.Valid; - -public class AuthenticationTypeProperties { - - private Map properties = null; - - /** - **/ - public AuthenticationTypeProperties properties(Map properties) { - - this.properties = properties; - return this; - } - - @ApiModelProperty(example = "{\"username\":\"auth_username\",\"password\":\"auth_username\"}", value = "") - @JsonProperty("properties") - @Valid - public Map getProperties() { - return properties; - } - public void setProperties(Map properties) { - this.properties = properties; - } - - public AuthenticationTypeProperties putPropertiesItem(String key, Object propertiesItem) { - if (this.properties == null) { - this.properties = new HashMap(); - } - this.properties.put(key, propertiesItem); - return this; - } - - @Override - public boolean equals(java.lang.Object o) { - - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - AuthenticationTypeProperties authenticationTypeProperties = (AuthenticationTypeProperties) o; - return Objects.equals(this.properties, authenticationTypeProperties.properties); - } - - @Override - public int hashCode() { - return Objects.hash(properties); - } - - @Override - public String toString() { - - StringBuilder sb = new StringBuilder(); - sb.append("class AuthenticationTypeProperties {\n"); - - sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - - if (o == null) { - return "null"; - } - return o.toString(); - } -} diff --git a/pom.xml b/pom.xml index d9ce5bf0e17..ee6c7ff0151 100755 --- a/pom.xml +++ b/pom.xml @@ -2456,7 +2456,7 @@ 2.0.17 - 1.2.257 + 1.3.0 1.3.45 5.5.9 @@ -2466,7 +2466,7 @@ 1.2.67 - 2.35.15 + 2.35.16 2.13.21 2.8.3 1.6.378