From 3821229b7ed6d1c4d5e566cdc98680ad8830a80c Mon Sep 17 00:00:00 2001 From: Amanda Ariyaratne Date: Tue, 22 Oct 2024 16:49:19 +0530 Subject: [PATCH 1/2] add integration tests for claim mgt --- .../oauth2/OAuth2ServiceJWTGrantTestCase.java | 5 +- .../v1/ClaimManagementNegativeTest.java | 269 +++++++++++++----- .../ClaimManagementRestClient.java | 11 + .../test/scim2/SCIM2UserTestCase.java | 69 ----- ...ent-add-external-claim-already-mapped.json | 4 + ...al-claim-mapped-to-custom-local-claim.json | 4 + ...ent-add-local-claim-with-existing-uri.json | 21 ++ ...agement-update-default-external-claim.json | 4 + ...-update-external-claim-already-mapped.json | 4 + ...e-external-claim-invalid-mapped-claim.json | 4 + 10 files changed, 258 insertions(+), 137 deletions(-) create mode 100644 modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-add-external-claim-already-mapped.json create mode 100644 modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-add-external-claim-mapped-to-custom-local-claim.json create mode 100644 modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-add-local-claim-with-existing-uri.json create mode 100644 modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-update-default-external-claim.json create mode 100644 modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-update-external-claim-already-mapped.json create mode 100644 modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-update-external-claim-invalid-mapped-claim.json diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceJWTGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceJWTGrantTestCase.java index d007a61967b..5c35f5c6c38 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceJWTGrantTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceJWTGrantTestCase.java @@ -102,6 +102,7 @@ public class OAuth2ServiceJWTGrantTestCase extends OAuth2ServiceAbstractIntegrat private static final String COUNTRY_OIDC_CLAIM = "country"; private static final String COUNTRY_NEW_OIDC_CLAIM = "customclaim"; private static final String COUNTRY_LOCAL_CLAIM_URI = "http://wso2.org/claims/country"; + private static final String STATE_LOCAL_CLAIM_URI = "http://wso2.org/claims/stateorprovince"; private static final String EMAIL_OIDC_CLAIM = "email"; private static final String EMAIL_CLAIM_VALUE = "email@email.com"; private static final String EMAIL_LOCAL_CLAIM_URI = "http://wso2.org/claims/emailaddress"; @@ -590,7 +591,9 @@ private void addAdminUser() throws Exception { */ private void changeCountryOIDCDialect() throws Exception { - claimManagementRestClient.deleteExternalClaim(ENCODED_OIDC_CLAIM_DIALECT, COUNTRY_CLAIM_ID); + ExternalClaimReq updateCountryReq = new ExternalClaimReq().claimURI(COUNTRY_OIDC_CLAIM) + .mappedLocalClaimURI(STATE_LOCAL_CLAIM_URI); + claimManagementRestClient.updateExternalClaim(ENCODED_OIDC_CLAIM_DIALECT, COUNTRY_CLAIM_ID, updateCountryReq); ExternalClaimReq externalClaimReq = new ExternalClaimReq(); externalClaimReq.setClaimURI(COUNTRY_NEW_OIDC_CLAIM); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/ClaimManagementNegativeTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/ClaimManagementNegativeTest.java index dfb5051daa0..da8019b7815 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/ClaimManagementNegativeTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/ClaimManagementNegativeTest.java @@ -18,7 +18,6 @@ import io.restassured.RestAssured; import io.restassured.response.Response; -import org.apache.axis2.AxisFault; import org.apache.commons.lang.StringUtils; import org.apache.http.HttpHeaders; import org.apache.http.HttpStatus; @@ -43,8 +42,8 @@ */ public class ClaimManagementNegativeTest extends ClaimManagementTestBase { - private static String testDialectId = "aHR0cDovL3VwZGF0ZWRkdW1teS5vcmcvY6xhaW0"; - private static String testClaimId = "aHR0cDovL2ludmFsaWRkdW1teS5vcmcvY2xhaW0vZW1haWxhZGRyZXNz"; + private static final String testDialectId = "aHR0cDovL3VwZGF0ZWRkdW1teS5vcmcvY6xhaW0"; + private static final String testClaimId = "aHR0cDovL2ludmFsaWRkdW1teS5vcmcvY2xhaW0vZW1haWxhZGRyZXNz"; @Factory(dataProvider = "restAPIUserConfigProvider") public ClaimManagementNegativeTest(TestUserMode userMode) throws Exception { @@ -96,6 +95,135 @@ public void testGetDialectWithInvalidDialectId() { validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "CMT-50016", testDialectId); } + @Test + public void testRemoveSystemDefaultDialect() { + + String dialectId = "local"; + removeDialect(dialectId); + getResponseOfGet(CLAIM_DIALECTS_ENDPOINT_URI + "/" + dialectId) + .then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_OK) + .body("id", equalTo(dialectId)) + .body("dialectURI", equalTo("http://wso2.org/claims")); + + dialectId = "dXJuOmlldGY6cGFyYW1zOnNjaW06c2NoZW1hczpjb3JlOjIuMA"; + getResponseOfDelete(CLAIM_DIALECTS_ENDPOINT_URI + "/" + dialectId) + .then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_FORBIDDEN) + .body("code", equalTo("CMT-60008")); + } + + @Test + public void testAddExistingDialect() throws IOException { + + String dialectId = createDialect(); + + String body = readResource("claim-management-add-dialect.json"); + Response response = getResponseOfPost(CLAIM_DIALECTS_ENDPOINT_URI, body); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_CONFLICT) + .body("code", equalTo("CMT-60002")); + + removeDialect(dialectId); + } + + @Test + public void testUpdateDefaultDialectURI() throws IOException { + + String dialectId = "aHR0cDovL3dzbzIub3JnL29pZGMvY2xhaW0"; + String body = readResource("claim-management-update-dialect.json"); + Response response = getResponseOfPut(CLAIM_DIALECTS_ENDPOINT_URI + "/" + dialectId, body); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_FORBIDDEN) + .body("code", equalTo("CMT-60007")); + } + + @Test + public void testGetLocalClaimsWithInvalidClaimId() { + + Response response = + getResponseOfGet(CLAIM_DIALECTS_ENDPOINT_URI + LOCAL_CLAIMS_ENDPOINT_URI + "/" + testClaimId); + validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "CMT-50019", testClaimId); + } + + @Test + public void testUpdateExistingLocalClaimUri() throws IOException { + + String localClaimUri = "http://wso2.org/claims/dummyemailaddress"; + String claimId = createLocalClaim(); + + String body = readResource("claim-management-update-local-claim-conflict.json"); + Response response = getResponseOfPut(CLAIM_DIALECTS_ENDPOINT_URI + LOCAL_CLAIMS_ENDPOINT_URI + "/" + claimId, + body); + validateErrorResponse(response, HttpStatus.SC_CONFLICT, "CMT-50021", localClaimUri); + + removeLocalClaim(claimId); + } + + @Test + public void testAddLocalClaimWithInvalidUsertore() throws IOException { + + String userstore = "DUMMY"; + String body = readResource("claim-management-add-local-claim-invalid-userstore.json"); + Response response = getResponseOfPost(CLAIM_DIALECTS_ENDPOINT_URI + LOCAL_CLAIMS_ENDPOINT_URI, body); + validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "CMT-50026", userstore); + } + + @Test + public void testRemoveLocalClaimWithExternalClaimAssociation() throws IOException { + + String localClaimId = createLocalClaim(); + String dialectId = createDialect(); + String claimId = createExternalClaimMappedToCustomLocalClaim(dialectId); + + Response response = getResponseOfDelete(CLAIM_DIALECTS_ENDPOINT_URI + LOCAL_CLAIMS_ENDPOINT_URI + "/" + + localClaimId); + validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "CMT-50031"); + + removeExternalClaim(dialectId, claimId); + removeDialect(dialectId); + removeLocalClaim(localClaimId); + } + + @Test + public void testRemoveDefaultLocalClaim() throws IOException { + + String dialectId = "dXJuOmlldGY6cGFyYW1zOnNjaW06c2NoZW1hczpjb3JlOjIuMA"; + String claimId = "dXJuOmlldGY6cGFyYW1zOnNjaW06c2NoZW1hczpjb3JlOjIuMDptZXRhLnJlc291cmNlVHlwZQ=="; + + String body = readResource("claim-management-update-default-external-claim.json"); + Response response = getResponseOfPut(CLAIM_DIALECTS_ENDPOINT_URI + "/" + dialectId + CLAIMS_ENDPOINT_URI + + "/" + claimId, body); + response.then() + .assertThat() + .statusCode(HttpStatus.SC_OK); + + String defaultLocalClaimId = "aHR0cDovL3dzbzIub3JnL2NsYWltcy9yZXNvdXJjZVR5cGU="; + + response = getResponseOfDelete(CLAIM_DIALECTS_ENDPOINT_URI + LOCAL_CLAIMS_ENDPOINT_URI + + "/" + defaultLocalClaimId); + validateErrorResponse(response, HttpStatus.SC_FORBIDDEN, "CMT-60006"); + } + + @Test + public void testAddLocalClaimWithExistingURI() throws IOException { + + String body = readResource("claim-management-add-local-claim-with-existing-uri.json"); + Response response = getResponseOfPost(CLAIM_DIALECTS_ENDPOINT_URI + LOCAL_CLAIMS_ENDPOINT_URI, body); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_CONFLICT); + } + @Test public void testGetClaimsWithInvalidDialectId() { @@ -122,7 +250,7 @@ public void testGetExternalClaimsWhenEmpty() throws IOException { public void testGetExternalClaimsWithInvalidClaimId() throws IOException { String dialectId = createDialect(); - String claimId = createExternalClaim(dialectId); + String claimId = createExternalClaimMappedToDefaultLocalClaim(dialectId); Response response = getResponseOfGet(CLAIM_DIALECTS_ENDPOINT_URI + "/" + dialectId + CLAIMS_ENDPOINT_URI + "/" + testClaimId); @@ -132,20 +260,12 @@ public void testGetExternalClaimsWithInvalidClaimId() throws IOException { removeDialect(dialectId); } - @Test - public void testGetLocalClaimsWithInvalidClaimId() { - - Response response = - getResponseOfGet(CLAIM_DIALECTS_ENDPOINT_URI + LOCAL_CLAIMS_ENDPOINT_URI + "/" + testClaimId); - validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "CMT-50019", testClaimId); - } - @Test public void testUpdateExistingExternalClaimUri() throws IOException { String externalClaimUri = "http://updateddummy.org/claim/emailaddress"; String dialectId = createDialect(); - String claimId = createExternalClaim(dialectId); + String claimId = createExternalClaimMappedToDefaultLocalClaim(dialectId); String body = readResource("claim-management-update-external-claim-conflict.json"); Response response = getResponseOfPut(CLAIM_DIALECTS_ENDPOINT_URI + "/" + dialectId + CLAIMS_ENDPOINT_URI + @@ -157,17 +277,63 @@ public void testUpdateExistingExternalClaimUri() throws IOException { } @Test - public void testUpdateExistingLocalClaimUri() throws IOException { + public void testAddExternalClaimWithInvalidDialect() throws IOException { - String localClaimUri = "http://wso2.org/claims/dummyemailaddress"; - String claimId = createLocalClaim(); + String body = readResource("claim-management-add-external-claim.json"); + Response response = getResponseOfPost(CLAIM_DIALECTS_ENDPOINT_URI + "/" + testDialectId + CLAIMS_ENDPOINT_URI + , body); + validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "CMT-50027", testDialectId); + } - String body = readResource("claim-management-update-local-claim-conflict.json"); - Response response = getResponseOfPut(CLAIM_DIALECTS_ENDPOINT_URI + LOCAL_CLAIMS_ENDPOINT_URI + "/" + claimId, + @Test + public void testAddExternalClaimWithInvalidMappedClaim() throws IOException { + + String dialectId = createDialect(); + + String body = readResource("claim-management-add-external-claim-invalid-mapped-claim.json"); + Response response = getResponseOfPost(CLAIM_DIALECTS_ENDPOINT_URI + "/" + dialectId + CLAIMS_ENDPOINT_URI, body); - validateErrorResponse(response, HttpStatus.SC_CONFLICT, "CMT-50021", localClaimUri); + validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "CMT-50036"); - removeLocalClaim(claimId); + removeDialect(dialectId); + } + + @Test + public void testAddExternalClaimWithExistingClaimURI() throws IOException { + + String dialectId = createDialect(); + String claimId = createExternalClaimMappedToDefaultLocalClaim(dialectId); + + String body = readResource("claim-management-add-external-claim.json"); + Response response = getResponseOfPost(CLAIM_DIALECTS_ENDPOINT_URI + "/" + dialectId + + CLAIMS_ENDPOINT_URI, body); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_CONFLICT) + .body("code", equalTo("CMT-50038")); + + removeExternalClaim(dialectId, claimId); + removeDialect(dialectId); + } + + @Test + public void testAddExternalClaimWithAlreadyMappedLocalClaim() throws IOException { + + String dialectId = createDialect(); + String claimId = createExternalClaimMappedToDefaultLocalClaim(dialectId); + + String body = readResource("claim-management-add-external-claim-already-mapped.json"); + Response response = getResponseOfPost(CLAIM_DIALECTS_ENDPOINT_URI + "/" + dialectId + + CLAIMS_ENDPOINT_URI, body); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_BAD_REQUEST) + .body("code", equalTo("CMT-60004")); + + removeExternalClaim(dialectId, claimId); + removeDialect(dialectId); } @Test @@ -208,52 +374,6 @@ public void testAttributeFilteringNotImplemented() { validateErrorResponse(response, HttpStatus.SC_NOT_IMPLEMENTED, "CMT-50025"); } - @Test - public void testAddLocalClaimWithInvalidUsertore() throws IOException { - - String userstore = "DUMMY"; - String body = readResource("claim-management-add-local-claim-invalid-userstore.json"); - Response response = getResponseOfPost(CLAIM_DIALECTS_ENDPOINT_URI + LOCAL_CLAIMS_ENDPOINT_URI, body); - validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "CMT-50026", userstore); - } - - @Test - public void testAddExternalClaimWithInvalidDialect() throws IOException { - - String body = readResource("claim-management-add-external-claim.json"); - Response response = getResponseOfPost(CLAIM_DIALECTS_ENDPOINT_URI + "/" + testDialectId + CLAIMS_ENDPOINT_URI - , body); - validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "CMT-50027", testDialectId); - } - - @Test - public void testRemoveLocalClaimWithExternalClaimAssociation() throws IOException { - - String mappedLocalClaimId = "aHR0cDovL3dzbzIub3JnL2NsYWltcy9lbWFpbGFkZHJlc3M"; - String dialectId = createDialect(); - String claimId = createExternalClaim(dialectId); - - Response response = - getResponseOfDelete(CLAIM_DIALECTS_ENDPOINT_URI + LOCAL_CLAIMS_ENDPOINT_URI + "/" + mappedLocalClaimId); - validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "CMT-50031"); - - removeExternalClaim(dialectId, claimId); - removeDialect(dialectId); - } - - @Test - public void testAddExternalClaimWithInvalidMappedClaim() throws IOException { - - String dialectId = createDialect(); - - String body = readResource("claim-management-add-external-claim-invalid-mapped-claim.json"); - Response response = getResponseOfPost(CLAIM_DIALECTS_ENDPOINT_URI + "/" + dialectId + CLAIMS_ENDPOINT_URI, - body); - validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "CMT-50036"); - - removeDialect(dialectId); - } - private String createDialect() throws IOException { String body = readResource("claim-management-add-dialect.json"); @@ -277,7 +397,7 @@ private void removeDialect(String dialectId) { .statusCode(HttpStatus.SC_NO_CONTENT); } - private String createExternalClaim(String dialectId) throws IOException { + private String createExternalClaimMappedToDefaultLocalClaim(String dialectId) throws IOException { String body = readResource("claim-management-add-external-claim.json"); Response response = getResponseOfPost(CLAIM_DIALECTS_ENDPOINT_URI + "/" + dialectId + @@ -292,6 +412,21 @@ private String createExternalClaim(String dialectId) throws IOException { return location.substring(location.lastIndexOf("/") + 1); } + private String createExternalClaimMappedToCustomLocalClaim(String dialectId) throws IOException { + + String body = readResource("claim-management-add-external-claim-mapped-to-custom-local-claim.json"); + Response response = getResponseOfPost(CLAIM_DIALECTS_ENDPOINT_URI + "/" + dialectId + + CLAIMS_ENDPOINT_URI, body); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_CREATED) + .header(HttpHeaders.LOCATION, notNullValue()); + + String location = response.getHeader(HttpHeaders.LOCATION); + return location.substring(location.lastIndexOf("/") + 1); + } + private void removeExternalClaim(String dialectId, String externalClaimId) { getResponseOfDelete(CLAIM_DIALECTS_ENDPOINT_URI + "/" + dialectId + CLAIMS_ENDPOINT_URI + "/" + diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/ClaimManagementRestClient.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/ClaimManagementRestClient.java index b48eb0dbe98..aa862f7634d 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/ClaimManagementRestClient.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/ClaimManagementRestClient.java @@ -111,6 +111,17 @@ public void deleteExternalClaim(String dialectId, String claimId) throws IOExcep } } + public void updateExternalClaim(String dialectId, String claimId, ExternalClaimReq claimRequest) throws IOException { + + String endPointUrl = serverBasePath + CLAIM_DIALECTS_ENDPOINT_URI + PATH_SEPARATOR + dialectId + + CLAIMS_ENDPOINT_URI + PATH_SEPARATOR + claimId; + String jsonRequest = toJSONString(claimRequest); + try (CloseableHttpResponse response = getResponseOfHttpPut(endPointUrl, jsonRequest, getHeaders())) { + Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_OK, + "External claim update failed"); + } + } + private Header[] getHeaders() { Header[] headerList = new Header[2]; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/scim2/SCIM2UserTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/scim2/SCIM2UserTestCase.java index df7f584a172..c1e3dfddc7a 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/scim2/SCIM2UserTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/scim2/SCIM2UserTestCase.java @@ -380,75 +380,6 @@ public void testGetResourceTypes() throws Exception { } - @Test(dependsOnMethods = "testGetUser") - public void testUpdateUserWhenExternalClaimDeleted() throws Exception { - - AutomationContext context = new AutomationContext("IDENTITY", testUserMode); - backendURL = context.getContextUrls().getBackEndUrl(); - loginLogoutClient = new LoginLogoutClient(context); - sessionCookie = loginLogoutClient.login(); - HttpPost postRequest = new HttpPost(getPath()); - postRequest.addHeader(HttpHeaders.AUTHORIZATION, getAuthzHeader()); - postRequest.addHeader(HttpHeaders.CONTENT_TYPE, "application/json"); - - JSONObject rootObject = new JSONObject(); - - JSONArray schemas = new JSONArray(); - rootObject.put(SCHEMAS_ATTRIBUTE, schemas); - - JSONObject names = new JSONObject(); - names.put(FAMILY_NAME_ATTRIBUTE, "udaranga"); - names.put(GIVEN_NAME_ATTRIBUTE, "buddhima"); - - rootObject.put(NAME_ATTRIBUTE, names); - rootObject.put(USER_NAME_ATTRIBUTE, "wso2is"); - - JSONObject emailWork = new JSONObject(); - emailWork.put(TYPE_PARAM, EMAIL_TYPE_WORK_ATTRIBUTE); - emailWork.put(VALUE_PARAM, EMAIL_TYPE_WORK_CLAIM_VALUE); - - JSONObject emailHome = new JSONObject(); - emailHome.put(TYPE_PARAM, EMAIL_TYPE_HOME_ATTRIBUTE); - emailHome.put(VALUE_PARAM, EMAIL_TYPE_HOME_CLAIM_VALUE); - - JSONArray emails = new JSONArray(); - emails.add(emailWork); - emails.add(emailHome); - - rootObject.put(EMAILS_ATTRIBUTE, emails); - - rootObject.put(PASSWORD_ATTRIBUTE, PASSWORD); - - StringEntity entity = new StringEntity(rootObject.toString()); - postRequest.setEntity(entity); - HttpResponse postResponse = client.execute(postRequest); - assertEquals(postResponse.getStatusLine().getStatusCode(), 201, - "User has not been created in patch process successfully."); - Object responseObj = JSONValue.parse(EntityUtils.toString(postResponse.getEntity())); - EntityUtils.consume(postResponse.getEntity()); - String userId = ((JSONObject) responseObj).get(ID_ATTRIBUTE).toString(); - assertNotNull(userId); - String userResourcePath = getPath() + "/" + userId; - - claimMetadataManagementServiceClient = new ClaimMetadataManagementServiceClient(backendURL, sessionCookie); - claimMetadataManagementServiceClient.removeExternalClaim("urn:ietf:params:scim:schemas:core:2.0:User", - "urn:ietf:params:scim:schemas:core:2.0:User:name.honorificSuffix"); - HttpPatch request = new HttpPatch(userResourcePath); - StringEntity params = new StringEntity("{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"]," - + "\"Operations\":[{\"op\":\"replace\",\"path\":\"name\",\"value\":{\"givenName\":\"mahela\"," - + "\"familyName\":\"jayaxxxx\"}}]}"); - - request.setEntity(params); - request.addHeader(HttpHeaders.AUTHORIZATION, getAuthzHeader()); - request.addHeader(HttpHeaders.CONTENT_TYPE, "application/json"); - HttpResponse response = client.execute(request); - assertEquals(response.getStatusLine().getStatusCode(), 200, "User has not been updated successfully."); - Object responseObjAfterPatch = JSONValue.parse(EntityUtils.toString(response.getEntity())); - EntityUtils.consume(response.getEntity()); - String updatedGivenName = ((JSONObject) responseObjAfterPatch).get(NAME_ATTRIBUTE).toString(); - assertTrue(updatedGivenName.contains("mahela")); - } - private String getPath() { if (tenant.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { return SERVER_URL + SCIM2_USERS_ENDPOINT; diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-add-external-claim-already-mapped.json b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-add-external-claim-already-mapped.json new file mode 100644 index 00000000000..39b7d25b462 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-add-external-claim-already-mapped.json @@ -0,0 +1,4 @@ +{ + "claimURI": "http://dummy.org/claim/email", + "mappedLocalClaimURI": "http://wso2.org/claims/emailaddress" +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-add-external-claim-mapped-to-custom-local-claim.json b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-add-external-claim-mapped-to-custom-local-claim.json new file mode 100644 index 00000000000..fa63f4cb701 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-add-external-claim-mapped-to-custom-local-claim.json @@ -0,0 +1,4 @@ +{ + "claimURI": "http://updateddummy.org/claim/emailaddress", + "mappedLocalClaimURI": "http://wso2.org/claims/dummyemailaddress" +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-add-local-claim-with-existing-uri.json b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-add-local-claim-with-existing-uri.json new file mode 100644 index 00000000000..e0a2ba5205a --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-add-local-claim-with-existing-uri.json @@ -0,0 +1,21 @@ +{ + "claimURI": "http://wso2.org/claims/fullname", + "description": "Full Name Duplicate", + "displayOrder": 4, + "displayName": "Full Name Duplicate", + "readOnly": false, + "required": true, + "supportedByDefault": true, + "attributeMapping": [ + { + "mappedAttribute": "fullname", + "userstore": "PRIMARY" + } + ], + "properties": [ + { + "key": "isVerifiable", + "value": "false" + } + ] +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-update-default-external-claim.json b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-update-default-external-claim.json new file mode 100644 index 00000000000..3fbf744a648 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-update-default-external-claim.json @@ -0,0 +1,4 @@ +{ + "claimURI": "urn:ietf:params:scim:schemas:core:2.0:meta.resourceType", + "mappedLocalClaimURI": "http://wso2.org/claims/userType" +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-update-external-claim-already-mapped.json b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-update-external-claim-already-mapped.json new file mode 100644 index 00000000000..6f47f0e7a0d --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-update-external-claim-already-mapped.json @@ -0,0 +1,4 @@ +{ + "claimURI": "address", + "mappedLocalClaimURI": "http://wso2.org/claims/addresses.formatted" +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-update-external-claim-invalid-mapped-claim.json b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-update-external-claim-invalid-mapped-claim.json new file mode 100644 index 00000000000..4d9220ff90f --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/claim/management/v1/claim-management-update-external-claim-invalid-mapped-claim.json @@ -0,0 +1,4 @@ +{ + "claimURI": "http://updateddummy.org/claim/emailaddress", + "mappedLocalClaimURI": "http://wso2.org/claims/dummyclaim" +} From 8afb650a06b58575f41b871a0b2bdb93012f9a64 Mon Sep 17 00:00:00 2001 From: Amanda Ariyaratne Date: Tue, 12 Nov 2024 12:18:08 +0530 Subject: [PATCH 2/2] bump framework and api server versions --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index aad54e3ade0..73d6bb383b9 100755 --- a/pom.xml +++ b/pom.xml @@ -2365,7 +2365,7 @@ - 7.6.3 + 7.6.4 [5.14.67, 8.0.0) @@ -2477,7 +2477,7 @@ 2.0.17 - 1.2.249 + 1.2.250 1.3.45 5.5.9