Search in sources :

Example 51 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class TestSanity method test020ModifyUser.

/**
     * We are going to modify the user. As the user has an account, the user
     * changes should be also applied to the account (by schemaHandling).
     */
@Test
public void test020ModifyUser() throws Exception {
    final String TEST_NAME = "test020ModifyUser";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    assertNoRepoCache();
    ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_FULLNAME_LOCALITY_FILENAME, ObjectDeltaType.class);
    // WHEN ObjectTypes.USER.getTypeQName(), 
    OperationResultType result = modifyObjectViaModelWS(objectChange);
    // THEN
    assertNoRepoCache();
    displayJaxb("modifyObject result:", result, SchemaConstants.C_RESULT);
    TestUtil.assertSuccess("modifyObject has failed", result);
    // Check if user object was modified in the repo
    OperationResult repoResult = new OperationResult("getObject");
    PrismObject<UserType> repoUser = repositoryService.getObject(UserType.class, USER_JACK_OID, null, repoResult);
    UserType repoUserType = repoUser.asObjectable();
    display("repository user", repoUser);
    PrismAsserts.assertEqualsPolyString("wrong value for fullName", "Cpt. Jack Sparrow", repoUserType.getFullName());
    PrismAsserts.assertEqualsPolyString("wrong value for locality", "somewhere", repoUserType.getLocality());
    assertEquals("wrong value for employeeNumber", "1", repoUserType.getEmployeeNumber());
    // Check if appropriate accountRef is still there
    List<ObjectReferenceType> accountRefs = repoUserType.getLinkRef();
    assertEquals(2, accountRefs.size());
    for (ObjectReferenceType accountRef : accountRefs) {
        assertTrue("No OID in " + accountRef + " in " + repoUserType, accountRef.getOid().equals(accountShadowOidOpendj) || accountRef.getOid().equals(accountShadowOidDerby));
    }
    // Check if shadow is still in the repo and that it is untouched
    repoResult = new OperationResult("getObject");
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidOpendj, null, repoResult);
    repoResult.computeStatus();
    TestUtil.assertSuccess("getObject(repo) has failed", repoResult);
    display("repository shadow", repoShadow);
    AssertJUnit.assertNotNull(repoShadow);
    ShadowType repoShadowType = repoShadow.asObjectable();
    AssertJUnit.assertEquals(RESOURCE_OPENDJ_OID, repoShadowType.getResourceRef().getOid());
    // check attributes in the shadow: should be only identifiers (ICF UID)
    String uid = checkRepoShadow(repoShadow);
    // Check if LDAP account was updated
    assertOpenDJAccountJack(uid, "jack");
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 52 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class TestSanity method test048ModifyUserRemoveGivenName.

/**
     * We are going to modify the user. As the user has an account, the user
     * changes should be also applied to the account (by schemaHandling).
     *
     * @throws DirectoryException
     */
@Test
public void test048ModifyUserRemoveGivenName() throws Exception {
    final String TEST_NAME = "test048ModifyUserRemoveGivenName";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    assertNoRepoCache();
    ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_GIVENNAME_FILENAME, ObjectDeltaType.class);
    displayJaxb("objectChange:", objectChange, SchemaConstants.T_OBJECT_DELTA);
    // WHEN ObjectTypes.USER.getTypeQName(), 
    OperationResultType result = modifyObjectViaModelWS(objectChange);
    // THEN
    assertNoRepoCache();
    displayJaxb("modifyObject result:", result, SchemaConstants.C_RESULT);
    TestUtil.assertSuccess("modifyObject has failed", result);
    // Check if user object was modified in the repo
    OperationResult repoResult = new OperationResult("getObject");
    PrismObject<UserType> repoUser = repositoryService.getObject(UserType.class, USER_JACK_OID, null, repoResult);
    UserType repoUserType = repoUser.asObjectable();
    display("repository user", repoUser);
    PrismAsserts.assertEqualsPolyString("wrong value for fullName", "Cpt. Jack Sparrow", repoUserType.getFullName());
    assertNull("Value for givenName still present", repoUserType.getGivenName());
    // Check if appropriate accountRef is still there
    List<ObjectReferenceType> accountRefs = repoUserType.getLinkRef();
    assertEquals(1, accountRefs.size());
    ObjectReferenceType accountRef = accountRefs.iterator().next();
    accountRef.getOid().equals(accountShadowOidOpendj);
    // Check if shadow is still in the repo and that it is untouched
    repoResult = new OperationResult("getObject");
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidOpendj, null, repoResult);
    repoResult.computeStatus();
    TestUtil.assertSuccess("getObject(repo) has failed", repoResult);
    display("repository shadow", repoShadow);
    AssertJUnit.assertNotNull(repoShadow);
    ShadowType repoShadowType = repoShadow.asObjectable();
    AssertJUnit.assertEquals(RESOURCE_OPENDJ_OID, repoShadowType.getResourceRef().getOid());
    // check attributes in the shadow: should be only identifiers (ICF UID)
    String uid = checkRepoShadow(repoShadow);
    // Check if LDAP account was updated
    Entry entry = openDJController.searchAndAssertByEntryUuid(uid);
    assertOpenDJAccountJack(entry, "jsparrow", null);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ChangeRecordEntry(org.opends.server.util.ChangeRecordEntry) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 53 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class TestSanity method checkOpenDjResource.

