Search in sources :

Example 36 with OperationResultType

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

the class TestSanityLegacy method testModifyAccountDjRoomNumber.

public void testModifyAccountDjRoomNumber(final String TEST_NAME, File reqFile, String expectedVal) throws Exception {
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    assertNoRepoCache();
    ObjectDeltaType objectChange = unmarshallValueFromFile(reqFile, ObjectDeltaType.class);
    objectChange.setOid(accountShadowOidOpendj);
    // WHEN
    OperationResultType result = modifyObjectViaModelWS(objectChange);
    // THEN
    assertNoRepoCache();
    displayJaxb("modifyObject result:", result, SchemaConstants.C_RESULT);
    TestUtil.assertSuccess("modifyObject has failed", result);
    OperationResult 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 jackLdapEntry = assertOpenDJAccountJack(uid, "jack");
    OpenDJController.assertAttribute(jackLdapEntry, "roomNumber", expectedVal);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) 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)

Example 37 with OperationResultType

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

the class TestSanityLegacy method test303LiveSyncLink.

@Test
public void test303LiveSyncLink() throws Exception {
    final String TEST_NAME = "test303LiveSyncLink";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    assertNoRepoCache();
    PrismObject<UserType> user = PrismTestUtil.parseObject(USER_E_LINK_ACTION_FILE);
    UserType userType = user.asObjectable();
    final String userOid = userType.getOid();
    // Encrypt e's password
    protector.encrypt(userType.getCredentials().getPassword().getValue());
    // create user in repository
    OperationResultType resultType = new OperationResultType();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(resultType);
    Holder<String> oidHolder = new Holder<String>();
    display("Adding user object", userType);
    addObjectViaModelWS(userType, null, oidHolder, resultHolder);
    //check results
    assertNoRepoCache();
    displayJaxb("addObject result:", resultHolder.value, SchemaConstants.C_RESULT);
    TestUtil.assertSuccess("addObject has failed", resultHolder.value);
    //        AssertJUnit.assertEquals(userOid, oidHolder.value);
    //WHEN
    //create account for e which should be correlated
    final OperationResult result = new OperationResult(TestSanityLegacy.class.getName() + "." + TEST_NAME);
    final Task syncCycle = taskManager.getTask(TASK_OPENDJ_SYNC_OID, result);
    AssertJUnit.assertNotNull(syncCycle);
    int tokenBefore = findSyncToken(syncCycle);
    display("Sync token before", tokenBefore);
    Entry entry = openDJController.addEntryFromLdifFile(LDIF_E_FILENAME_LINK);
    display("Entry from LDIF", entry);
    // THEN
    // Wait a bit to give the sync cycle time to detect the change
    basicWaitForSyncChangeDetection(syncCycle, tokenBefore, 4, result);
    //check user and account ref
    userType = searchUserByName("e");
    List<ObjectReferenceType> accountRefs = userType.getLinkRef();
    assertEquals("Account ref not found, or found too many", 1, accountRefs.size());
    //check account defined by account ref
    String accountOid = accountRefs.get(0).getOid();
    ShadowType account = searchAccountByOid(accountOid);
    assertEqualsPolyString("Name doesn't match", "uid=e,ou=People,dc=example,dc=com", account.getName());
    assertAndStoreSyncTokenIncrement(syncCycle, 4);
    checkAllShadows();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) 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) 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) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 38 with OperationResultType

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

the class TestSanityLegacy method test023ChangeUserPasswordJAXB.

/**
     * Similar to previous test just the request is constructed a bit differently.
     */
