use of com.evolveum.midpoint.security.api.MidPointPrincipal in project midpoint by Evolveum.
the class TestEmpty method test020UserProfileServiceMockUsername.
@Test
public void test020UserProfileServiceMockUsername() throws Exception {
final String TEST_NAME = "test020UserProfileServiceMockUsername";
TestUtil.displayTestTile(TEST_NAME);
MidPointPrincipal principal = userProfileService.getPrincipal(USER_JACK_USERNAME);
assertPrincipalJack(principal);
}
use of com.evolveum.midpoint.security.api.MidPointPrincipal in project midpoint by Evolveum.
the class UserProfileServiceMock method createPrincipal.
private MidPointPrincipal createPrincipal(PrismObject<UserType> user, OperationResult result) {
if (user == null) {
return null;
}
PrismObject<SystemConfigurationType> systemConfiguration = null;
try {
systemConfiguration = repositoryService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, result);
} catch (ObjectNotFoundException | SchemaException e) {
LOGGER.warn("No system configuration: {}", e.getMessage(), e);
}
MidPointPrincipal principal = new MidPointPrincipal(user.asObjectable());
initializePrincipalFromAssignments(principal, systemConfiguration);
return principal;
}
use of com.evolveum.midpoint.security.api.MidPointPrincipal in project midpoint by Evolveum.
the class TestSecurityPrincipal method test110GuybrushRoleNicePirate.
@Test
public void test110GuybrushRoleNicePirate() throws Exception {
final String TEST_NAME = "test110GuybrushRoleNicePirate";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
login(USER_ADMINISTRATOR_USERNAME);
Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assignRole(USER_GUYBRUSH_OID, ROLE_NICE_PIRATE_OID, task, result);
resetAuthentication();
// WHEN
MidPointPrincipal principal = userProfileService.getPrincipal(USER_GUYBRUSH_USERNAME);
// THEN
display("Principal guybrush", principal);
assertEquals("Wrong number of authorizations", 2, principal.getAuthorities().size());
assertNotAuthorized(principal, AUTZ_LOOT_URL);
assertNotAuthorized(principal, AUTZ_COMMAND_URL);
}
use of com.evolveum.midpoint.security.api.MidPointPrincipal in project midpoint by Evolveum.
the class TestSecurityPrincipal method test010GetUserAdministrator.
@Test
public void test010GetUserAdministrator() throws Exception {
final String TEST_NAME = "test010GetUserAdministrator";
TestUtil.displayTestTile(this, TEST_NAME);
resetAuthentication();
// WHEN
MidPointPrincipal principal = userProfileService.getPrincipal(USER_ADMINISTRATOR_USERNAME);
// THEN
display("Administrator principal", principal);
assertEquals("Wrong number of authorizations", 1, principal.getAuthorities().size());
assertHasAuthotizationAllow(principal.getAuthorities().iterator().next(), AuthorizationConstants.AUTZ_ALL_URL);
assertAuthorized(principal, AUTZ_LOOT_URL);
assertAuthorized(principal, AUTZ_COMMAND_URL);
}
use of com.evolveum.midpoint.security.api.MidPointPrincipal in project midpoint by Evolveum.
the class TestSecurityPrincipal method test109JackUnassignRolePirate.
@Test
public void test109JackUnassignRolePirate() throws Exception {
final String TEST_NAME = "test109JackUnassignRolePirate";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
login(USER_ADMINISTRATOR_USERNAME);
Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result);
resetAuthentication();
// WHEN
MidPointPrincipal principal = userProfileService.getPrincipal(USER_JACK_USERNAME);
// THEN
assertJack(principal);
assertEquals("Wrong number of authorizations", 0, principal.getAuthorities().size());
assertNotAuthorized(principal, AUTZ_LOOT_URL);
assertNotAuthorized(principal, AUTZ_COMMAND_URL);
assertAdminGuiConfigurations(principal, 0, 1, 3, 1, 0);
}
Aggregations