Search in sources :

Example 26 with DummyGroup

use of com.evolveum.icf.dummy.resource.DummyGroup in project midpoint by Evolveum.

the class TestCaseIgnore method test200GuybrushAssignRoleFools.

/**
	 * Create group no resource in such a way that midpoint does not know about it.
	 * The assign a role that refers to this group by using associationTargetSearch.
	 * The group shadow has to be created in midPoint and it should have the correct
	 * kind/intent. Otherwise the shadow will not have proper matching rules and the
	 * identifiers in the shadow will not be normalized. This may lead to shadow duplication.
	 */
@Test
public void test200GuybrushAssignRoleFools() throws Exception {
    final String TEST_NAME = "test200GuybrushAssignRoleFools";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assertShadows(5);
    assertNoDummyAccount(RESOURCE_DUMMY_UPCASE_NAME, ACCOUNT_GUYBRUSH_DUMMY_UPCASE_NAME);
    DummyGroup dummyGroupFools = new DummyGroup(GROUP_DUMMY_FOOLS_NAME);
    dummyResourceUpcase.addGroup(dummyGroupFools);
    recomputeUser(USER_GUYBRUSH_OID, task, result);
    assertShadows(4);
    PrismObject<UserType> userBefore = getUser(USER_GUYBRUSH_OID);
    display("User before", userBefore);
    assertShadows(4);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    assignRole(USER_GUYBRUSH_OID, ROLE_FOOL_OID, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertShadows(6);
    // Make sure this is repository so we do not destroy the "evidence" yet.
    PrismObject<UserType> userAfter = repositoryService.getObject(UserType.class, USER_GUYBRUSH_OID, null, result);
    display("User after change execution", userAfter);
    assertAssignedRole(userAfter, ROLE_FOOL_OID);
    accountOid = getSingleLinkOid(userAfter);
    assertShadows(6);
    // Check shadow
    rememberShadowFetchOperationCount();
    PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result);
    display("Repo shadow", accountShadow);
    assertShadowFetchOperationCountIncrement(0);
    assertAccountShadowRepo(accountShadow, accountOid, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, resourceDummyUpcaseType, caseIgnoreMatchingRule);
    assertShadows(6);
    // Check account
    rememberShadowFetchOperationCount();
    PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result);
    display("Model shadow", accountModel);
    assertShadowFetchOperationCountIncrement(1);
    assertAccountShadowModel(accountModel, accountOid, ACCOUNT_GUYBRUSH_DUMMY_UPCASE_NAME, resourceDummyUpcaseType, caseIgnoreMatchingRule);
    //        assertShadows(6);
    assertDummyAccount(RESOURCE_DUMMY_UPCASE_NAME, ACCOUNT_GUYBRUSH_DUMMY_UPCASE_NAME, ACCOUNT_GUYBRUSH_DUMMY_FULLNAME, true);
    assertDummyAccountAttribute(RESOURCE_DUMMY_UPCASE_NAME, ACCOUNT_GUYBRUSH_DUMMY_UPCASE_NAME, "title", "FOOL!");
    assertDummyGroupMember(RESOURCE_DUMMY_UPCASE_NAME, GROUP_DUMMY_FOOLS_NAME, ACCOUNT_GUYBRUSH_DUMMY_UPCASE_NAME);
    assertEquals(1, accountModel.asObjectable().getAssociation().size());
    ObjectReferenceType shadowRef = accountModel.asObjectable().getAssociation().get(0).getShadowRef();
    PrismObject<ShadowType> groupFoolsRepoShadow = repositoryService.getObject(ShadowType.class, shadowRef.getOid(), null, result);
    display("group fools repo shadow", groupFoolsRepoShadow);
    PrismAsserts.assertPropertyValue(groupFoolsRepoShadow, new ItemPath(ShadowType.F_ATTRIBUTES, SchemaConstants.ICFS_NAME), GROUP_DUMMY_FOOLS_NAME.toLowerCase());
    PrismAsserts.assertPropertyValue(groupFoolsRepoShadow, new ItemPath(ShadowType.F_ATTRIBUTES, SchemaConstants.ICFS_UID), GROUP_DUMMY_FOOLS_NAME.toLowerCase());
    assertShadowKindIntent(groupFoolsRepoShadow, ShadowKindType.ENTITLEMENT, INTENT_DUMMY_GROUP);
    assertShadows(6);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TestRbac(com.evolveum.midpoint.model.intest.rbac.TestRbac) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 27 with DummyGroup

use of com.evolveum.icf.dummy.resource.DummyGroup in project midpoint by Evolveum.

the class TestDummy method test299DeleteGroupPirates.

