From a415f7537daecdc68f470dd27a704e668adfe6e7 Mon Sep 17 00:00:00 2001 From: Ashan Thamara Palihakkara <75057725+ashanthamara@users.noreply.github.com> Date: Thu, 5 Sep 2024 00:15:38 +0530 Subject: [PATCH] Modify Action Management Rest Api tests for not implemented action types --- .../management/v1/ActionsFailureTest.java | 57 +++++-------------- .../management/v1/ActionsSuccessTest.java | 9 +-- .../action/management/v1/ActionsTestBase.java | 11 +++- pom.xml | 2 +- 4 files changed, 26 insertions(+), 53 deletions(-) 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 f10cbc699b8..bb705ee0fda 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 @@ -159,6 +159,21 @@ public void testCreateActionAfterReachingMaxActionCount() { } @Test(dependsOnMethods = {"testCreateActionAfterReachingMaxActionCount"}) + public void testCreateActionWithNotImplementedActionTypes() { + + for (String actionTypePath : NOT_IMPLEMENTED_ACTION_TYPE_PATHS) { + String body = toJSONString(action1); + Response responseOfPost = getResponseOfPost(ACTION_MANAGEMENT_API_BASE_PATH + + actionTypePath, body); + responseOfPost.then() + .log().ifValidationFails() + .assertThat().statusCode(HttpStatus.SC_NOT_IMPLEMENTED) + .body("description", equalTo("The requested action type is not currently " + + "supported by the server.")); + } + } + + @Test(dependsOnMethods = {"testCreateActionWithNotImplementedActionTypes"}) public void testUpdateActionWithInvalidID() { // Update Action basic information with an invalid action id. @@ -173,14 +188,6 @@ public void testUpdateActionWithInvalidID() { .assertThat().statusCode(HttpStatus.SC_NOT_FOUND) .body("description", equalTo("No Action is configured on the given Action Type and Id.")); - // Update Action basic information with correct Id and different action type. - getResponseOfPatch = getResponseOfPatch(ACTION_MANAGEMENT_API_BASE_PATH + - PRE_UPDATE_PASSWORD_PATH + "/" + testActionId2, body); - getResponseOfPatch.then() - .log().ifValidationFails() - .assertThat().statusCode(HttpStatus.SC_NOT_FOUND) - .body("description", equalTo("No Action is configured on the given Action Type and Id.")); - // Update Action Endpoint Authentication Properties with an invalid action id. AuthenticationTypeProperties authenticationType = new AuthenticationTypeProperties() .properties(new HashMap() {{ @@ -194,14 +201,6 @@ public void testUpdateActionWithInvalidID() { .log().ifValidationFails() .assertThat().statusCode(HttpStatus.SC_NOT_FOUND) .body("description", equalTo("No Action is configured on the given Action Type and Id.")); - - // Update Action Endpoint Authentication Properties with correct Id and different action type. - responseOfPut = getResponseOfPut(ACTION_MANAGEMENT_API_BASE_PATH + - PRE_UPDATE_PASSWORD_PATH + "/" + testActionId2 + ACTION_BEARER_AUTH_PATH, body); - responseOfPut.then() - .log().ifValidationFails() - .assertThat().statusCode(HttpStatus.SC_NOT_FOUND) - .body("description", equalTo("No Action is configured on the given Action Type and Id.")); } @Test(dependsOnMethods = {"testUpdateActionWithInvalidID"}) @@ -251,15 +250,6 @@ public void testActivateActionWithInvalidID() { .assertThat() .statusCode(HttpStatus.SC_NOT_FOUND) .body("description", equalTo("No Action is configured on the given Action Type and Id.")); - - // With correct Id and different action type. - getResponseOfPost(ACTION_MANAGEMENT_API_BASE_PATH + PRE_UPDATE_PASSWORD_PATH + - "/" + testActionId2 + ACTION_ACTIVATE_PATH, "") - .then() - .log().ifValidationFails() - .assertThat() - .statusCode(HttpStatus.SC_NOT_FOUND) - .body("description", equalTo("No Action is configured on the given Action Type and Id.")); } @Test(dependsOnMethods = {"testActivateActionWithInvalidID"}) @@ -272,15 +262,6 @@ public void testDeactivateActionWithInvalidID() { .assertThat() .statusCode(HttpStatus.SC_NOT_FOUND) .body("description", equalTo("No Action is configured on the given Action Type and Id.")); - - // With correct Id and different action type. - getResponseOfPost(ACTION_MANAGEMENT_API_BASE_PATH + PRE_UPDATE_PASSWORD_PATH + - "/" + testActionId2 + ACTION_DEACTIVATE_PATH, "") - .then() - .log().ifValidationFails() - .assertThat() - .statusCode(HttpStatus.SC_NOT_FOUND) - .body("description", equalTo("No Action is configured on the given Action Type and Id.")); } @Test(dependsOnMethods = {"testDeactivateActionWithInvalidID"}) @@ -294,14 +275,6 @@ public void testDeleteActionWithInvalidID() { .statusCode(HttpStatus.SC_NOT_FOUND) .body("description", equalTo("No Action is configured on the given Action Type and Id.")); - getResponseOfDelete(ACTION_MANAGEMENT_API_BASE_PATH + PRE_UPDATE_PASSWORD_PATH + - "/" + testActionId2) - .then() - .log().ifValidationFails() - .assertThat() - .statusCode(HttpStatus.SC_NOT_FOUND) - .body("description", equalTo("No Action is configured on the given Action Type and Id.")); - // Delete, created action. deleteAction(PRE_ISSUE_ACCESS_TOKEN_PATH , testActionId2); } 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 8f6d5edbfc6..1e51aa627aa 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 @@ -145,14 +145,7 @@ public void testGetActions() { notNullValue()) .body( "find { it.type == '" + PRE_ISSUE_ACCESS_TOKEN_ACTION_TYPE + "' }.count", equalTo(1)) - .body( "find { it.type == '" + PRE_ISSUE_ACCESS_TOKEN_ACTION_TYPE + "' }.self", notNullValue()) - .body( "find { it.type == '" + PRE_UPDATE_PASSWORD_ACTION_TYPE + "' }.displayName", - notNullValue()) - .body( "find { it.type == '" + PRE_UPDATE_PASSWORD_ACTION_TYPE + "' }.description", - notNullValue()) - .body( "find { it.type == '" + PRE_UPDATE_PASSWORD_ACTION_TYPE + "' }.count", - equalTo(0)) - .body( "find { it.type == '" + PRE_UPDATE_PASSWORD_ACTION_TYPE + "' }.self", notNullValue()); + .body( "find { it.type == '" + PRE_ISSUE_ACCESS_TOKEN_ACTION_TYPE + "' }.self", notNullValue()); } @Test(dependsOnMethods = {"testGetActions"}) 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 bd840486b2d..f68c245a4fb 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 @@ -31,6 +31,8 @@ import org.wso2.identity.integration.test.rest.api.server.common.RESTAPIServerTestBase; import java.io.IOException; +import java.util.HashSet; +import java.util.Set; public class ActionsTestBase extends RESTAPIServerTestBase { @@ -40,14 +42,12 @@ public class ActionsTestBase extends RESTAPIServerTestBase { protected static final String ACTION_MANAGEMENT_API_BASE_PATH = "/actions"; protected static final String TYPES_API_PATH = "/types"; protected static final String PRE_ISSUE_ACCESS_TOKEN_PATH = "/preIssueAccessToken"; - protected static final String PRE_UPDATE_PASSWORD_PATH = "/preUpdatePassword"; 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"; - protected static final String PRE_UPDATE_PASSWORD_ACTION_TYPE = "PRE_UPDATE_PASSWORD"; protected static final String TEST_ACTION_NAME = "Access Token Pre Issue"; protected static final String TEST_ACTION_DESCRIPTION = "This is the configuration of pre-action for issuing access token."; @@ -72,9 +72,16 @@ public class ActionsTestBase extends RESTAPIServerTestBase { protected static final String TEST_APIKEY_VALUE_AUTH_PROPERTY = "value"; protected static final String TEST_APIKEY_VALUE_AUTH_PROPERTY_VALUE = "secret"; + protected static final Set NOT_IMPLEMENTED_ACTION_TYPE_PATHS = new HashSet<>(); + protected static String swaggerDefinition; static { + NOT_IMPLEMENTED_ACTION_TYPE_PATHS.add("/preUpdatePassword"); + NOT_IMPLEMENTED_ACTION_TYPE_PATHS.add("/preUpdateProfile"); + NOT_IMPLEMENTED_ACTION_TYPE_PATHS.add("/preRegistration"); + NOT_IMPLEMENTED_ACTION_TYPE_PATHS.add("/authentication"); + String API_PACKAGE_NAME = "org.wso2.carbon.identity.api.server.action.management.v1"; try { swaggerDefinition = getAPISwaggerDefinition(API_PACKAGE_NAME, API_DEFINITION_NAME); diff --git a/pom.xml b/pom.xml index 7948f4e9c65..7634823302f 100755 --- a/pom.xml +++ b/pom.xml @@ -2436,7 +2436,7 @@ 2.0.17 1.3.39 - 1.2.225 + 1.2.226 5.5.9 5.5.9