/**
     * Checks if the resource is internally consistent, if it has everything it should have.
     *
     * @throws SchemaException
     */
private void checkOpenDjResource(ResourceType resource, String source) throws SchemaException {
    assertNotNull("Resource from " + source + " is null", resource);
    ObjectReferenceType connectorRefType = resource.getConnectorRef();
    assertNotNull("Resource from " + source + " has null connectorRef", connectorRefType);
    assertFalse("Resource from " + source + " has no OID in connectorRef", StringUtils.isBlank(connectorRefType.getOid()));
    assertNotNull("Resource from " + source + " has null description in connectorRef", connectorRefType.getDescription());
    assertNotNull("Resource from " + source + " has null filter in connectorRef", connectorRefType.getFilter());
    assertNotNull("Resource from " + source + " has null filter element in connectorRef", connectorRefType.getFilter().getFilterClauseXNode());
    assertNotNull("Resource from " + source + " has null configuration", resource.getConnectorConfiguration());
    assertNotNull("Resource from " + source + " has null schema", resource.getSchema());
    checkOpenDjSchema(resource, source);
    assertNotNull("Resource from " + source + " has null schemahandling", resource.getSchemaHandling());
    checkOpenDjSchemaHandling(resource, source);
    if (!source.equals("repository")) {
        // This is generated on the fly in provisioning
        assertNotNull("Resource from " + source + " has null nativeCapabilities", resource.getCapabilities().getNative());
        assertFalse("Resource from " + source + " has empty nativeCapabilities", resource.getCapabilities().getNative().getAny().isEmpty());
    }
    assertNotNull("Resource from " + source + " has null configured capabilities", resource.getCapabilities().getConfigured());
    assertFalse("Resource from " + source + " has empty capabilities", resource.getCapabilities().getConfigured().getAny().isEmpty());
    assertNotNull("Resource from " + source + " has null synchronization", resource.getSynchronization());
    checkOpenDjConfiguration(resource.asPrismObject(), source);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)

Example 54 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class TestSanity method test107UnassignRolePirate.

