use of io.jans.scim.model.scim2.patch.PatchRequest in project jans by JanssenProject.
the class PatchUserExtTest method patchJson.
@Parameters({ "user_patch_ext" })
@Test(dependsOnMethods = "create")
public void patchJson(String patchRequest) {
Response response = client.patchUser(patchRequest, user.getId(), null, null);
assertEquals(response.getStatus(), OK.getStatusCode());
UserResource other = response.readEntity(usrClass);
// For help on usage of io.jans.scim.model.scim2.CustomAttributes class, read its api docs (oxtrust-scim maven project)
CustomAttributes custAttrs = other.getCustomAttributes(USER_EXT_SCHEMA_ID);
// Verify new items appeared in scimCustomSecond
List<Date> scimCustomSecond = custAttrs.getValues("scimCustomSecond", Date.class);
assertEquals(scimCustomSecond.size(), 6);
// Verify change in value of scimCustomThird
int scimCustomThird = custAttrs.getValue("scimCustomThird", Integer.class);
assertEquals(1, scimCustomThird);
// Verify scimCustomFirst disappeared
assertNull(custAttrs.getValue("scimCustomFirst", String.class));
// Verify some others disappeared too
assertNull(other.getAddresses().get(0).getType());
assertNull(other.getName().getGivenName());
Stream<String> types = other.getPhoneNumbers().stream().map(PhoneNumber::getType);
assertTrue(types.map(Optional::ofNullable).noneMatch(Optional::isPresent));
}
use of io.jans.scim.model.scim2.patch.PatchRequest in project jans by JanssenProject.
the class PatchDeleteUserTest method delete1.
@Parameters({ "user_patchdelete" })
@Test(dependsOnMethods = "createForDel")
public void delete1(String patchRequest) {
Response response = client.patchUser(patchRequest, user.getId(), null, null);
assertEquals(response.getStatus(), OK.getStatusCode());
UserResource other = response.readEntity(usrClass);
for (int i = 0; i < 2; i++) {
assertNull(other.getName().getMiddleName());
assertNull(other.getNickName());
assertNull(other.getEntitlements());
assertNull(other.getAddresses().get(0).getPostalCode());
assertNull(other.getAddresses().get(0).getLocality());
assertNotNull(other.getAddresses().get(0).getStreetAddress());
// Double check
response = client.getUserById(user.getId(), null, null);
other = response.readEntity(usrClass);
}
}
use of io.jans.scim.model.scim2.patch.PatchRequest in project jans by JanssenProject.
the class PatchReplaceUserTest method jsonPathPatch1.
@Parameters({ "user_patchreplace_3" })
@Test(dependsOnMethods = "jsonNoPathPatch2")
public void jsonPathPatch1(String patchRequest) {
Response response = client.patchUser(patchRequest, user.getId(), null, null);
assertEquals(response.getStatus(), OK.getStatusCode());
UserResource other = response.readEntity(usrClass);
// Verify display name changed
assertNotEquals(user.getDisplayName(), other.getDisplayName());
// Verify some name components changed
assertNotEquals(user.getName().getFamilyName(), other.getName().getFamilyName());
assertNotEquals(user.getName().getMiddleName(), other.getName().getMiddleName());
assertNotEquals(user.getName().getGivenName(), other.getName().getGivenName());
assertEquals(user.getName().getHonorificPrefix(), other.getName().getHonorificPrefix());
assertEquals(user.getName().getHonorificSuffix(), other.getName().getHonorificSuffix());
// Verify is now active
assertTrue(other.getActive());
user = other;
}
use of io.jans.scim.model.scim2.patch.PatchRequest in project jans by JanssenProject.
the class PatchValueFilterUserTest method objectPatch.
@Test(dependsOnMethods = "patch")
public void objectPatch() {
PatchRequest request = new PatchRequest();
request.setOperations(new ArrayList<>());
PatchOperation del = new PatchOperation();
del.setOperation("remove");
del.setPath("emails[type sw \"hobby\"]");
request.getOperations().add(del);
del = new PatchOperation();
del.setOperation("remove");
del.setPath("phoneNumbers[primary pr or value co \" \"].type");
request.getOperations().add(del);
del = new PatchOperation();
del.setOperation("remove");
del.setPath("addresses[region eq \"somewhere\" and primary ne true].locality");
request.getOperations().add(del);
Response response = client.patchUser(request, user.getId(), null, null);
assertEquals(response.getStatus(), OK.getStatusCode());
user = response.readEntity(usrClass);
assertNull(user.getEmails());
assertTrue(user.getPhoneNumbers().stream().allMatch(ph -> ph.getType() == null));
// No change in addresses
assertEquals(user.getAddresses().size(), 1);
assertNull(user.getAddresses().get(0).getLocality());
}
use of io.jans.scim.model.scim2.patch.PatchRequest in project oxTrust by GluuFederation.
the class BulkWebService method execute.
private Pair<Response, String> execute(Verb verb, BaseScimWebService ws, String data, String fragment) {
Response response = null;
String idCreated = null;
try {
if (ws == userWS)
switch(verb) {
case PUT:
UserResource user = mapper.readValue(data, UserResource.class);
response = userWS.updateUser(user, fragment, "id", null);
break;
case DELETE:
response = userWS.deleteUser(fragment);
break;
case PATCH:
PatchRequest pr = mapper.readValue(data, PatchRequest.class);
response = userWS.patchUser(pr, fragment, "id", null);
break;
case POST:
user = mapper.readValue(data, UserResource.class);
response = userWS.createUser(user, "id", null);
if (CREATED.getStatusCode() == response.getStatus()) {
user = mapper.readValue(response.getEntity().toString(), UserResource.class);
idCreated = user.getId();
}
break;
}
else if (ws == groupWS)
switch(verb) {
case PUT:
GroupResource group = mapper.readValue(data, GroupResource.class);
response = groupWS.updateGroup(group, fragment, "id", null);
break;
case DELETE:
response = groupWS.deleteGroup(fragment);
break;
case PATCH:
PatchRequest pr = mapper.readValue(data, PatchRequest.class);
response = groupWS.patchGroup(pr, fragment, "id", null);
break;
case POST:
group = mapper.readValue(data, GroupResource.class);
response = groupWS.createGroup(group, "id", null);
if (CREATED.getStatusCode() == response.getStatus()) {
group = mapper.readValue(response.getEntity().toString(), GroupResource.class);
idCreated = group.getId();
}
break;
}
else if (ws == fidoDeviceWS)
switch(verb) {
case PUT:
FidoDeviceResource dev = mapper.readValue(data, FidoDeviceResource.class);
response = fidoDeviceWS.updateDevice(dev, fragment, "id", null);
break;
case DELETE:
response = fidoDeviceWS.deleteDevice(fragment);
break;
case PATCH:
PatchRequest pr = mapper.readValue(data, PatchRequest.class);
response = fidoDeviceWS.patchDevice(pr, fragment, "id", null);
break;
case POST:
response = fidoDeviceWS.createDevice();
break;
}
} catch (Exception e) {
log.error(e.getMessage(), e);
response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
}
return new Pair<Response, String>(response, idCreated);
}
Aggregations