use of com.evolveum.midpoint.security.api.MidPointPrincipal in project midpoint by Evolveum.
the class TestValidityRecomputeTask method test142BarbossaDisableAssignmentRedJudge.
@Test
public void test142BarbossaDisableAssignmentRedJudge() throws Exception {
final String TEST_NAME = "test142BarbossaDisableAssignmentRedJudge";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TestValidityRecomputeTask.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID);
// WHEN
TestUtil.displayWhen(TEST_NAME);
modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.DISABLED, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true);
// WHEN
TestUtil.displayWhen(TEST_NAME);
waitForTaskNextRunAssertSuccess(TASK_VALIDITY_SCANNER_OID, true);
// THEN
TestUtil.displayThen(TEST_NAME);
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true);
assertNoDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME);
assertDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, ROLE_SAILOR_DRINK);
PrismObject<UserType> user = getUser(USER_BARBOSSA_OID);
display("User after", user);
assertLinks(user, 1);
MidPointPrincipal principal = userProfileService.getPrincipal(user);
assertNotAuthorized(principal, AUTZ_PUNISH_URL);
}
use of com.evolveum.midpoint.security.api.MidPointPrincipal in project midpoint by Evolveum.
the class TestValidityRecomputeTask method testJackAssignRoleJudgeValid.
private void testJackAssignRoleJudgeValid(final String TEST_NAME, ActivationType activationType, Task task, OperationResult result) throws Exception {
// WHEN
TestUtil.displayWhen(TEST_NAME);
assignRole(USER_JACK_OID, ROLE_BIG_JUDGE_OID, activationType, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
assertDummyAccount(null, USER_JACK_USERNAME);
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_JACK_USERNAME);
// WHEN
TestUtil.displayWhen(TEST_NAME);
waitForTaskNextRunAssertSuccess(TASK_VALIDITY_SCANNER_OID, true);
// THEN
TestUtil.displayThen(TEST_NAME);
assertDummyAccount(null, USER_JACK_USERNAME);
PrismObject<UserType> user = getUser(USER_JACK_OID);
display("User after", user);
assertLinks(user, 2);
assert11xUserOk(user);
MidPointPrincipal principal = userProfileService.getPrincipal(user);
assertAuthorized(principal, AUTZ_PUNISH_URL);
// CLEANUP
unassignAllRoles(USER_JACK_OID);
assertNoDummyAccount(null, USER_JACK_USERNAME);
}
use of com.evolveum.midpoint.security.api.MidPointPrincipal in project midpoint by Evolveum.
the class TestValidityRecomputeTask method test146BarbossaDisableBothRedAssignments.
@Test
public void test146BarbossaDisableBothRedAssignments() throws Exception {
final String TEST_NAME = "test146BarbossaDisableBothRedAssignments";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TestValidityRecomputeTask.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
AssignmentType judgeAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID);
AssignmentType sailorAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_SAILOR_OID);
ObjectDelta<UserType> objectDelta = ObjectDelta.createModificationReplaceProperty(UserType.class, USER_BARBOSSA_OID, new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(judgeAssignment.getId()), new NameItemPathSegment(AssignmentType.F_ACTIVATION), new NameItemPathSegment(ActivationType.F_ADMINISTRATIVE_STATUS)), prismContext, ActivationStatusType.DISABLED);
objectDelta.addModificationReplaceProperty(new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(sailorAssignment.getId()), new NameItemPathSegment(AssignmentType.F_ACTIVATION), new NameItemPathSegment(ActivationType.F_ADMINISTRATIVE_STATUS)), ActivationStatusType.DISABLED);
// WHEN
TestUtil.displayWhen(TEST_NAME);
modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false);
// WHEN
TestUtil.displayWhen(TEST_NAME);
waitForTaskNextRunAssertSuccess(TASK_VALIDITY_SCANNER_OID, true);
// THEN
TestUtil.displayThen(TEST_NAME);
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false);
assertNoDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME);
assertNoDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME);
PrismObject<UserType> user = getUser(USER_BARBOSSA_OID);
display("User after", user);
assertLinks(user, 1);
MidPointPrincipal principal = userProfileService.getPrincipal(user);
assertNotAuthorized(principal, AUTZ_PUNISH_URL);
}
use of com.evolveum.midpoint.security.api.MidPointPrincipal in project midpoint by Evolveum.
the class TestValidityRecomputeTask method test149BarbossaDisableBothRedAssignmentsUnassign.
/**
* Unassign disabled assignments.
*/
@Test
public void test149BarbossaDisableBothRedAssignmentsUnassign() throws Exception {
final String TEST_NAME = "test149BarbossaDisableBothRedAssignmentsUnassign";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TestValidityRecomputeTask.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
AssignmentType judgeAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_JUDGE_OID);
AssignmentType judgeAssignmentLight = new AssignmentType();
judgeAssignmentLight.setId(judgeAssignment.getId());
AssignmentType sailorAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_SAILOR_OID);
AssignmentType sailorAssignmentLight = new AssignmentType();
sailorAssignmentLight.setId(sailorAssignment.getId());
ObjectDelta<UserType> objectDelta = ObjectDelta.createModificationReplaceProperty(UserType.class, USER_BARBOSSA_OID, new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(judgeAssignment.getId()), new NameItemPathSegment(AssignmentType.F_ACTIVATION), new NameItemPathSegment(ActivationType.F_ADMINISTRATIVE_STATUS)), prismContext, ActivationStatusType.DISABLED);
objectDelta.addModificationReplaceProperty(new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(sailorAssignment.getId()), new NameItemPathSegment(AssignmentType.F_ACTIVATION), new NameItemPathSegment(ActivationType.F_ADMINISTRATIVE_STATUS)), ActivationStatusType.DISABLED);
modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result);
assertNoDummyAccount(null, USER_BARBOSSA_USERNAME);
waitForTaskNextRunAssertSuccess(TASK_VALIDITY_SCANNER_OID, true);
assertNoDummyAccount(null, USER_BARBOSSA_USERNAME);
PrismObject<UserType> user = getUser(USER_BARBOSSA_OID);
display("User after", user);
assertLinks(user, 1);
MidPointPrincipal principal = userProfileService.getPrincipal(user);
assertNotAuthorized(principal, AUTZ_PUNISH_URL);
objectDelta = ObjectDelta.createModificationDeleteContainer(UserType.class, USER_BARBOSSA_OID, new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT)), prismContext, judgeAssignmentLight);
objectDelta.addModificationDeleteContainer(new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT)), sailorAssignmentLight);
display("Unassign delta", objectDelta);
// WHEN
TestUtil.displayWhen(TEST_NAME);
modelService.executeChanges(MiscSchemaUtil.createCollection(objectDelta), null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false);
// to be on the safe side
assertNoDummyAccount(null, USER_BARBOSSA_USERNAME);
// WHEN
TestUtil.displayWhen(TEST_NAME);
waitForTaskNextRunAssertSuccess(TASK_VALIDITY_SCANNER_OID, true);
// THEN
TestUtil.displayThen(TEST_NAME);
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, false);
assertNoDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME);
assertNoDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME);
// to be on the safe side
assertNoDummyAccount(null, USER_BARBOSSA_USERNAME);
user = getUser(USER_BARBOSSA_OID);
display("User after", user);
assertLinks(user, 1);
assertNoAssignments(user);
principal = userProfileService.getPrincipal(user);
assertNotAuthorized(principal, AUTZ_PUNISH_URL);
}
use of com.evolveum.midpoint.security.api.MidPointPrincipal in project midpoint by Evolveum.
the class TestValidityRecomputeTask method test145BarbossaEnableAssignmentRedSailor.
@Test
public void test145BarbossaEnableAssignmentRedSailor() throws Exception {
final String TEST_NAME = "test145BarbossaEnableAssignmentRedSailor";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TestValidityRecomputeTask.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
AssignmentType assignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_RED_SAILOR_OID);
// WHEN
TestUtil.displayWhen(TEST_NAME);
modifyAssignmentAdministrativeStatus(USER_BARBOSSA_OID, assignment.getId(), ActivationStatusType.ENABLED, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true);
// WHEN
TestUtil.displayWhen(TEST_NAME);
assertDummyAccount(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, true);
assertDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, ROLE_JUDGE_TITLE);
assertDummyAccountAttribute(RESOURCE_DUMMY_RED_NAME, USER_BARBOSSA_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, ROLE_JUDGE_DRINK, ROLE_SAILOR_DRINK);
PrismObject<UserType> user = getUser(USER_BARBOSSA_OID);
display("User after", user);
assertLinks(user, 1);
MidPointPrincipal principal = userProfileService.getPrincipal(user);
assertAuthorized(principal, AUTZ_PUNISH_URL);
}
Aggregations