use of org.apache.syncope.common.lib.to.RoleTO in project syncope by apache.
the class ApplicationITCase method read.
@Test
public void read() {
ApplicationTO mightyApp = applicationService.read("mightyApp");
assertNotNull(mightyApp);
assertEquals(2, mightyApp.getPrivileges().size());
assertTrue(mightyApp.getPrivileges().stream().anyMatch(privilege -> "postMighty".equals(privilege.getKey())));
PrivilegeTO getMighty = applicationService.readPrivilege("getMighty");
assertNotNull(getMighty);
assertEquals("mightyApp", getMighty.getApplication());
RoleTO role = roleService.read("Other");
assertFalse(role.getPrivileges().isEmpty());
assertEquals(1, role.getPrivileges().size());
assertTrue(role.getPrivileges().stream().anyMatch(privilege -> "postMighty".equals(privilege)));
}
use of org.apache.syncope.common.lib.to.RoleTO in project syncope by apache.
the class SearchITCase method searchByDynRole.
@Test
public void searchByDynRole() {
RoleTO role = RoleITCase.getSampleRoleTO("dynMembership");
role.setDynMembershipCond("cool==true");
Response response = roleService.create(role);
role = getObject(response.getLocation(), RoleService.class, RoleTO.class);
assertNotNull(role);
if (ElasticsearchDetector.isElasticSearchEnabled(syncopeService)) {
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
// ignore
}
}
PagedResult<UserTO> matchingUsers = userService.search(new AnyQuery.Builder().realm(SyncopeConstants.ROOT_REALM).fiql(SyncopeClient.getUserSearchConditionBuilder().inRoles(role.getKey()).query()).build());
assertNotNull(matchingUsers);
assertFalse(matchingUsers.getResult().isEmpty());
assertTrue(matchingUsers.getResult().stream().anyMatch(user -> "c9b2dec2-00a7-4855-97c0-d854842b4b24".equals(user.getKey())));
}
use of org.apache.syncope.common.lib.to.RoleTO in project syncope by apache.
the class RoleITCase method create.
@Test
public void create() {
RoleTO role = new RoleTO();
role.getRealms().add(SyncopeConstants.ROOT_REALM);
role.getRealms().add("/even/two");
role.getEntitlements().add(StandardEntitlement.LOG_LIST);
role.getEntitlements().add(StandardEntitlement.LOG_SET_LEVEL);
try {
createRole(role);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.InvalidRole, e.getType());
}
role.setKey("new" + getUUIDString());
role = createRole(role);
assertNotNull(role);
}
use of org.apache.syncope.common.lib.to.RoleTO in project syncope by apache.
the class RoleITCase method read.
@Test
public void read() {
RoleTO roleTO = roleService.read("Search for realm evenTwo");
assertNotNull(roleTO);
assertTrue(roleTO.getEntitlements().contains(StandardEntitlement.USER_READ));
}
use of org.apache.syncope.common.lib.to.RoleTO in project syncope by apache.
the class RoleITCase method delete.
@Test
public void delete() {
RoleTO role = getSampleRoleTO("delete");
Response response = roleService.create(role);
RoleTO actual = getObject(response.getLocation(), RoleService.class, RoleTO.class);
assertNotNull(actual);
roleService.delete(actual.getKey());
try {
roleService.read(actual.getKey());
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.NotFound, e.getType());
}
}
Aggregations