Search in sources :

Example 51 with Patch

use of org.wso2.carbon.identity.api.server.idp.v1.model.Patch in project product-is by wso2.

the class SCIM2CustomSchemaMeTestCase method testPatchRemoveMyAttributes.

@Test(dependsOnMethods = "testPatchReplaceMyAttributes", description = "Tests patch remove operation for custom " + "schema attributes with /Me api")
public void testPatchRemoveMyAttributes() throws Exception {
    String body = readResource("scim2-custom-schema-patch-remove-attribute.json");
    Response response = getResponseOfPatch(ME_ENDPOINT, body, SCIM_CONTENT_TYPE);
    ExtractableResponse<Response> extractableResponse = response.then().log().ifValidationFails().assertThat().statusCode(HttpStatus.SC_OK).and().assertThat().header(HttpHeaders.CONTENT_TYPE, SCIM_CONTENT_TYPE).extract();
    Assert.assertNotNull(extractableResponse);
    Object customSchema = extractableResponse.path(CUSTOM_SCHEMA_URI_WITH_ESCAPE_CHARS);
    assertNotNull(customSchema);
    Object country = ((LinkedHashMap) customSchema).get(COUNTRY_CLAIM_ATTRIBUTE_NAME);
    assertNull(country);
    LinkedHashMap manager = (LinkedHashMap) ((LinkedHashMap) customSchema).get(MANAGER_CLAIM_ATTRIBUTE_NAME);
    assertNotNull(manager);
    String managerEMail = manager.get(MANAGER_EMAIL_CLAIM_ATTRIBUTE_NAME).toString();
    assertEquals(managerEMail, MANAGER_EMAIL_LOCAL_CLAIM_VALUE_AFTER_REPLACE);
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) Response(io.restassured.response.Response) LinkedHashMap(java.util.LinkedHashMap) Test(org.testng.annotations.Test) SCIM2BaseTest(org.wso2.identity.integration.test.scim2.rest.api.SCIM2BaseTest)

Example 52 with Patch

use of org.wso2.carbon.identity.api.server.idp.v1.model.Patch in project product-is by wso2.

the class SCIM2CustomSchemaMeTestCase method testPatchAddMyAttributes.

@Test(dependsOnMethods = "testPutMyAttributes", description = "Tests patch add operation with custom schema " + "attributes using /Me api.")
public void testPatchAddMyAttributes() throws Exception {
    String body = readResource("scim2-custom-schema-patch-add-attribute.json");
    Response response = getResponseOfPatch(ME_ENDPOINT, body, SCIM_CONTENT_TYPE);
    ExtractableResponse<Response> extractableResponse = response.then().log().ifValidationFails().assertThat().statusCode(HttpStatus.SC_OK).and().assertThat().header(HttpHeaders.CONTENT_TYPE, SCIM_CONTENT_TYPE).extract();
    Assert.assertNotNull(extractableResponse);
    Object customSchema = extractableResponse.path(CUSTOM_SCHEMA_URI_WITH_ESCAPE_CHARS);
    assertNotNull(customSchema);
    LinkedHashMap manager = (LinkedHashMap) ((LinkedHashMap) customSchema).get(MANAGER_CLAIM_ATTRIBUTE_NAME);
    assertNotNull(manager);
    String managerEMail = manager.get(MANAGER_EMAIL_CLAIM_ATTRIBUTE_NAME).toString();
    assertEquals(managerEMail, "piraveenaAdd@gmail.com");
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) Response(io.restassured.response.Response) LinkedHashMap(java.util.LinkedHashMap) Test(org.testng.annotations.Test) SCIM2BaseTest(org.wso2.identity.integration.test.scim2.rest.api.SCIM2BaseTest)

Example 53 with Patch

use of org.wso2.carbon.identity.api.server.idp.v1.model.Patch in project product-is by wso2.

the class SCIM2CustomSchemaMeTestCase method testPatchReplaceMyAttributes.

@Test(dependsOnMethods = "testGetMe", description = "Tests patch replace operation with custom schema " + "attributes with /Me api.")
public void testPatchReplaceMyAttributes() throws Exception {
    String body = readResource("scim2-custom-schema-patch-replace-attribute.json");
    Response response = getResponseOfPatch(ME_ENDPOINT, body, SCIM_CONTENT_TYPE);
    ExtractableResponse<Response> extractableResponse = response.then().log().ifValidationFails().assertThat().statusCode(HttpStatus.SC_OK).and().assertThat().header(HttpHeaders.CONTENT_TYPE, SCIM_CONTENT_TYPE).extract();
    Assert.assertNotNull(extractableResponse);
    Object customSchema = extractableResponse.path(CUSTOM_SCHEMA_URI_WITH_ESCAPE_CHARS);
    assertNotNull(customSchema);
    String country = ((LinkedHashMap) customSchema).get(COUNTRY_CLAIM_ATTRIBUTE_NAME).toString();
    assertEquals(country, COUNTRY_LOCAL_CLAIM_VALUE_AFTER_REPLACE);
    LinkedHashMap manager = (LinkedHashMap) ((LinkedHashMap) customSchema).get(MANAGER_CLAIM_ATTRIBUTE_NAME);
    assertNotNull(manager);
    String managerEMail = manager.get(MANAGER_EMAIL_CLAIM_ATTRIBUTE_NAME).toString();
    assertEquals(managerEMail, MANAGER_EMAIL_LOCAL_CLAIM_VALUE_AFTER_REPLACE);
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) Response(io.restassured.response.Response) LinkedHashMap(java.util.LinkedHashMap) Test(org.testng.annotations.Test) SCIM2BaseTest(org.wso2.identity.integration.test.scim2.rest.api.SCIM2BaseTest)

