Search in sources :

Example 26 with NameItemPathSegment

use of com.evolveum.midpoint.prism.path.NameItemPathSegment in project midpoint by Evolveum.

the class TestValidityRecomputeTask method test147BarbossaEnableBothRedAssignments.

@Test
public void test147BarbossaEnableBothRedAssignments() throws Exception {
    final String TEST_NAME = "test147BarbossaEnableBothRedAssignments";
    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.ENABLED);
    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.ENABLED);
    // 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, 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);
    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);
}
Also used : TestTriggerTask(com.evolveum.midpoint.model.intest.TestTriggerTask) Task(com.evolveum.midpoint.task.api.Task) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 27 with NameItemPathSegment

use of com.evolveum.midpoint.prism.path.NameItemPathSegment in project midpoint by Evolveum.

the class TestValidityRecomputeTask method test136BarbossaDisableBothAssignments.

@Test
public void test136BarbossaDisableBothAssignments() throws Exception {
    final String TEST_NAME = "test136BarbossaDisableBothAssignments";
    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_JUDGE_OID);
    AssignmentType sailorAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_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);
    assertNoDummyAccount(null, USER_BARBOSSA_USERNAME);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    waitForTaskNextRunAssertSuccess(TASK_VALIDITY_SCANNER_OID, true);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    assertNoDummyAccount(null, USER_BARBOSSA_USERNAME);
    PrismObject<UserType> user = getUser(USER_BARBOSSA_OID);
    display("User after", user);
    assertLinks(user, 0);
    MidPointPrincipal principal = userProfileService.getPrincipal(user);
    assertNotAuthorized(principal, AUTZ_PUNISH_URL);
}
Also used : TestTriggerTask(com.evolveum.midpoint.model.intest.TestTriggerTask) Task(com.evolveum.midpoint.task.api.Task) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 28 with NameItemPathSegment

use of com.evolveum.midpoint.prism.path.NameItemPathSegment in project midpoint by Evolveum.

the class TestValidityRecomputeTask method test139BarbossaDisableBothAssignmentsUnassign.

/**
	 * Unassign disabled assignments.
	 */
@Test
public void test139BarbossaDisableBothAssignmentsUnassign() throws Exception {
    final String TEST_NAME = "test139BarbossaDisableBothAssignmentsUnassign";
    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_JUDGE_OID);
    AssignmentType judgeAssignmentLight = new AssignmentType();
    judgeAssignmentLight.setId(judgeAssignment.getId());
    AssignmentType sailorAssignment = getUserAssignment(USER_BARBOSSA_OID, ROLE_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, 0);
    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);
    assertNoDummyAccount(null, USER_BARBOSSA_USERNAME);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    waitForTaskNextRunAssertSuccess(TASK_VALIDITY_SCANNER_OID, true);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    assertNoDummyAccount(null, USER_BARBOSSA_USERNAME);
    user = getUser(USER_BARBOSSA_OID);
    display("User after", user);
    assertLinks(user, 0);
    assertNoAssignments(user);
    principal = userProfileService.getPrincipal(user);
    assertNotAuthorized(principal, AUTZ_PUNISH_URL);
}
Also used : TestTriggerTask(com.evolveum.midpoint.model.intest.TestTriggerTask) Task(com.evolveum.midpoint.task.api.Task) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 29 with NameItemPathSegment

use of com.evolveum.midpoint.prism.path.NameItemPathSegment in project midpoint by Evolveum.

the class TestValidityRecomputeTask method test127JackDeleteActivationAssignmentJudge.

@Test
public void test127JackDeleteActivationAssignmentJudge() throws Exception {
    final String TEST_NAME = "test127JackDeleteActivationAssignmentJudge";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(TestValidityRecomputeTask.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assertDummyAccount(null, USER_JACK_USERNAME);
    AssignmentType judgeAssignment = getJudgeAssignment(USER_JACK_OID);
    ActivationType activationType = new ActivationType();
    activationType.setAdministrativeStatus(ActivationStatusType.ENABLED);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modifyObjectDeleteContainer(UserType.class, USER_JACK_OID, new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(judgeAssignment.getId()), new NameItemPathSegment(AssignmentType.F_ACTIVATION)), task, result, activationType);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    PrismObject<UserType> user = getUser(USER_JACK_OID);
    display("User after", user);
    assertDummyAccount(null, USER_JACK_USERNAME);
    assert11xUserOk(user);
}
Also used : TestTriggerTask(com.evolveum.midpoint.model.intest.TestTriggerTask) Task(com.evolveum.midpoint.task.api.Task) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 30 with NameItemPathSegment

use of com.evolveum.midpoint.prism.path.NameItemPathSegment in project midpoint by Evolveum.

the class TestValidityRecomputeTask method test128JackAssignmentJudgeValidToSetInvalid.

@Test
public void test128JackAssignmentJudgeValidToSetInvalid() throws Exception {
    final String TEST_NAME = "test128JackAssignmentJudgeValidToSetInvalid";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(TestValidityRecomputeTask.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assertDummyAccount(null, USER_JACK_USERNAME);
    AssignmentType judgeAssignment = getJudgeAssignment(USER_JACK_OID);
    ActivationType activationType = new ActivationType();
    XMLGregorianCalendar validTo = clock.currentTimeXMLGregorianCalendar();
    // one hour ago
    validTo.add(XmlTypeConverter.createDuration(-60 * 60 * 1000));
    activationType.setValidTo(validTo);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modifyObjectReplaceContainer(UserType.class, USER_JACK_OID, new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(judgeAssignment.getId()), new NameItemPathSegment(AssignmentType.F_ACTIVATION)), task, result, activationType);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    PrismObject<UserType> user = getUser(USER_JACK_OID);
    display("User after", user);
    assertNoDummyAccount(null, USER_JACK_USERNAME);
    assert11xUserOk(user);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) TestTriggerTask(com.evolveum.midpoint.model.intest.TestTriggerTask) Task(com.evolveum.midpoint.task.api.Task) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Aggregations

NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)69 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)61 IdItemPathSegment (com.evolveum.midpoint.prism.path.IdItemPathSegment)46 Test (org.testng.annotations.Test)35 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)22 QName (javax.xml.namespace.QName)20 Task (com.evolveum.midpoint.task.api.Task)19 ItemPathSegment (com.evolveum.midpoint.prism.path.ItemPathSegment)15 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)14 TestTriggerTask (com.evolveum.midpoint.model.intest.TestTriggerTask)11 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)10 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)10 UserType (com.evolveum.midpoint.prism.foo.UserType)7 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)7 AssignmentType (com.evolveum.midpoint.prism.foo.AssignmentType)6 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)6 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)6 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)5 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)5 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)4