From ea0f8e8385592e4d8e42ad943c77c0e01b31f323 Mon Sep 17 00:00:00 2001 From: Thumimku Date: Wed, 31 Jan 2024 16:02:16 +0530 Subject: [PATCH 1/4] enable ANA Basic --- .../tests-backend/src/test/resources/testng.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 5ac345d3ac..9909e125ed 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 @@ -133,8 +133,7 @@ - - + From 2f5ec43f5017f7b2aff31be91978f348399d8f55 Mon Sep 17 00:00:00 2001 From: Thumimku Date: Wed, 31 Jan 2024 18:00:47 +0530 Subject: [PATCH 2/4] enable ANA Basic --- .../tests-backend/src/test/resources/testng.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9909e125ed..90de6f1400 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,6 +29,7 @@ + @@ -133,7 +134,6 @@ - From 297bdaa63c97c6e8d4210b8ec48f2bafaa1037c3 Mon Sep 17 00:00:00 2001 From: Thumimku Date: Thu, 1 Feb 2024 09:15:56 +0530 Subject: [PATCH 3/4] 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 fe2694f6cd..594481d80a 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 63ce5c8214..c6e322b9ae 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 90de6f1400..9909e125ed 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 @@ + From 01cc3cf62cdbc0630d390c39309663285cc97d27 Mon Sep 17 00:00:00 2001 From: Thumimku Date: Mon, 12 Feb 2024 12:21:13 +0530 Subject: [PATCH 4/4] add basic authn id check --- .../ApplicationNativeAuthenticationTestCase.java | 3 +++ 1 file changed, 3 insertions(+) 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 594481d80a..e156721a13 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 @@ -115,6 +115,7 @@ public class ApplicationNativeAuthenticationTestCase extends OAuth2ServiceAbstra private CloseableHttpClient client; private UserManagementClient userMgtServiceClient; private String code; + private static final String basicAuthenticatorId = "QmFzaWNBdXRoZW50aWNhdG9yOkxPQ0FM"; @BeforeClass(alwaysRun = true) public void testInit() throws Exception { @@ -346,6 +347,8 @@ private void validInitClientNativeAuthnResponse(JSONObject json) { authenticator.containsKey(REQUIRED_PARAMS)) { authenticatorId = (String) authenticator.get(AUTHENTICATOR_ID); + Assert.assertEquals(authenticatorId, basicAuthenticatorId, "Authenticator Id is not " + + "equal for basic authenticator ID"); JSONObject metadataNode = (JSONObject) authenticator.get(METADATA); if (metadataNode.containsKey(PROMPT_TYPE) && metadataNode.containsKey(PARAMS)) { paramsArray = (JSONArray) metadataNode.get(PARAMS);