@Test
public void test299DeleteGroupPirates() throws Exception {
    final String TEST_NAME = "test299DeleteGroupPirates";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    syncServiceMock.reset();
    // WHEN
    provisioningService.deleteObject(ShadowType.class, GROUP_PIRATES_OID, null, null, task, result);
    // THEN
    result.computeStatus();
    display(result);
    TestUtil.assertSuccess(result);
    syncServiceMock.assertNotifySuccessOnly();
    try {
        repositoryService.getObject(ShadowType.class, GROUP_PIRATES_OID, null, result);
        AssertJUnit.fail("Group shadow is not gone (repo)");
    } catch (ObjectNotFoundException e) {
    // This is expected
    }
    try {
        provisioningService.getObject(ShadowType.class, GROUP_PIRATES_OID, null, task, result);
        AssertJUnit.fail("Group shadow is not gone (provisioning)");
    } catch (ObjectNotFoundException e) {
    // This is expected
    }
    DummyGroup dummyAccount = getDummyGroup(GROUP_PIRATES_NAME, piratesIcfUid);
    assertNull("Dummy group '" + GROUP_PIRATES_NAME + "' is not gone from dummy resource", dummyAccount);
    assertSteadyResource();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) Test(org.testng.annotations.Test)

Example 28 with DummyGroup

use of com.evolveum.icf.dummy.resource.DummyGroup in project midpoint by Evolveum.

the class TestDummy method test225GetFoolishPirateWill.

/**
	 * Create a fresh group directly on the resource. So we are sure there is no shadow
	 * for it yet. Add will to this group. Get will account. Make sure that the group is
	 * in the associations.
	 */
@Test
public void test225GetFoolishPirateWill() throws Exception {
    final String TEST_NAME = "test225GetFoolishPirateWill";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    DummyGroup groupFools = new DummyGroup("fools");
    dummyResource.addGroup(groupFools);
    groupFools.addMember(transformNameFromResource(ACCOUNT_WILL_USERNAME));
    syncServiceMock.reset();
    rememberDummyResourceGroupMembersReadCount(null);
    rememberConnectorOperationCount();
    // WHEN
    PrismObject<ShadowType> account = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
    // THEN
    result.computeStatus();
    display("Account", account);
    display(result);
    TestUtil.assertSuccess(result);
    assertConnectorOperationIncrement(2);
    assertDummyResourceGroupMembersReadCountIncrement(null, 0);
    PrismObject<ShadowType> foolsShadow = findShadowByName(new QName(RESOURCE_DUMMY_NS, OBJECTCLAS_GROUP_LOCAL_NAME), "fools", resource, result);
    assertNotNull("No shadow for group fools", foolsShadow);
    assertDummyResourceGroupMembersReadCountIncrement(null, 0);
    assertEntitlementGroup(account, GROUP_PIRATES_OID);
    assertEntitlementGroup(account, foolsShadow.getOid());
    assertEntitlementPriv(account, PRIVILEGE_PILLAGE_OID);
    assertEntitlementPriv(account, PRIVILEGE_BARGAIN_OID);
    assertDummyResourceGroupMembersReadCountIncrement(null, 0);
    // Just make sure nothing has changed
    DummyAccount dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid);
    assertNotNull("Account will is gone!", dummyAccount);
    Set<String> accountProvileges = dummyAccount.getAttributeValues(DummyAccount.ATTR_PRIVILEGES_NAME, String.class);
    PrismAsserts.assertSets("Wrong account privileges", accountProvileges, PRIVILEGE_PILLAGE_NAME, PRIVILEGE_BARGAIN_NAME);
    // Make sure that privilege object is still there
    DummyPrivilege priv = getDummyPrivilegeAssert(PRIVILEGE_PILLAGE_NAME, pillageIcfUid);
    assertNotNull("Privilege object is gone!", priv);
    DummyPrivilege priv2 = getDummyPrivilegeAssert(PRIVILEGE_BARGAIN_NAME, bargainIcfUid);
    assertNotNull("Privilege object (bargain) is gone!", priv2);
    assertDummyResourceGroupMembersReadCountIncrement(null, 0);
    DummyGroup group = getDummyGroupAssert(GROUP_PIRATES_NAME, piratesIcfUid);
    assertMember(group, transformNameToResource(ACCOUNT_WILL_USERNAME));
    String foolsIcfUid = getIcfUid(foolsShadow);
    groupFools = getDummyGroupAssert("fools", foolsIcfUid);
    assertMember(groupFools, transformNameToResource(ACCOUNT_WILL_USERNAME));
    assertDummyResourceGroupMembersReadCountIncrement(null, 0);
    assertSteadyResource();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyPrivilege(com.evolveum.icf.dummy.resource.DummyPrivilege) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) Test(org.testng.annotations.Test)