@Test
public void test107UnassignRolePirate() throws Exception {
    final String TEST_NAME = "test107UnassignRolePirate";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResultType result = new OperationResultType();
    assertNoRepoCache();
    ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_DELETE_ROLE_PIRATE_FILENAME, ObjectDeltaType.class);
    // WHEN ObjectTypes.USER.getTypeQName(), 
    result = modifyObjectViaModelWS(objectChange);
    // THEN
    assertNoRepoCache();
    displayJaxb("modifyObject result", result, SchemaConstants.C_RESULT);
    TestUtil.assertSuccess("modifyObject has failed", result);
    // Check if user object was modified in the repo
    OperationResult repoResult = new OperationResult("getObject");
    PrismObject<UserType> repoUser = repositoryService.getObject(UserType.class, USER_GUYBRUSH_OID, null, repoResult);
    UserType repoUserType = repoUser.asObjectable();
    repoResult.computeStatus();
    display("User (repository)", repoUser);
    List<ObjectReferenceType> accountRefs = repoUserType.getLinkRef();
    assertEquals(1, accountRefs.size());
    ObjectReferenceType accountRef = accountRefs.get(0);
    assertEquals(accountShadowOidGuybrushOpendj, accountRef.getOid());
    // Check if shadow is still in the repo
    repoResult = new OperationResult("getObject");
    PrismObject<ShadowType> aObject = repositoryService.getObject(ShadowType.class, accountShadowOidGuybrushOpendj, null, repoResult);
    ShadowType repoShadow = aObject.asObjectable();
    repoResult.computeStatus();
    TestUtil.assertSuccess("getObject has failed", repoResult);
    display("Shadow (repository)", repoShadow);
    assertNotNull(repoShadow);
    assertEquals(RESOURCE_OPENDJ_OID, repoShadow.getResourceRef().getOid());
    // check if account is still in LDAP
    Entry entry = openDJController.searchAndAssertByEntryUuid(accountGuybrushOpendjEntryUuuid);
    display("LDAP account", entry);
    OpenDJController.assertAttribute(entry, "uid", "guybrush");
    OpenDJController.assertAttribute(entry, "givenName", "Guybrush");
    OpenDJController.assertAttribute(entry, "sn", "Threepwood");
    OpenDJController.assertAttribute(entry, "cn", "Guybrush Threepwood");
    OpenDJController.assertAttribute(entry, "displayName", "Guybrush Threepwood");
    // The "l" attribute is assigned indirectly through schemaHandling and
    // config object
    OpenDJController.assertAttribute(entry, "l", "Deep in the Caribbean");
    // Set by the role
    OpenDJController.assertAttribute(entry, "employeeType", "sailor");
    OpenDJController.assertAttribute(entry, "title", "Honorable Captain");
    OpenDJController.assertAttribute(entry, "carLicense", "C4PT41N");
    OpenDJController.assertAttribute(entry, "businessCategory", "cruise", "fighting", "capsize");
    // Expression in the role taking that from the user
    OpenDJController.assertAttribute(entry, "destinationIndicator", "Guybrush Threepwood");
    OpenDJController.assertAttribute(entry, "departmentNumber", "Department of Guybrush");
    // Expression in the role taking that from the assignments (both of them)
    OpenDJController.assertAttribute(entry, "physicalDeliveryOfficeName", "The Sea Monkey", "The Dainty Lady");
    String guybrushPassword = OpenDJController.getAttributeValue(entry, "userPassword");
    assertNotNull("Pasword disappeared", guybrushPassword);
// TODO: Derby        
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ChangeRecordEntry(org.opends.server.util.ChangeRecordEntry) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 55 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class TestSanity method test030DisableUser.

/**
     * Try to disable user. As the user has an account, the account should be disabled as well.
     */
