Search in sources :

Example 36 with Holder

use of javax.xml.ws.Holder in project midpoint by Evolveum.

the class TestSanity method test006reimportResourceDummy.

@Test
public void test006reimportResourceDummy() throws Exception {
    TestUtil.displayTestTile("test006reimportResourceDummy");
    //get object from repo (with version set and try to add it - it should be re-added, without error)
    OperationResult repoResult = new OperationResult("getObject");
    PrismObject<ResourceType> resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, repoResult);
    assertNotNull(resource);
    ModelExecuteOptionsType options = new ModelExecuteOptionsType();
    options.setOverwrite(Boolean.TRUE);
    options.setIsImport(Boolean.TRUE);
    addObjectViaModelWS(resource.asObjectable(), options, new Holder<String>(), new Holder<OperationResultType>());
    //TODO: add some asserts
    //parse object from file again and try to add it - this should fail, becasue the same object already exists)
    resource = PrismTestUtil.parseObject(new File(RESOURCE_DUMMY_FILENAME));
    try {
        Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
        options = new ModelExecuteOptionsType();
        options.setIsImport(Boolean.TRUE);
        addObjectViaModelWS(resource.asObjectable(), options, new Holder<String>(), resultHolder);
        OperationResultType result = resultHolder.value;
        TestUtil.assertFailure(result);
        fail("Expected object already exists exception, but haven't got one.");
    } catch (FaultMessage ex) {
        LOGGER.info("fault {}", ex.getFaultInfo());
        LOGGER.info("fault {}", ex.getCause());
        if (ex.getFaultInfo() instanceof ObjectAlreadyExistsFaultType) {
        // this is OK, we expect this
        } else {
            fail("Expected object already exists exception, but haven't got one.");
        }
    }
//         ResourceType resourceType = uObject.asObjectable();
//         assertNotNull("Reference on the connector must not be null in resource.",resourceType.getConnectorRef());
//         assertNotNull("Missing oid reference on the connector",resourceType.getConnectorRef().getOid());
}
Also used : 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) ModelExecuteOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ObjectAlreadyExistsFaultType(com.evolveum.midpoint.xml.ns._public.common.fault_3.ObjectAlreadyExistsFaultType) File(java.io.File) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 37 with Holder

use of javax.xml.ws.Holder in project midpoint by Evolveum.

the class TestSanity 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(TestSanity.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 Holder

use of javax.xml.ws.Holder in project midpoint by Evolveum.

the class TestSanity method test014AddDerbyAccountToUser.

/**
     * Add Derby account to user. This should result in account provisioning. Check if
     * that happens in repo and in Derby.
     */
@Test
public void test014AddDerbyAccountToUser() throws IOException, JAXBException, FaultMessage, ObjectNotFoundException, SchemaException, DirectoryException, SQLException {
    TestUtil.displayTestTile("test014AddDerbyAccountToUser");
    // GIVEN
    checkRepoDerbyResource();
    assertNoRepoCache();
    ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_ADD_ACCOUNT_DERBY_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_JACK_OID, null, repoResult);
    UserType repoUser = uObject.asObjectable();
    repoResult.computeStatus();
    display("User (repository)", repoUser);
    List<ObjectReferenceType> accountRefs = repoUser.getLinkRef();
    // OpenDJ account was added in previous test, hence 2 accounts
    assertEquals(2, accountRefs.size());
    ObjectReferenceType accountRef = null;
    for (ObjectReferenceType ref : accountRefs) {
        if (!ref.getOid().equals(accountShadowOidOpendj)) {
            accountRef = ref;
        }
    }
    accountShadowOidDerby = accountRef.getOid();
    assertFalse(accountShadowOidDerby.isEmpty());
    // Check if shadow was created in the repo
    repoResult = new OperationResult("getObject");
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidDerby, null, repoResult);
    ShadowType repoShadowType = repoShadow.asObjectable();
    repoResult.computeStatus();
    TestUtil.assertSuccess("addObject has failed", repoResult);
    display("Shadow (repository)", repoShadowType);
    assertNotNull(repoShadowType);
    assertEquals(RESOURCE_DERBY_OID, repoShadowType.getResourceRef().getOid());
    // Check the "name" property, it should be set to DN, not entryUUID
    assertEquals("Wrong name property", PrismTestUtil.createPolyStringType(USER_JACK_DERBY_LOGIN), repoShadowType.getName());
    // check attributes in the shadow: should be only identifiers (ICF UID)
    String uid = checkRepoShadow(repoShadow);
    // check if account was created in DB Table
    Statement stmt = derbyController.getExecutedStatementWhereLoginName(uid);
    ResultSet rs = stmt.getResultSet();
    System.out.println("RS: " + rs);
    assertTrue("No records found for login name " + uid, rs.next());
    assertEquals(USER_JACK_DERBY_LOGIN, rs.getString(DerbyController.COLUMN_LOGIN));
    assertEquals("Cpt. Jack Sparrow", rs.getString(DerbyController.COLUMN_FULL_NAME));
    // TODO: check password
    //assertEquals("3lizab3th",rs.getString(DerbyController.COLUMN_PASSWORD));
    System.out.println("Password: " + rs.getString(DerbyController.COLUMN_PASSWORD));
    assertFalse("Too many records found for login name " + uid, rs.next());
    rs.close();
    stmt.close();
    // Use getObject to test fetch of complete shadow
    assertNoRepoCache();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    Holder<ObjectType> objectHolder = new Holder<ObjectType>();
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    // WHEN
    modelWeb.getObject(ObjectTypes.SHADOW.getTypeQName(), accountShadowOidDerby, options, objectHolder, resultHolder);
    // THEN
    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_DERBY_OID, modelShadow.getResourceRef().getOid());
    assertAttribute(modelShadow, SchemaConstants.ICFS_UID, USER_JACK_DERBY_LOGIN);
    assertAttribute(modelShadow, SchemaConstants.ICFS_NAME, USER_JACK_DERBY_LOGIN);
    assertAttribute(resourceDerby, modelShadow, "FULL_NAME", "Cpt. Jack Sparrow");
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) Statement(java.sql.Statement) 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) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ResultSet(java.sql.ResultSet) 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)

Example 39 with Holder

use of javax.xml.ws.Holder 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 40 with Holder

use of javax.xml.ws.Holder 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)

Aggregations

Holder (javax.xml.ws.Holder)328 Test (org.junit.Test)204 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)77 Test (org.testng.annotations.Test)53 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)48 BigInteger (java.math.BigInteger)44 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)33 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)29 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)29 QName (javax.xml.namespace.QName)29 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)24 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)23 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)23 URL (java.net.URL)23 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)21 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)21 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)21 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)19 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)16 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)15