From 2c63f8da4dea99a7f50ebc27c92ccaeb17465aaf Mon Sep 17 00:00:00 2001 From: Shenali Date: Tue, 10 Dec 2024 21:16:13 +0530 Subject: [PATCH 1/7] Improve identity provider integration tests --- .../api/server/idp/v1/IdPSuccessTest.java | 93 +++++++++++++++---- 1 file changed, 77 insertions(+), 16 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java index c4b59dd883..e8b579b6d0 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java @@ -63,7 +63,10 @@ public class IdPSuccessTest extends IdPTestBase { private static final String OIDC_SCOPES_PLACEHOLDER = "\"\""; private static final String AUTHENTICATOR_PROPERTIES_PLACEHOLDER = "\"\""; private static final String FEDERATED_AUTHENTICATOR_ID = "Y3VzdG9tQXV0aGVudGljYXRvcg"; + private static final String OIDC_AUTHENTICATOR_ID = "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I"; + private static final String SAML_AUTHENTICATOR_ID = "U0FNTFNTT0F1dGhlbnRpY2F0b3I"; private static final String CUSTOM_IDP_NAME = "Custom Auth IDP"; + private static final String SAML_IDP_NAME = "SAML IdP"; private static final String ENDPOINT_URI = "https://abc.com/authenticate"; private static final String UPDATED_ENDPOINT_URI = "https://xyz.com/authenticate"; private static final String USERNAME = "username"; @@ -76,6 +79,7 @@ public class IdPSuccessTest extends IdPTestBase { private static final String TRUSTED_TOKEN_ISS_IDP_NAME = "Trusted Token Issuer IdP"; private static final String AUTHENTICATOR_NAME = "GoogleOIDCAuthenticator"; private static final String DEFINED_BY_SYSTEM = "SYSTEM"; + private static final String DEFINED_BY_USER = "USER"; private UserDefinedAuthenticatorPayload userDefinedAuthenticatorPayload; private String idpCreatePayload; private String idPId; @@ -339,17 +343,27 @@ public void testGetMetaOutboundConnector() throws IOException { @Test public void testAddIdPWithUserDefinedAuthenticator() throws IOException { + String baseIdentifier = "federatedAuthenticators.authenticators.find { it.authenticatorId == '" + + FEDERATED_AUTHENTICATOR_ID + "' }."; + String body = idpCreatePayload.replace(FEDERATED_AUTHENTICATOR_ID_PLACEHOLDER, userDefinedAuthenticatorPayload.getAuthenticatorId()); body = body.replace(FEDERATED_AUTHENTICATOR_PLACEHOLDER, userDefinedAuthenticatorPayload.convertToJasonPayload()); body = body.replace(IDP_NAME_PLACEHOLDER, CUSTOM_IDP_NAME); + Response response = getResponseOfPost(IDP_API_BASE_PATH, body); response.then() .log().ifValidationFails() .assertThat() .statusCode(HttpStatus.SC_CREATED) - .header(HttpHeaders.LOCATION, notNullValue()); + .header(HttpHeaders.LOCATION, notNullValue()) + .body("name", equalTo(CUSTOM_IDP_NAME)) + .body(baseIdentifier + "authenticatorId", equalTo(FEDERATED_AUTHENTICATOR_ID)) + .body(baseIdentifier + "name", equalTo(new String(Base64.getDecoder().decode(FEDERATED_AUTHENTICATOR_ID)))) + .body(baseIdentifier + "isEnabled", equalTo(true)) + .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_USER)) + .body(baseIdentifier + "tags", Matchers.hasItems("Custom")); String location = response.getHeader(HttpHeaders.LOCATION); assertNotNull(location); @@ -360,6 +374,7 @@ public void testAddIdPWithUserDefinedAuthenticator() throws IOException { @Test(dependsOnMethods = "testAddIdPWithUserDefinedAuthenticator") public void testGetUserDefinedAuthenticatorsOfIdP() throws XPathExpressionException { + String baseIdentifier = "authenticators.find { it.authenticatorId == '" + FEDERATED_AUTHENTICATOR_ID + "' }."; Response response = getResponseOfGet(IDP_API_BASE_PATH + PATH_SEPARATOR + customIdPId + PATH_SEPARATOR + IDP_FEDERATED_AUTHENTICATORS_PATH); @@ -368,14 +383,14 @@ public void testGetUserDefinedAuthenticatorsOfIdP() throws XPathExpressionExcept .assertThat() .statusCode(HttpStatus.SC_OK) .body("defaultAuthenticatorId", equalTo(FEDERATED_AUTHENTICATOR_ID)) - .body("authenticators.find { it.authenticatorId == '" + FEDERATED_AUTHENTICATOR_ID + "' }.name", - equalTo(new String(Base64.getDecoder().decode(FEDERATED_AUTHENTICATOR_ID)))) - .body("authenticators.find { it.authenticatorId == '" + FEDERATED_AUTHENTICATOR_ID + "' }.isEnabled", - equalTo(true)) - .body("authenticators.find { it.authenticatorId == '" + FEDERATED_AUTHENTICATOR_ID + "' }.self", - equalTo(getTenantedRelativePath("/api/server/v1/identity-providers/" + - customIdPId + "/federated-authenticators/" + FEDERATED_AUTHENTICATOR_ID, - context.getContextTenant().getDomain()))); + .body(baseIdentifier + "name", equalTo(new String(Base64.getDecoder().decode(FEDERATED_AUTHENTICATOR_ID)))) + .body(baseIdentifier + "isEnabled", equalTo(true)) + .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_USER)) + .body(baseIdentifier + "tags", Matchers.hasItems("Custom")) + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( + "/api/server/v1/identity-providers/" + customIdPId + + "/federated-authenticators/" + FEDERATED_AUTHENTICATOR_ID, + context.getContextTenant().getDomain()))); } @Test(dependsOnMethods = "testGetUserDefinedAuthenticatorsOfIdP") @@ -392,7 +407,9 @@ public void testUpdateUserDefinedAuthenticatorOfIdP() throws JsonProcessingExcep .statusCode(HttpStatus.SC_OK) .body("authenticatorId", equalTo(FEDERATED_AUTHENTICATOR_ID)) .body("name", equalTo(new String(Base64.getDecoder().decode(FEDERATED_AUTHENTICATOR_ID)))) - .body("definedBy", equalTo("USER")) + .body("isEnabled", equalTo(true)) + .body("definedBy", equalTo(DEFINED_BY_USER)) + .body( "tags", Matchers.hasItems("Custom")) .body("endpoint.uri", equalTo(UPDATED_ENDPOINT_URI)) .body("endpoint.authentication.type", equalTo(AuthenticationType.TypeEnum.BEARER.value())); } @@ -421,6 +438,9 @@ public void testDeleteIdPWithUserDefinedAuthenticator() { @Test(dependsOnMethods = {"testGetMetaOutboundConnector"}) public void testAddIdP() throws IOException { + String baseIdentifier = "federatedAuthenticators.authenticators.find { it.authenticatorId == '" + + SAMPLE_FEDERATED_AUTHENTICATOR_ID + "' }."; + String addIdpPayload = readResource("add-idp.json"); String properties = convertDuplicatedPropertiesToJson( createAuthenticatorProperties("username","admin"), null); @@ -431,7 +451,13 @@ public void testAddIdP() throws IOException { .log().ifValidationFails() .assertThat() .statusCode(HttpStatus.SC_CREATED) - .header(HttpHeaders.LOCATION, notNullValue()); + .header(HttpHeaders.LOCATION, notNullValue()) + .body("name", equalTo(IDP_NAME)) + .body(baseIdentifier + "name", equalTo(new String(Base64.getDecoder(). + decode(SAMPLE_FEDERATED_AUTHENTICATOR_ID)))) + .body(baseIdentifier + "isEnabled", equalTo(true)) + .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_SYSTEM)) + .body(baseIdentifier + "tags", Matchers.hasItems("Social-Login", "APIAuth")); String location = response.getHeader(HttpHeaders.LOCATION); assertNotNull(location); @@ -467,6 +493,9 @@ public void addIdPWithoutAuthenticator() throws IOException { @Test public void addIdPWithDuplicatedOIDCScopes() throws IOException { + String baseIdentifier = "federatedAuthenticators.authenticators.find { it.authenticatorId == '" + + OIDC_AUTHENTICATOR_ID + "' }."; + String oidcIdpPayload = readResource("add-oidc-idp.json"); String oidcScopesProperties = convertDuplicatedPropertiesToJson( createAuthenticatorProperties("Scopes","openid country profile"), @@ -479,7 +508,13 @@ public void addIdPWithDuplicatedOIDCScopes() throws IOException { .log().ifValidationFails() .assertThat() .statusCode(HttpStatus.SC_CREATED) - .header(HttpHeaders.LOCATION, notNullValue()); + .header(HttpHeaders.LOCATION, notNullValue()) + .body("name", equalTo("OIDC-IdP-1")) + .body(baseIdentifier + "authenticatorId", equalTo(OIDC_AUTHENTICATOR_ID)) + .body(baseIdentifier + "name", equalTo(new String(Base64.getDecoder().decode(OIDC_AUTHENTICATOR_ID)))) + .body(baseIdentifier + "isEnabled", equalTo(true)) + .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_SYSTEM)) + .body(baseIdentifier + "tags", Matchers.hasItems("OIDC", "APIAuth")); String location = response.getHeader(HttpHeaders.LOCATION); assertNotNull(location); @@ -496,6 +531,9 @@ public void addIdPWithDuplicatedOIDCScopes() throws IOException { @Test(dependsOnMethods = "addIdPWithDuplicatedOIDCScopes") public void addOIDCIdPWithoutOpenidScope() throws IOException { + String baseIdentifier = "\"federatedAuthenticators.authenticators.find { it.authenticatorId == '" + + OIDC_AUTHENTICATOR_ID + "' }."; + String oidcIdpPayload = readResource("add-oidc-idp.json"); String oidcScopesProperties = convertDuplicatedPropertiesToJson( createAuthenticatorProperties("Scopes","country profile"), null); @@ -507,7 +545,13 @@ public void addOIDCIdPWithoutOpenidScope() throws IOException { .log().ifValidationFails() .assertThat() .statusCode(HttpStatus.SC_CREATED) - .header(HttpHeaders.LOCATION, notNullValue()); + .header(HttpHeaders.LOCATION, notNullValue()) + .body("name", equalTo("OIDC-IdP-2")) + .body(baseIdentifier + "authenticatorId", equalTo(OIDC_AUTHENTICATOR_ID)) + .body(baseIdentifier + "name", equalTo(new String(Base64.getDecoder().decode(OIDC_AUTHENTICATOR_ID)))) + .body(baseIdentifier + "isEnabled", equalTo(true)) + .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_SYSTEM)) + .body(baseIdentifier + "tags", Matchers.hasItems("OIDC", "APIAuth")); String location = response.getHeader(HttpHeaders.LOCATION); assertNotNull(location); @@ -520,6 +564,9 @@ public void addOIDCIdPWithoutOpenidScope() throws IOException { @Test public void addSAMLStandardBasedIdP() throws IOException { + String baseIdentifier = "federatedAuthenticators.authenticators.find { it.authenticatorId == '" + + SAML_AUTHENTICATOR_ID + "' }."; + String samlIdpPayload = readResource("add-saml-idp.json"); String body = samlIdpPayload.replace(METADATA_SAML_PLACEHOLDER, loadMetadataSamlFile( "test-metadata-saml.xml")); @@ -529,7 +576,13 @@ public void addSAMLStandardBasedIdP() throws IOException { .log().ifValidationFails() .assertThat() .statusCode(HttpStatus.SC_CREATED) - .header(HttpHeaders.LOCATION, notNullValue()); + .header(HttpHeaders.LOCATION, notNullValue()) + .body("name", equalTo(SAML_IDP_NAME)) + .body(baseIdentifier + "authenticatorId", equalTo(SAML_AUTHENTICATOR_ID)) + .body(baseIdentifier + "name", equalTo(new String(Base64.getDecoder().decode(SAML_AUTHENTICATOR_ID)))) + .body(baseIdentifier + "isEnabled", equalTo(true)) + .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_SYSTEM)) + .body(baseIdentifier + "tags", Matchers.hasItems("SAML")); String location = response.getHeader(HttpHeaders.LOCATION); assertNotNull(location); @@ -542,6 +595,9 @@ public void addSAMLStandardBasedIdP() throws IOException { @Test(dependsOnMethods = {"testAddIdP"}) public void testGetIdP() throws IOException { + String baseIdentifier = "federatedAuthenticators.authenticators.find { it.authenticatorId == '" + + SAMPLE_FEDERATED_AUTHENTICATOR_ID + "' }."; + Response response = getResponseOfGet(IDP_API_BASE_PATH + PATH_SEPARATOR + idPId); response.then() .log().ifValidationFails() @@ -552,8 +608,11 @@ public void testGetIdP() throws IOException { .body("description", equalTo("IDP for Google Federation")) .body("isEnabled", equalTo(true)) .body("isPrimary", equalTo(false)) - .body("federatedAuthenticators.authenticators.find { it.authenticatorId == '" + - SAMPLE_FEDERATED_AUTHENTICATOR_ID + "' }.definedBy", equalTo("SYSTEM")) + .body(baseIdentifier + "name", equalTo(new String(Base64.getDecoder(). + decode(SAMPLE_FEDERATED_AUTHENTICATOR_ID)))) + .body(baseIdentifier + "isEnabled", equalTo(true)) + .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_SYSTEM)) + .body(baseIdentifier + "tags", Matchers.hasItems("Social-Login", "APIAuth")) .body("image", equalTo("google-logo-url")) .body("isFederationHub", equalTo(false)) .body("homeRealmIdentifier", equalTo("localhost")) @@ -629,6 +688,7 @@ public void testGetIdPsWithRequiredAttribute() throws Exception { .body(baseIdentifier + "description", equalTo("IDP for Google Federation")) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "image", equalTo("google-logo-url")) + .body(baseIdentifier + "tags", Matchers.hasItems("Social-Login", "APIAuth")) .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( "/api/server/v1/identity-providers/" + idPId, context.getContextTenant().getDomain()))) @@ -647,6 +707,7 @@ public void testGetIdPFederatedAuthenticators() throws Exception { .assertThat() .statusCode(HttpStatus.SC_OK) .body(baseIdentifier + "name", equalTo("GoogleOIDCAuthenticator")) + .body(baseIdentifier + "tags", Matchers.hasItems("Social-Login", "APIAuth")) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( "/api/server/v1/identity-providers/" + idPId + "/federated-authenticators/" + From 73544b5f6c1b85187d055ae6b9a680ac83a54456 Mon Sep 17 00:00:00 2001 From: Shenali Date: Tue, 10 Dec 2024 22:27:02 +0530 Subject: [PATCH 2/7] Fix comments --- .../integration/test/rest/api/server/idp/v1/IdPSuccessTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java index e8b579b6d0..ef6f297291 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java @@ -531,7 +531,7 @@ public void addIdPWithDuplicatedOIDCScopes() throws IOException { @Test(dependsOnMethods = "addIdPWithDuplicatedOIDCScopes") public void addOIDCIdPWithoutOpenidScope() throws IOException { - String baseIdentifier = "\"federatedAuthenticators.authenticators.find { it.authenticatorId == '" + + String baseIdentifier = "federatedAuthenticators.authenticators.find { it.authenticatorId == '" + OIDC_AUTHENTICATOR_ID + "' }."; String oidcIdpPayload = readResource("add-oidc-idp.json"); From 7831a169607232cefc26307b20c8ca3746542a52 Mon Sep 17 00:00:00 2001 From: Shenali Date: Wed, 11 Dec 2024 10:29:41 +0530 Subject: [PATCH 3/7] Address comments --- .../test/rest/api/server/idp/v1/IdPSuccessTest.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java index ef6f297291..ba0bfc389b 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java @@ -562,7 +562,7 @@ public void addOIDCIdPWithoutOpenidScope() throws IOException { } @Test - public void addSAMLStandardBasedIdP() throws IOException { + public void addSAMLStandardBasedIdP() throws IOException, XPathExpressionException { String baseIdentifier = "federatedAuthenticators.authenticators.find { it.authenticatorId == '" + SAML_AUTHENTICATOR_ID + "' }."; @@ -582,7 +582,8 @@ public void addSAMLStandardBasedIdP() throws IOException { .body(baseIdentifier + "name", equalTo(new String(Base64.getDecoder().decode(SAML_AUTHENTICATOR_ID)))) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_SYSTEM)) - .body(baseIdentifier + "tags", Matchers.hasItems("SAML")); + .body(baseIdentifier + "tags", Matchers.hasItems("SAML")) + .body(baseIdentifier + "self", Matchers.notNullValue()); String location = response.getHeader(HttpHeaders.LOCATION); assertNotNull(location); @@ -593,7 +594,7 @@ public void addSAMLStandardBasedIdP() throws IOException { } @Test(dependsOnMethods = {"testAddIdP"}) - public void testGetIdP() throws IOException { + public void testGetIdP() throws IOException, XPathExpressionException { String baseIdentifier = "federatedAuthenticators.authenticators.find { it.authenticatorId == '" + SAMPLE_FEDERATED_AUTHENTICATOR_ID + "' }."; @@ -613,6 +614,9 @@ public void testGetIdP() throws IOException { .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_SYSTEM)) .body(baseIdentifier + "tags", Matchers.hasItems("Social-Login", "APIAuth")) + .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( + "/api/server/v1/identity-providers/" + idPId + "/federated-authenticators/" + + SAMPLE_FEDERATED_AUTHENTICATOR_ID, context.getContextTenant().getDomain()))) .body("image", equalTo("google-logo-url")) .body("isFederationHub", equalTo(false)) .body("homeRealmIdentifier", equalTo("localhost")) @@ -688,7 +692,6 @@ public void testGetIdPsWithRequiredAttribute() throws Exception { .body(baseIdentifier + "description", equalTo("IDP for Google Federation")) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "image", equalTo("google-logo-url")) - .body(baseIdentifier + "tags", Matchers.hasItems("Social-Login", "APIAuth")) .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( "/api/server/v1/identity-providers/" + idPId, context.getContextTenant().getDomain()))) @@ -706,6 +709,7 @@ public void testGetIdPFederatedAuthenticators() throws Exception { .log().ifValidationFails() .assertThat() .statusCode(HttpStatus.SC_OK) + .body(baseIdentifier + "authenticatorId", equalTo(SAMPLE_FEDERATED_AUTHENTICATOR_ID)) .body(baseIdentifier + "name", equalTo("GoogleOIDCAuthenticator")) .body(baseIdentifier + "tags", Matchers.hasItems("Social-Login", "APIAuth")) .body(baseIdentifier + "isEnabled", equalTo(true)) From e73225fc2e8068e574a4280d5206f44f5aaf2ceb Mon Sep 17 00:00:00 2001 From: Shenali Date: Wed, 11 Dec 2024 11:02:55 +0530 Subject: [PATCH 4/7] Update assertions --- .../api/server/idp/v1/IdPSuccessTest.java | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java index ba0bfc389b..f8871acc94 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java @@ -46,6 +46,8 @@ import javax.xml.xpath.XPathExpressionException; import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.Matchers.emptyIterable; +import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.core.IsNull.notNullValue; import static org.hamcrest.core.IsNull.nullValue; import static org.testng.Assert.assertNotNull; @@ -341,7 +343,7 @@ public void testGetMetaOutboundConnector() throws IOException { } @Test - public void testAddIdPWithUserDefinedAuthenticator() throws IOException { + public void testAddIdPWithUserDefinedAuthenticator() throws IOException, XPathExpressionException { String baseIdentifier = "federatedAuthenticators.authenticators.find { it.authenticatorId == '" + FEDERATED_AUTHENTICATOR_ID + "' }."; @@ -363,7 +365,8 @@ public void testAddIdPWithUserDefinedAuthenticator() throws IOException { .body(baseIdentifier + "name", equalTo(new String(Base64.getDecoder().decode(FEDERATED_AUTHENTICATOR_ID)))) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_USER)) - .body(baseIdentifier + "tags", Matchers.hasItems("Custom")); + .body(baseIdentifier + "tags", hasItems("Custom")) + .body(baseIdentifier + "self", notNullValue()); String location = response.getHeader(HttpHeaders.LOCATION); assertNotNull(location); @@ -386,7 +389,7 @@ public void testGetUserDefinedAuthenticatorsOfIdP() throws XPathExpressionExcept .body(baseIdentifier + "name", equalTo(new String(Base64.getDecoder().decode(FEDERATED_AUTHENTICATOR_ID)))) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_USER)) - .body(baseIdentifier + "tags", Matchers.hasItems("Custom")) + .body(baseIdentifier + "tags", hasItems("Custom")) .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( "/api/server/v1/identity-providers/" + customIdPId + "/federated-authenticators/" + FEDERATED_AUTHENTICATOR_ID, @@ -394,7 +397,7 @@ public void testGetUserDefinedAuthenticatorsOfIdP() throws XPathExpressionExcept } @Test(dependsOnMethods = "testGetUserDefinedAuthenticatorsOfIdP") - public void testUpdateUserDefinedAuthenticatorOfIdP() throws JsonProcessingException { + public void testUpdateUserDefinedAuthenticatorOfIdP() throws JsonProcessingException, XPathExpressionException { Response response = getResponseOfPut(IDP_API_BASE_PATH + PATH_SEPARATOR + customIdPId + PATH_SEPARATOR + IDP_FEDERATED_AUTHENTICATORS_PATH + PATH_SEPARATOR + FEDERATED_AUTHENTICATOR_ID, @@ -409,7 +412,11 @@ public void testUpdateUserDefinedAuthenticatorOfIdP() throws JsonProcessingExcep .body("name", equalTo(new String(Base64.getDecoder().decode(FEDERATED_AUTHENTICATOR_ID)))) .body("isEnabled", equalTo(true)) .body("definedBy", equalTo(DEFINED_BY_USER)) - .body( "tags", Matchers.hasItems("Custom")) + .body( "tags", hasItems("Custom")) + .body("self", equalTo(getTenantedRelativePath( + "/api/server/v1/identity-providers/" + customIdPId + + "/federated-authenticators/" + FEDERATED_AUTHENTICATOR_ID, + context.getContextTenant().getDomain()))) .body("endpoint.uri", equalTo(UPDATED_ENDPOINT_URI)) .body("endpoint.authentication.type", equalTo(AuthenticationType.TypeEnum.BEARER.value())); } @@ -436,7 +443,7 @@ public void testDeleteIdPWithUserDefinedAuthenticator() { } @Test(dependsOnMethods = {"testGetMetaOutboundConnector"}) - public void testAddIdP() throws IOException { + public void testAddIdP() throws IOException, XPathExpressionException { String baseIdentifier = "federatedAuthenticators.authenticators.find { it.authenticatorId == '" + SAMPLE_FEDERATED_AUTHENTICATOR_ID + "' }."; @@ -457,7 +464,8 @@ public void testAddIdP() throws IOException { decode(SAMPLE_FEDERATED_AUTHENTICATOR_ID)))) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_SYSTEM)) - .body(baseIdentifier + "tags", Matchers.hasItems("Social-Login", "APIAuth")); + .body(baseIdentifier + "tags", hasItems("Social-Login", "APIAuth")) + .body(baseIdentifier + "self", notNullValue()); String location = response.getHeader(HttpHeaders.LOCATION); assertNotNull(location); @@ -474,7 +482,7 @@ public void addIdPWithoutAuthenticator() throws IOException { .log().ifValidationFails() .assertThat() .statusCode(HttpStatus.SC_CREATED) - .body("federatedAuthenticators.authenticators", Matchers.emptyIterable()) + .body("federatedAuthenticators.authenticators", emptyIterable()) .header(HttpHeaders.LOCATION, notNullValue()); String location = response.getHeader(HttpHeaders.LOCATION); @@ -514,7 +522,8 @@ public void addIdPWithDuplicatedOIDCScopes() throws IOException { .body(baseIdentifier + "name", equalTo(new String(Base64.getDecoder().decode(OIDC_AUTHENTICATOR_ID)))) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_SYSTEM)) - .body(baseIdentifier + "tags", Matchers.hasItems("OIDC", "APIAuth")); + .body(baseIdentifier + "tags", hasItems("OIDC", "APIAuth")) + .body(baseIdentifier + "self", notNullValue()); String location = response.getHeader(HttpHeaders.LOCATION); assertNotNull(location); @@ -551,7 +560,8 @@ public void addOIDCIdPWithoutOpenidScope() throws IOException { .body(baseIdentifier + "name", equalTo(new String(Base64.getDecoder().decode(OIDC_AUTHENTICATOR_ID)))) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_SYSTEM)) - .body(baseIdentifier + "tags", Matchers.hasItems("OIDC", "APIAuth")); + .body(baseIdentifier + "tags", hasItems("OIDC", "APIAuth")) + .body(baseIdentifier + "self", notNullValue()); String location = response.getHeader(HttpHeaders.LOCATION); assertNotNull(location); @@ -582,8 +592,8 @@ public void addSAMLStandardBasedIdP() throws IOException, XPathExpressionExcepti .body(baseIdentifier + "name", equalTo(new String(Base64.getDecoder().decode(SAML_AUTHENTICATOR_ID)))) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_SYSTEM)) - .body(baseIdentifier + "tags", Matchers.hasItems("SAML")) - .body(baseIdentifier + "self", Matchers.notNullValue()); + .body(baseIdentifier + "tags", hasItems("SAML")) + .body(baseIdentifier + "self", notNullValue()); String location = response.getHeader(HttpHeaders.LOCATION); assertNotNull(location); @@ -613,7 +623,7 @@ public void testGetIdP() throws IOException, XPathExpressionException { decode(SAMPLE_FEDERATED_AUTHENTICATOR_ID)))) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_SYSTEM)) - .body(baseIdentifier + "tags", Matchers.hasItems("Social-Login", "APIAuth")) + .body(baseIdentifier + "tags", hasItems("Social-Login", "APIAuth")) .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( "/api/server/v1/identity-providers/" + idPId + "/federated-authenticators/" + SAMPLE_FEDERATED_AUTHENTICATOR_ID, context.getContextTenant().getDomain()))) @@ -711,7 +721,7 @@ public void testGetIdPFederatedAuthenticators() throws Exception { .statusCode(HttpStatus.SC_OK) .body(baseIdentifier + "authenticatorId", equalTo(SAMPLE_FEDERATED_AUTHENTICATOR_ID)) .body(baseIdentifier + "name", equalTo("GoogleOIDCAuthenticator")) - .body(baseIdentifier + "tags", Matchers.hasItems("Social-Login", "APIAuth")) + .body(baseIdentifier + "tags", hasItems("Social-Login", "APIAuth")) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( "/api/server/v1/identity-providers/" + idPId + "/federated-authenticators/" + From 90c9bc03698091c82794a8ae1dd25bde25db0eae Mon Sep 17 00:00:00 2001 From: Shenali Date: Wed, 11 Dec 2024 15:02:56 +0530 Subject: [PATCH 5/7] Update assertions with related to dev improvements --- .../test/rest/api/server/idp/v1/IdPSuccessTest.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java index f8871acc94..2035b67312 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java @@ -23,7 +23,6 @@ import org.apache.commons.lang.StringUtils; import org.apache.http.HttpHeaders; import org.apache.http.HttpStatus; -import org.hamcrest.Matchers; import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeClass; @@ -82,6 +81,7 @@ public class IdPSuccessTest extends IdPTestBase { private static final String AUTHENTICATOR_NAME = "GoogleOIDCAuthenticator"; private static final String DEFINED_BY_SYSTEM = "SYSTEM"; private static final String DEFINED_BY_USER = "USER"; + private static final String CUSTOM_TAGS = "CUSTOM"; private UserDefinedAuthenticatorPayload userDefinedAuthenticatorPayload; private String idpCreatePayload; private String idPId; @@ -365,7 +365,7 @@ public void testAddIdPWithUserDefinedAuthenticator() throws IOException, XPathEx .body(baseIdentifier + "name", equalTo(new String(Base64.getDecoder().decode(FEDERATED_AUTHENTICATOR_ID)))) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_USER)) - .body(baseIdentifier + "tags", hasItems("Custom")) + .body(baseIdentifier + "tags", hasItems(CUSTOM_TAGS)) .body(baseIdentifier + "self", notNullValue()); String location = response.getHeader(HttpHeaders.LOCATION); @@ -389,7 +389,7 @@ public void testGetUserDefinedAuthenticatorsOfIdP() throws XPathExpressionExcept .body(baseIdentifier + "name", equalTo(new String(Base64.getDecoder().decode(FEDERATED_AUTHENTICATOR_ID)))) .body(baseIdentifier + "isEnabled", equalTo(true)) .body(baseIdentifier + "definedBy", equalTo(DEFINED_BY_USER)) - .body(baseIdentifier + "tags", hasItems("Custom")) + .body(baseIdentifier + "tags", hasItems(CUSTOM_TAGS)) .body(baseIdentifier + "self", equalTo(getTenantedRelativePath( "/api/server/v1/identity-providers/" + customIdPId + "/federated-authenticators/" + FEDERATED_AUTHENTICATOR_ID, @@ -412,11 +412,7 @@ public void testUpdateUserDefinedAuthenticatorOfIdP() throws JsonProcessingExcep .body("name", equalTo(new String(Base64.getDecoder().decode(FEDERATED_AUTHENTICATOR_ID)))) .body("isEnabled", equalTo(true)) .body("definedBy", equalTo(DEFINED_BY_USER)) - .body( "tags", hasItems("Custom")) - .body("self", equalTo(getTenantedRelativePath( - "/api/server/v1/identity-providers/" + customIdPId + - "/federated-authenticators/" + FEDERATED_AUTHENTICATOR_ID, - context.getContextTenant().getDomain()))) + .body("tags", hasItems(CUSTOM_TAGS)) .body("endpoint.uri", equalTo(UPDATED_ENDPOINT_URI)) .body("endpoint.authentication.type", equalTo(AuthenticationType.TypeEnum.BEARER.value())); } From f1f4d8f12ab28f6661e832db51865999a4ca1244 Mon Sep 17 00:00:00 2001 From: Thisara Welmilla Date: Wed, 18 Dec 2024 11:03:48 +0530 Subject: [PATCH 6/7] Rename CUSTOM to Custom --- .../integration/test/rest/api/server/idp/v1/IdPSuccessTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java index 2035b67312..3b32c0d64d 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/idp/v1/IdPSuccessTest.java @@ -81,7 +81,7 @@ public class IdPSuccessTest extends IdPTestBase { private static final String AUTHENTICATOR_NAME = "GoogleOIDCAuthenticator"; private static final String DEFINED_BY_SYSTEM = "SYSTEM"; private static final String DEFINED_BY_USER = "USER"; - private static final String CUSTOM_TAGS = "CUSTOM"; + private static final String CUSTOM_TAGS = "Custom"; private UserDefinedAuthenticatorPayload userDefinedAuthenticatorPayload; private String idpCreatePayload; private String idPId; From 7e90adbf54ca985dabf40cebd92e605e5f708fd1 Mon Sep 17 00:00:00 2001 From: Shenali Date: Wed, 18 Dec 2024 13:48:22 +0530 Subject: [PATCH 7/7] Bump api-server version and framework version --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 51ee47a759..d11488b1a8 100755 --- a/pom.xml +++ b/pom.xml @@ -2356,7 +2356,7 @@ - 7.7.45 + 7.7.46 [5.14.67, 8.0.0) @@ -2468,7 +2468,7 @@ 2.0.17 - 1.3.12 + 1.3.14 1.3.46 5.5.9