Example 54 with Patch

use of org.wso2.carbon.identity.api.server.idp.v1.model.Patch in project product-is by wso2.

the class SCIM2CustomSchemaUserTestCase method testPatchAddUserAttributes.

@Test(dependsOnMethods = "testPutUserAttributes", description = "Tests patch add operation with custom schema " + "attributes using /Users api.")
public void testPatchAddUserAttributes() throws Exception {
    String body = readResource("scim2-custom-schema-patch-add-attribute.json");
    Response response = getResponseOfPatch(userIdEndpointURL, body, SCIM_CONTENT_TYPE);
    ExtractableResponse<Response> extractableResponse = response.then().log().ifValidationFails().assertThat().statusCode(HttpStatus.SC_OK).and().assertThat().header(HttpHeaders.CONTENT_TYPE, SCIM_CONTENT_TYPE).extract();
    Assert.assertNotNull(extractableResponse);
    Object customSchema = extractableResponse.path(CUSTOM_SCHEMA_URI_WITH_ESCAPE_CHARS);
    assertNotNull(customSchema);
    LinkedHashMap manager = (LinkedHashMap) ((LinkedHashMap) customSchema).get(MANAGER_CLAIM_ATTRIBUTE_NAME);
    assertNotNull(manager);
    String managerEMail = manager.get(MANAGER_EMAIL_CLAIM_ATTRIBUTE_NAME).toString();
    assertEquals(managerEMail, MANAGER_EMAIL_LOCAL_CLAIM_VALUE_AFTER_ADD);
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) Response(io.restassured.response.Response) LinkedHashMap(java.util.LinkedHashMap) Test(org.testng.annotations.Test) SCIM2BaseTest(org.wso2.identity.integration.test.scim2.rest.api.SCIM2BaseTest)

Example 55 with Patch

use of org.wso2.carbon.identity.api.server.idp.v1.model.Patch in project product-is by wso2.

the class SCIM2CustomSchemaUserTestCase method testPatchReplaceUserAttributes.

@Test(dependsOnMethods = "testGetUsers", description = "Tests patch replace operation with custom schema " + "attributes with /Users api.")
public void testPatchReplaceUserAttributes() throws Exception {
    String body = readResource("scim2-custom-schema-patch-replace-attribute.json");
    Response response = getResponseOfPatch(userIdEndpointURL, body, SCIM_CONTENT_TYPE);
    ExtractableResponse<Response> extractableResponse = response.then().log().ifValidationFails().assertThat().statusCode(HttpStatus.SC_OK).and().assertThat().header(HttpHeaders.CONTENT_TYPE, SCIM_CONTENT_TYPE).extract();
    Assert.assertNotNull(extractableResponse);
    Object customSchema = extractableResponse.path(CUSTOM_SCHEMA_URI_WITH_ESCAPE_CHARS);
    assertNotNull(customSchema);
    String country = ((LinkedHashMap) customSchema).get(COUNTRY_CLAIM_ATTRIBUTE_NAME).toString();
    assertEquals(country, COUNTRY_LOCAL_CLAIM_VALUE_AFTER_REPLACE);
    LinkedHashMap manager = (LinkedHashMap) ((LinkedHashMap) customSchema).get(MANAGER_CLAIM_ATTRIBUTE_NAME);
    assertNotNull(manager);
    String managerEMail = manager.get(MANAGER_EMAIL_CLAIM_ATTRIBUTE_NAME).toString();
    assertEquals(managerEMail, MANAGER_EMAIL_LOCAL_CLAIM_VALUE_AFTER_REPLACE);
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) Response(io.restassured.response.Response) LinkedHashMap(java.util.LinkedHashMap) Test(org.testng.annotations.Test) SCIM2BaseTest(org.wso2.identity.integration.test.scim2.rest.api.SCIM2BaseTest)

Aggregations

BadRequestException (org.wso2.charon3.core.exceptions.BadRequestException)19 ArrayList (java.util.ArrayList)11 HashMap (java.util.HashMap)11 Test (org.testng.annotations.Test)11 JSONArray (org.json.JSONArray)9 JSONObject (org.json.JSONObject)9 Attribute (org.wso2.charon3.core.attributes.Attribute)9 ComplexAttribute (org.wso2.charon3.core.attributes.ComplexAttribute)9 MultiValuedAttribute (org.wso2.charon3.core.attributes.MultiValuedAttribute)9 SimpleAttribute (org.wso2.charon3.core.attributes.SimpleAttribute)9 CharonException (org.wso2.charon3.core.exceptions.CharonException)9 SCIMResponse (org.wso2.charon3.core.protocol.SCIMResponse)8 List (java.util.List)7 NotImplementedException (org.wso2.charon3.core.exceptions.NotImplementedException)7 LinkedHashMap (java.util.LinkedHashMap)6 Map (java.util.Map)6 JSONException (org.json.JSONException)6 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)6 AttributeSchema (org.wso2.charon3.core.schema.AttributeSchema)6 ExtractableResponse (io.restassured.response.ExtractableResponse)5