use of io.jans.scim.model.scim2.user.UserResource in project jans by JanssenProject.
the class GroupAssignUserTest method getDummyPatient.
private UserResource getDummyPatient() {
UserResource user = new UserResource();
user.setUserName("test-" + Math.random());
user.setDisplayName(user.getUserName());
return user;
}
use of io.jans.scim.model.scim2.user.UserResource in project jans by JanssenProject.
the class PatchGroupTest method patch2.
@Test(dependsOnMethods = "patch1")
public void patch2() throws Exception {
List<UserResource> users = getTestUsers("aaa");
assertTrue(users.size() > 0);
// Define one "add" operation to insert the users retrieved in the created group
PatchOperation operation = new PatchOperation();
operation.setOperation("add");
operation.setPath("members");
List<Member> memberList = new ArrayList<>();
users.stream().forEach(u -> {
Member m = new Member();
m.setType(ScimResourceUtil.getType(usrClass));
m.setValue(u.getId());
m.setDisplay(u.getDisplayName());
m.setRef("/scim/v2/Users/" + u.getId());
memberList.add(m);
});
operation.setValue(memberList);
// Apply the patch to the group
PatchRequest pr = new PatchRequest();
pr.setOperations(Collections.singletonList(operation));
Response response = client.patchGroup(pr, group.getId(), null, null);
assertEquals(response.getStatus(), OK.getStatusCode());
group = response.readEntity(groupCls);
// Verify the new users are there
Set<Member> members = group.getMembers();
assertNotNull(members);
assertTrue(members.stream().allMatch(m -> m.getDisplay() != null && m.getType() != null && m.getValue() != null && m.getRef() != null));
// Verify the Ids are the same (both provided and returned)
Set<String> userIds = users.stream().map(UserResource::getId).collect(Collectors.toSet());
assertTrue(members.stream().map(Member::getValue).collect(Collectors.toSet()).equals(userIds));
}
use of io.jans.scim.model.scim2.user.UserResource 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.user.UserResource in project jans by JanssenProject.
the class ComplexSearchUserTest method searchSortByExternalId.
@Test
public void searchSortByExternalId() {
Response response = client.searchUsers(null, null, null, "externalId", "descending", "externalId", null);
assertEquals(response.getStatus(), OK.getStatusCode());
ListResponse listResponse = response.readEntity(ListResponse.class);
UserResource[] users = listResponse.getResources().stream().map(usrClass::cast).collect(Collectors.toList()).toArray(new UserResource[0]);
assertEquals(listResponse.getStartIndex(), 1);
assertEquals(listResponse.getItemsPerPage(), users.length);
assertEquals(listResponse.getResources().size(), users.length);
for (int i = 1; i < users.length; i++) {
String exId1 = users[i - 1].getExternalId();
String exId2 = users[i].getExternalId();
if (exId2 != null)
assertNotNull(exId1);
if (exId1 == null)
assertNull(exId2);
if (// In descending order exId1 must be higher than exId2
exId1 != null && exId2 != null)
assertFalse(exId1.compareTo(exId2) < 0);
}
}
use of io.jans.scim.model.scim2.user.UserResource in project jans by JanssenProject.
the class SampleTest method smallerClient.
// This tests assumes client_secret_basic for token endpoint authentication
@Test
@Parameters({ "domainURL", "OIDCMetadataUrl", "clientId", "clientSecret" })
public void smallerClient(String domainURL, String OIDCMetadataUrl, String clientId, String clientSecret) throws Exception {
IUserWebService myclient = ScimClientFactory.getClient(IUserWebService.class, domainURL, OIDCMetadataUrl, clientId, clientSecret, false);
SearchRequest sr = new SearchRequest();
sr.setFilter("userName eq \"admin\"");
Response response = myclient.searchUsersPost(sr);
assertEquals(response.getStatus(), OK.getStatusCode());
UserResource u = (UserResource) response.readEntity(ListResponse.class).getResources().get(0);
logger.debug("Hello {}!", u.getDisplayName());
}
Aggregations