From 7f903d6347c3b9216fab324124a7aa0655a870a9 Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Tue, 21 Jan 2025 08:16:02 +0530 Subject: [PATCH] Fix integration tests. --- .../v1/AuthenticatorFailureTest.java | 14 ++++++++----- .../api/server/idp/v1/IdPFailureTest.java | 21 ++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/authenticator/management/v1/AuthenticatorFailureTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/authenticator/management/v1/AuthenticatorFailureTest.java index 9d9ffb4034..16224ed425 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/authenticator/management/v1/AuthenticatorFailureTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/authenticator/management/v1/AuthenticatorFailureTest.java @@ -137,9 +137,10 @@ public void createUserDefinedLocalAuthenticatorMissingEndpointProperty() throws } @Test(priority = 3) - public void createUserDefinedLocalAuthenticatorEmptyDisplayName() throws JsonProcessingException { + public void createUserDefinedLocalAuthenticatorTwoCharacterDisplayName() throws JsonProcessingException { - creationPayload.setDisplayName(""); + String displayName = "te"; + creationPayload.setDisplayName(displayName); String body = UserDefinedLocalAuthenticatorPayload.convertToJasonPayload(creationPayload); Response response = getResponseOfPost(AUTHENTICATOR_CUSTOM_API_BASE_PATH, body); response.then() @@ -148,7 +149,8 @@ public void createUserDefinedLocalAuthenticatorEmptyDisplayName() throws JsonPro .statusCode(HttpStatus.SC_BAD_REQUEST) .body("code", equalTo("AUT-60015")) .body("message", equalTo("Authenticator display name is invalid.")) - .body("description", equalTo("Value for displayName should not be empty or blank.")); + .body("description", equalTo(String.format( + "The provided authenticator name %s is not in the expected format ^.{3,}$.", displayName))); } @Test(priority = 4) @@ -266,7 +268,8 @@ public void updateUserDefinedLocalAuthenticatorMissingEndpointProperty() throws @Test(priority = 11) public void updateUserDefinedLocalAuthenticatorEmptyDisplayName() throws JsonProcessingException { - updatePayload.setDisplayName(""); + String displayName = ""; + updatePayload.setDisplayName(displayName); String body = UserDefinedLocalAuthenticatorPayload.convertToJasonPayload(updatePayload); Response response = getResponseOfPutWithNoFilter(AUTHENTICATOR_CUSTOM_API_BASE_PATH + PATH_SEPARATOR + customIdPId, body); @@ -276,7 +279,8 @@ public void updateUserDefinedLocalAuthenticatorEmptyDisplayName() throws JsonPro .statusCode(HttpStatus.SC_BAD_REQUEST) .body("code", equalTo("AUT-60015")) .body("message", equalTo("Authenticator display name is invalid.")) - .body("description", equalTo("Value for displayName should not be empty or blank.")); + .body("description", equalTo(String.format( + "The provided authenticator name %s is not in the expected format ^.{3,}$.", displayName))); } @Test(priority = 12) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPFailureTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPFailureTest.java index b8eb488e12..0f8a1a81b6 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPFailureTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPFailureTest.java @@ -69,7 +69,7 @@ public class IdPFailureTest extends IdPTestBase { private String idPId; private String idpCreatePayload; private static final String OIDC_IDP_ID = "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I"; - private static final String CONFLICTING_AUTH_NAME = "Y3VzdG9tX2NvbmZsaWN0QXV0aE5hbWU="; + private static final String CONFLICTING_AUTH_NAME = "Y3VzdG9tLWNvbmZsaWN0QXV0aE5hbWU="; @Factory(dataProvider = "restAPIUserConfigProvider") public IdPFailureTest(TestUserMode userMode) throws Exception { @@ -86,7 +86,6 @@ public void init() throws IOException { super.testInit(API_VERSION, swaggerDefinition, tenant); idpCreatePayload = readResource("add-idp-with-custom-fed-auth.json"); - createUserDefinedLocalAuthenticator(); } @AfterClass(alwaysRun = true) @@ -247,6 +246,7 @@ public void testAddIdPWithUserDefinedAuthenticatorWhenEndpointUriIsEmpty() throw @Test public void testAddIdPWithUserDefinedAuthenticatorWithExistingAuthName() throws IOException { + createUserDefinedLocalAuthenticator(); UserDefinedAuthenticatorPayload userDefAuthPayload = createUserDefinedAuthenticatorPayload( CONFLICTING_AUTH_NAME, "https://abc.com/authenticate", @@ -257,8 +257,10 @@ public void testAddIdPWithUserDefinedAuthenticatorWithExistingAuthName() throws .log().ifValidationFails() .assertThat() .statusCode(HttpStatus.SC_BAD_REQUEST) - .body("message", equalTo("Invalid Request")) - .body("description", equalTo("must match \"^https?://.+\"")); + .body("message", equalTo( + "Federated authenticator name custom-conflictAuthName is already taken.")) + .body("description", equalTo( + "Federated authenticator name custom-conflictAuthName is already taken.")); } @Test @@ -742,15 +744,18 @@ private String convertDuplicatedPropertiesToJson(Map properties, private void createUserDefinedLocalAuthenticator() throws JsonProcessingException { String body = "{\n" + - " \"name\": \"custom_conflictAuthName\",\n" + + " \"name\": \"custom-conflictAuthName\",\n" + " \"displayName\": \"Custom auth\",\n" + " \"isEnabled\": true,\n" + - " \"description\": \"The user defined custom local authenticator.\",\n" + + " \"authenticationType\": \"IDENTIFICATION\",\n" + " \"endpoint\": {\n" + " \"uri\": \"https://abc.com/token\",\n" + " \"authentication\": {\n" + - " \"type\": \"NONE\",\n" + - "\n" + + " \"type\": \"BASIC\",\n" + + " \"properties\": {\n" + + " \"username\": \"auth_username\",\n" + + " \"password\": \"auth_password\"\n" + + " }\n" + " }\n" + " }\n" + "}";