Example 29 with DummyGroup

use of com.evolveum.icf.dummy.resource.DummyGroup in project midpoint by Evolveum.

the class TestDummyCaseIgnore method test289DetitleAccountWillPirates.

@Test
public void test289DetitleAccountWillPirates() throws Exception {
    final String TEST_NAME = "test289DetitleAccountWillPirates";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    syncServiceMock.reset();
    ObjectDelta<ShadowType> delta = IntegrationTestTools.createDetitleDelta(ACCOUNT_WILL_OID, dummyResourceCtl.getAttributeQName(DummyResourceContoller.DUMMY_ENTITLEMENT_GROUP_NAME), GROUP_PIRATES_OID, prismContext);
    display("ObjectDelta", delta);
    delta.checkConsistence();
    // WHEN
    provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
    // THEN
    result.computeStatus();
    display("modifyObject result", result);
    TestUtil.assertSuccess(result);
    delta.checkConsistence();
    DummyGroup group = getDummyGroupAssert(GROUP_PIRATES_NAME, piratesIcfUid);
    assertNoMember(group, getWillRepoIcfName());
    assertNoMember(group, getWillRepoIcfName().toUpperCase());
    assertNoMember(group, getWillRepoIcfName().toLowerCase());
    // Make sure that account is still there and it has the privilege
    DummyAccount dummyAccount = getDummyAccountAssert(ACCOUNT_WILL_USERNAME, willIcfUid);
    assertNotNull("Account will is gone!", dummyAccount);
    syncServiceMock.assertNotifySuccessOnly();
    assertSteadyResource();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationProvisioningScriptsType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) Test(org.testng.annotations.Test)

Example 30 with DummyGroup

use of com.evolveum.icf.dummy.resource.DummyGroup in project midpoint by Evolveum.

the class TestDummyCaseIgnore method test282DetitleAccountWillPirates.

@Test
public void test282DetitleAccountWillPirates() throws Exception {
    final String TEST_NAME = "test282DetitleAccountWillPirates";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    syncServiceMock.reset();
    ObjectDelta<ShadowType> delta = IntegrationTestTools.createDetitleDelta(ACCOUNT_WILL_OID, dummyResourceCtl.getAttributeQName(DummyResourceContoller.DUMMY_ENTITLEMENT_GROUP_NAME), GROUP_PIRATES_OID, prismContext);
    display("ObjectDelta", delta);
    delta.checkConsistence();
    // WHEN
    provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
    // THEN
    result.computeStatus();
    display("modifyObject result", result);
    TestUtil.assertSuccess(result);
    delta.checkConsistence();
    DummyGroup group = getDummyGroupAssert(GROUP_PIRATES_NAME, piratesIcfUid);
    assertNoMember(group, getWillRepoIcfName());
    // Make sure that account is still there and it has the privilege
    DummyAccount dummyAccount = getDummyAccountAssert(ACCOUNT_WILL_USERNAME, willIcfUid);
    assertNotNull("Account will is gone!", dummyAccount);
    syncServiceMock.assertNotifySuccessOnly();
    assertSteadyResource();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationProvisioningScriptsType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) DummyGroup(com.evolveum.icf.dummy.resource.DummyGroup) Test(org.testng.annotations.Test)

Aggregations

DummyGroup (com.evolveum.icf.dummy.resource.DummyGroup)38 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)24 Task (com.evolveum.midpoint.task.api.Task)23 Test (org.testng.annotations.Test)23 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)20 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)18 DummyPrivilege (com.evolveum.icf.dummy.resource.DummyPrivilege)16 OperationProvisioningScriptsType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType)11 SchemaViolationException (com.evolveum.icf.dummy.resource.SchemaViolationException)7 GuardedString (org.identityconnectors.common.security.GuardedString)7 ConflictException (com.evolveum.icf.dummy.resource.ConflictException)6 DummyOrg (com.evolveum.icf.dummy.resource.DummyOrg)6 ObjectAlreadyExistsException (com.evolveum.icf.dummy.resource.ObjectAlreadyExistsException)6 FileNotFoundException (java.io.FileNotFoundException)6 ConnectException (java.net.ConnectException)6 AlreadyExistsException (org.identityconnectors.framework.common.exceptions.AlreadyExistsException)6 ConnectionFailedException (org.identityconnectors.framework.common.exceptions.ConnectionFailedException)6 ConnectorIOException (org.identityconnectors.framework.common.exceptions.ConnectorIOException)6 InvalidAttributeValueException (org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException)6 QName (javax.xml.namespace.QName)5