@Test
public void test030DisableUser() throws Exception {
    final String TEST_NAME = "test030DisableUser";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_ACTIVATION_DISABLE_FILENAME, ObjectDeltaType.class);
    Entry entry = openDJController.searchByUid("jack");
    assertOpenDJAccountJack(entry, "jack");
    String pwpAccountDisabled = OpenDJController.getAttributeValue(entry, "ds-pwp-account-disabled");
    display("ds-pwp-account-disabled before change", pwpAccountDisabled);
    assertTrue("LDAP account is not enabled (precondition)", openDJController.isAccountEnabled(entry));
    assertNoRepoCache();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    OperationResultType result = modifyObjectViaModelWS(objectChange);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    assertNoRepoCache();
    displayJaxb("modifyObject result:", result, SchemaConstants.C_RESULT);
    TestUtil.assertSuccess("modifyObject has failed", result);
    // Check if user object was modified in the repo
    OperationResult repoResult = new OperationResult("getObject");
    PrismObject<UserType> repoUser = repositoryService.getObject(UserType.class, USER_JACK_OID, null, repoResult);
    display("repository user", repoUser);
    UserType repoUserType = repoUser.asObjectable();
    // Check if nothing else was modified
    assertEqualsPolyString("wrong repo fullName", "Cpt. Jack Sparrow", repoUserType.getFullName());
    assertEqualsPolyString("wrong repo locality", "somewhere", repoUserType.getLocality());
    // Check if appropriate accountRef is still there
    List<ObjectReferenceType> accountRefs = repoUserType.getLinkRef();
    assertEquals(2, accountRefs.size());
    for (ObjectReferenceType accountRef : accountRefs) {
        assertTrue("No OID in " + accountRef + " in " + repoUserType, accountRef.getOid().equals(accountShadowOidOpendj) || accountRef.getOid().equals(accountShadowOidDerby));
    }
    // Check if shadow is still in the repo and that it is untouched
    repoResult = new OperationResult("getObject");
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidOpendj, null, repoResult);
    display("repo shadow", repoShadow);
    ShadowType repoShadowType = repoShadow.asObjectable();
    repoResult.computeStatus();
    TestUtil.assertSuccess("getObject(repo) has failed", repoResult);
    AssertJUnit.assertNotNull(repoShadowType);
    AssertJUnit.assertEquals(RESOURCE_OPENDJ_OID, repoShadowType.getResourceRef().getOid());
    // check attributes in the shadow: should be only identifiers (ICF UID)
    String uid = checkRepoShadow(repoShadow);
    // Check if LDAP account was updated
    entry = openDJController.searchAndAssertByEntryUuid(uid);
    assertOpenDJAccountJack(entry, "jack");
    pwpAccountDisabled = OpenDJController.getAttributeValue(entry, "ds-pwp-account-disabled");
    display("ds-pwp-account-disabled after change", pwpAccountDisabled);
    assertFalse("LDAP account was not disabled", openDJController.isAccountEnabled(entry));
    // Use getObject to test fetch of complete shadow
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    Holder<ObjectType> objectHolder = new Holder<ObjectType>();
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    assertNoRepoCache();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modelWeb.getObject(ObjectTypes.SHADOW.getTypeQName(), accountShadowOidOpendj, options, objectHolder, resultHolder);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    assertNoRepoCache();
    displayJaxb("getObject result", resultHolder.value, SchemaConstants.C_RESULT);
    TestUtil.assertSuccess("getObject has failed", resultHolder.value);
    ShadowType modelShadow = (ShadowType) objectHolder.value;
    display("Shadow (model)", modelShadow);
    AssertJUnit.assertNotNull(modelShadow);
    AssertJUnit.assertEquals(RESOURCE_OPENDJ_OID, modelShadow.getResourceRef().getOid());
    assertAttributeNotNull(modelShadow, getOpenDjPrimaryIdentifierQName());
    assertAttribute(resourceTypeOpenDjrepo, modelShadow, "uid", "jack");
    assertAttribute(resourceTypeOpenDjrepo, modelShadow, "givenName", "Jack");
    assertAttribute(resourceTypeOpenDjrepo, modelShadow, "sn", "Sparrow");
    assertAttribute(resourceTypeOpenDjrepo, modelShadow, "cn", "Cpt. Jack Sparrow");
    assertAttribute(resourceTypeOpenDjrepo, modelShadow, "displayName", "Cpt. Jack Sparrow");
    assertAttribute(resourceTypeOpenDjrepo, modelShadow, "l", "somewhere");
    assertNotNull("The account activation is null in the shadow", modelShadow.getActivation());
    assertNotNull("The account activation status was not present in shadow", modelShadow.getActivation().getAdministrativeStatus());
    assertEquals("The account was not disabled in the shadow", ActivationStatusType.DISABLED, modelShadow.getActivation().getAdministrativeStatus());
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) Holder(javax.xml.ws.Holder) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType) ChangeRecordEntry(org.opends.server.util.ChangeRecordEntry) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Aggregations

ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)278 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)104 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)61 Test (org.testng.annotations.Test)61 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)56 Task (com.evolveum.midpoint.task.api.Task)53 QName (javax.xml.namespace.QName)46 ArrayList (java.util.ArrayList)44 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)42 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)37 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)33 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)32 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)32 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)31 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)30 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)30 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)26 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)26 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)23 List (java.util.List)23