@Test
public void test023ChangeUserPasswordJAXB() throws Exception {
    final String TEST_NAME = "test023ChangeUserPasswordJAXB";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    final String NEW_PASSWORD = "abandonSHIP";
    Document doc = ModelClientUtil.getDocumnent();
    ObjectDeltaType userDelta = new ObjectDeltaType();
    userDelta.setOid(USER_JACK_OID);
    userDelta.setChangeType(ChangeTypeType.MODIFY);
    userDelta.setObjectType(UserType.COMPLEX_TYPE);
    ItemDeltaType passwordDelta = new ItemDeltaType();
    passwordDelta.setModificationType(ModificationTypeType.REPLACE);
    passwordDelta.setPath(ModelClientUtil.createItemPathType("credentials/password/value"));
    ProtectedStringType pass = new ProtectedStringType();
    pass.setClearValue(NEW_PASSWORD);
    XNode passValue = ((PrismContextImpl) prismContext).getBeanMarshaller().marshall(pass);
    System.out.println("PASSWORD VALUE: " + passValue.debugDump());
    RawType passwordValue = new RawType(passValue, prismContext);
    passwordDelta.getValue().add(passwordValue);
    userDelta.getItemDelta().add(passwordDelta);
    // WHEN ObjectTypes.USER.getTypeQName(), 
    OperationResultType result = modifyObjectViaModelWS(userDelta);
    // THEN
    assertUserPasswordChange(NEW_PASSWORD, result);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) XNode(com.evolveum.midpoint.prism.xnode.XNode) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) PrimitiveXNode(com.evolveum.midpoint.prism.xnode.PrimitiveXNode) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) Document(org.w3c.dom.Document) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 39 with OperationResultType

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

the class TestSanityLegacy method test104AssignRoleJudge.

/**
     * Judge role excludes pirate role. This assignment should fail. 
     */
@Test
public void test104AssignRoleJudge() throws Exception {
    final String TEST_NAME = "test104AssignRoleJudge";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResultType result = new OperationResultType();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(result);
    Holder<String> oidHolder = new Holder<String>();
    assertNoRepoCache();
    ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_ADD_ROLE_JUDGE_FILENAME, ObjectDeltaType.class);
    try {
        // WHEN ObjectTypes.USER.getTypeQName(), 
        result = modifyObjectViaModelWS(objectChange);
        // THEN
        AssertJUnit.fail("Expected a failure after assigning conflicting roles but nothing happened and life goes on");
    } catch (FaultMessage f) {
    // This is expected
    // TODO: check if the fault is the right one
    }
    assertNoRepoCache();
    displayJaxb("modifyObject result", result, SchemaConstants.C_RESULT);
    TestUtil.assertSuccess("modifyObject has failed", result);
    // Check if user object remain unmodified in the repo
    OperationResult repoResult = new OperationResult("getObject");
    PrismObject<UserType> uObject = repositoryService.getObject(UserType.class, USER_GUYBRUSH_OID, null, repoResult);
    UserType repoUser = uObject.asObjectable();
    repoResult.computeStatus();
    display("User (repository)", repoUser);
    List<ObjectReferenceType> accountRefs = repoUser.getLinkRef();
    assertEquals("Unexpected number or accountRefs", 1, accountRefs.size());
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) 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 40 with OperationResultType

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

the class TestSanity method test103AssignRoleCaptainAgain.

/**
     * Assign the same "captain" role again, this time with a slightly different assignment parameters.
     */
@Test
public void test103AssignRoleCaptainAgain() throws Exception {
    final String TEST_NAME = "test103AssignRoleCaptainAgain";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_ADD_ROLE_CAPTAIN_2_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> uObject = repositoryService.getObject(UserType.class, USER_GUYBRUSH_OID, null, repoResult);
    UserType repoUser = uObject.asObjectable();
    repoResult.computeStatus();
    display("User (repository)", repoUser);
    List<ObjectReferenceType> accountRefs = repoUser.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", "Bloody Pirate", "Honorable Captain");
    OpenDJController.assertAttribute(entry, "carLicense", "C4PT41N");
    OpenDJController.assertAttribute(entry, "businessCategory", "loot", "murder", "cruise");
    // 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)

Aggregations

OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)172 Test (org.testng.annotations.Test)106 Holder (javax.xml.ws.Holder)78 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)75 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)63 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)57 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)56 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)53 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)49 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)47 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)34 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)34 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)32 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)26 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)23 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)21 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)18 FaultMessage (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage)18 QName (javax.xml.namespace.QName)18 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)17