From 78e6075f89a662c2b0e37c09010295ba9e9f5568 Mon Sep 17 00:00:00 2001 From: Thisara-Welmilla Date: Thu, 19 Dec 2024 09:40:18 +0530 Subject: [PATCH] Add integration test to get user defined local authenticators. --- .../v1/AuthenticatorSuccessTest.java | 27 ++++++++++++++++--- .../management/v1/AuthenticatorTestBase.java | 3 ++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/authenticator/management/v1/AuthenticatorSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/authenticator/management/v1/AuthenticatorSuccessTest.java index e6bfb92b0c..6d12b2e34f 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/authenticator/management/v1/AuthenticatorSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/authenticator/management/v1/AuthenticatorSuccessTest.java @@ -164,7 +164,7 @@ public void testCreateUserDefinedLocalAuthenticator() throws JsonProcessingExcep .body("isEnabled", equalTo(true)) .body("tags", hasItem(CUSTOM_TAG)) .body("self", equalTo(getTenantedRelativePath( - AUTHENTICATOR_CONFIG_API_BASE_PATH + customIdPId, tenant))); + BASE_PATH + AUTHENTICATOR_CONFIG_API_BASE_PATH + customIdPId, tenant))); } @Test(dependsOnMethods = {"testCreateUserDefinedLocalAuthenticator"}) @@ -188,8 +188,8 @@ public void getUserDefinedLocalAuthenticators() throws JSONException { Assert.assertEquals(authenticator.getString("type"), "LOCAL"); Assert.assertTrue(authenticator.getBoolean("isEnabled")); Assert.assertTrue(authenticator.getString("tags").contains(CUSTOM_TAG)); - Assert.assertEquals(authenticator.getString("self"), - getTenantedRelativePath(AUTHENTICATOR_CONFIG_API_BASE_PATH + customIdPId, tenant)); + Assert.assertEquals(authenticator.getString("self"), getTenantedRelativePath( + BASE_PATH + AUTHENTICATOR_CONFIG_API_BASE_PATH + customIdPId, tenant)); } } Assert.assertTrue(isUserDefinedAuthenticatorFound); @@ -211,6 +211,25 @@ public void testValidateCustomTagInGetMetaTags() { } @Test(dependsOnMethods = {"testCreateUserDefinedLocalAuthenticator"}) + public void testGetUserDefinedLocalAuthenticator() { + + Response response = getResponseOfGet(AUTHENTICATOR_CONFIG_API_BASE_PATH + customIdPId); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_OK) + .header(HttpHeaders.LOCATION, notNullValue()) + .body("id", equalTo(customIdPId)) + .body("name", equalTo(AUTHENTICATOR_NAME)) + .body("displayName", equalTo(AUTHENTICATOR_DISPLAY_NAME)) + .body("type", equalTo("LOCAL")) + .body("definedBy", equalTo("USER")) + .body("isEnabled", equalTo(true)) + .body("endpoint.uri", equalTo(AUTHENTICATOR_ENDPOINT_URI)) + .body("endpoint.authentication", equalTo("Basic")); + } + + @Test(dependsOnMethods = {"testGetUserDefinedLocalAuthenticator"}) public void testUpdateUserDefinedLocalAuthenticator() throws JsonProcessingException { updatePayload.displayName(AUTHENTICATOR_DISPLAY_NAME + UPDATE_VALUE_POSTFIX); @@ -231,7 +250,7 @@ public void testUpdateUserDefinedLocalAuthenticator() throws JsonProcessingExcep .body("isEnabled", equalTo(false)) .body("tags", hasItem(CUSTOM_TAG)) .body("self", equalTo(getTenantedRelativePath( - AUTHENTICATOR_CONFIG_API_BASE_PATH + customIdPId, tenant))); + BASE_PATH + AUTHENTICATOR_CONFIG_API_BASE_PATH + customIdPId, tenant))); } @Test(dependsOnMethods = {"testValidateCustomTagInGetMetaTags", "testUpdateUserDefinedLocalAuthenticator"}) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/authenticator/management/v1/AuthenticatorTestBase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/authenticator/management/v1/AuthenticatorTestBase.java index 846eef15ea..546b013206 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/authenticator/management/v1/AuthenticatorTestBase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/authenticator/management/v1/AuthenticatorTestBase.java @@ -41,10 +41,11 @@ public class AuthenticatorTestBase extends RESTAPIServerTestBase { protected static final String API_VERSION = "v1"; protected static final String API_PACKAGE_NAME = "org.wso2.carbon.identity.api.server.authenticators.v1"; + protected static final String BASE_PATH = "/api/server/v1"; protected static final String AUTHENTICATOR_API_BASE_PATH = "/authenticators"; protected static final String AUTHENTICATOR_META_TAGS_PATH = "/authenticators/meta/tags"; protected static final String AUTHENTICATOR_CUSTOM_API_BASE_PATH = "/authenticators/custom"; - protected static final String AUTHENTICATOR_CONFIG_API_BASE_PATH = "/api/server/v1/configs/authenticators/"; + protected static final String AUTHENTICATOR_CONFIG_API_BASE_PATH = "/configs/authenticators/"; protected static final String PATH_SEPARATOR = "/"; protected final String AUTHENTICATOR_NAME = "customAuthenticator";