From 297bdaa63c97c6e8d4210b8ec48f2bafaa1037c3 Mon Sep 17 00:00:00 2001 From: Thumimku Date: Thu, 1 Feb 2024 09:15:56 +0530 Subject: [PATCH] add basic authenticator --- ...plicationNativeAuthenticationTestCase.java | 21 +++++++++++++++++++ .../Constants.java | 4 ++++ .../src/test/resources/testng.xml | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/applicationNativeAuthentication/ApplicationNativeAuthenticationTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/applicationNativeAuthentication/ApplicationNativeAuthenticationTestCase.java index fe2694f6cd5..594481d80a2 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/applicationNativeAuthentication/ApplicationNativeAuthenticationTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/applicationNativeAuthentication/ApplicationNativeAuthenticationTestCase.java @@ -49,6 +49,9 @@ import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationModel; import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationPatchModel; import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.AuthenticationSequence; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.AuthenticationStep; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.Authenticator; import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.InboundProtocols; import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; import org.wso2.identity.integration.test.utils.OAuth2Constant; @@ -66,6 +69,7 @@ import static org.wso2.identity.integration.test.applicationNativeAuthentication.Constants.AUTHENTICATOR_ID; import static org.wso2.identity.integration.test.applicationNativeAuthentication.Constants.AUTH_DATA_CODE; import static org.wso2.identity.integration.test.applicationNativeAuthentication.Constants.AUTH_DATA_SESSION_STATE; +import static org.wso2.identity.integration.test.applicationNativeAuthentication.Constants.BASIC_AUTHENTICATOR; import static org.wso2.identity.integration.test.applicationNativeAuthentication.Constants.CODE; import static org.wso2.identity.integration.test.applicationNativeAuthentication.Constants.CONTENT_TYPE_APPLICATION_JSON; import static org.wso2.identity.integration.test.applicationNativeAuthentication.Constants.ERROR_CODE_CLIENT_NATIVE_AUTHENTICATION_DISABLED; @@ -75,6 +79,7 @@ import static org.wso2.identity.integration.test.applicationNativeAuthentication.Constants.HREF; import static org.wso2.identity.integration.test.applicationNativeAuthentication.Constants.IDP; import static org.wso2.identity.integration.test.applicationNativeAuthentication.Constants.LINKS; +import static org.wso2.identity.integration.test.applicationNativeAuthentication.Constants.LOCAL; import static org.wso2.identity.integration.test.applicationNativeAuthentication.Constants.METADATA; import static org.wso2.identity.integration.test.applicationNativeAuthentication.Constants.NEXT_STEP; import static org.wso2.identity.integration.test.applicationNativeAuthentication.Constants.PARAMS; @@ -274,6 +279,22 @@ private ApplicationResponseModel createAppWithoutClientNativeAuthentication() th application.setInboundProtocolConfiguration(inboundProtocolsConfig); application.setName(TEST_APP_NAME); + // Set Basic authenticator as 1st step. + List authenticators = new ArrayList<>(); + List authenticationSteps = new ArrayList<>(); + Authenticator basicAuthenticator = new Authenticator() + .idp(LOCAL) + .authenticator(BASIC_AUTHENTICATOR); + authenticators.add(basicAuthenticator); + AuthenticationSequence authenticationSequence = new AuthenticationSequence(); + authenticationSequence.setType(AuthenticationSequence.TypeEnum.USER_DEFINED); + AuthenticationStep authenticationStep = new AuthenticationStep(); + authenticationStep.setId(1); + authenticationStep.setOptions(authenticators); + authenticationSteps.add(authenticationStep); + authenticationSequence.setSteps(authenticationSteps); + application.setAuthenticationSequence(authenticationSequence); + String appId = addApplication(application); return getApplication(appId); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/applicationNativeAuthentication/Constants.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/applicationNativeAuthentication/Constants.java index 63ce5c8214a..c6e322b9ae7 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/applicationNativeAuthentication/Constants.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/applicationNativeAuthentication/Constants.java @@ -31,6 +31,10 @@ public class Constants { public static final String TEST_USER_NAME = "attestationTestUser"; public static final String TEST_APP_NAME = "oauthTestANAApplication"; + // Basic Authenticator + public static final String LOCAL = "LOCAL"; + public static final String BASIC_AUTHENTICATOR = "BasicAuthenticator"; + public static final String TEST_PASSWORD = "passWord1@"; public static final String TEST_PROFILE = "default"; diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml b/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml index 90de6f1400e..9909e125ed8 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/testng.xml @@ -29,7 +29,6 @@ - @@ -134,6 +133,7 @@ +