Search in sources :

Example 11 with DummyAccount

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

the class AbstractDummyTest method initSystem.

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
    // We need to switch off the encryption checks. Some values cannot be encrypted as we do
    // not have a definition here
    InternalsConfig.encryptionChecks = false;
    provisioningService.postInit(initResult);
    resource = addResourceFromFile(getResourceDummyFilename(), IntegrationTestTools.DUMMY_CONNECTOR_TYPE, initResult);
    resourceType = resource.asObjectable();
    dummyResourceCtl = DummyResourceContoller.create(null);
    dummyResourceCtl.setResource(resource);
    dummyResourceCtl.extendSchemaPirate();
    dummyResource = dummyResourceCtl.getDummyResource();
    extraDummyResourceInit();
    DummyAccount dummyAccountDaemon = new DummyAccount(ACCOUNT_DAEMON_USERNAME);
    dummyAccountDaemon.setEnabled(true);
    dummyAccountDaemon.addAttributeValues("fullname", "Evil Daemon");
    dummyResource.addAccount(dummyAccountDaemon);
    daemonIcfUid = dummyAccountDaemon.getId();
    PrismObject<ShadowType> shadowDaemon = PrismTestUtil.parseObject(ACCOUNT_DAEMON_FILE);
    if (!isIcfNameUidSame()) {
        setIcfUid(shadowDaemon, dummyAccountDaemon.getId());
    }
    repositoryService.addObject(shadowDaemon, null, initResult);
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount)

Example 12 with DummyAccount

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

the class AbstractDummyTest method getDummyAccountAssert.

protected DummyAccount getDummyAccountAssert(String icfName, String icfUid) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException {
    //		if (isNameUnique()) {
    if (isIcfNameUidSame()) {
        return dummyResource.getAccountByUsername(icfName);
    } else {
        DummyAccount account = dummyResource.getAccountById(icfUid);
        assertNotNull("No dummy account with ICF UID " + icfUid + " (expected name " + icfName + ")", account);
        assertEquals("Unexpected name in " + account, icfName, account.getName());
        return account;
    }
}
Also used : DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount)

Example 13 with DummyAccount

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

the class TestBrokenResources method testAssignTwoResoures.

/**
	 * Assign two resources to a user. One of them is looney, the other is not. The result should be that
	 * the account on the good resource is created.
	 */
private void testAssignTwoResoures(final String TEST_NAME, String badResourceOid) throws Exception {
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE);
    ObjectDelta<UserType> userDelta = createAccountAssignmentUserDelta(USER_JACK_OID, badResourceOid, null, true);
    userDelta.addModification(createAccountAssignmentModification(RESOURCE_DUMMY_OID, null, true));
    display("input delta", userDelta);
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
    // WHEN
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    result.computeStatus();
    display("executeChanges result", result);
    //TODO: ugly hack, see MID-1248 
    if ("test401AssignTwoResouresBroken".equals(TEST_NAME)) {
        assertEquals("Expected partial error in result", OperationResultStatus.PARTIAL_ERROR, result.getStatus());
    }
    DummyAccount jackDummyAccount = getDummyResource().getAccountByUsername(USER_JACK_USERNAME);
    assertNotNull("No jack dummy account", jackDummyAccount);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount)

Example 14 with DummyAccount

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

the class AbstractModelIntegrationTest method assertDummyAccountNoAttribute.

protected void assertDummyAccountNoAttribute(String dummyInstanceName, String username, String attributeName) throws SchemaViolationException, ConflictException {
    DummyAccount account = getDummyAccount(dummyInstanceName, username);
    assertNotNull("No dummy account for username " + username, account);
    Set<Object> values = account.getAttributeValues(attributeName, Object.class);
    assertTrue("Unexpected values for attribute " + attributeName + " of dummy account " + username + ": " + values, values == null || values.isEmpty());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount)

Example 15 with DummyAccount

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

the class AbstractModelIntegrationTest method assertDummyAccount.

protected DummyAccount assertDummyAccount(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException {
    DummyAccount account = getDummyAccount(dummyInstanceName, username);
    assertNotNull("No dummy(" + dummyInstanceName + ") account for username " + username, account);
    return account;
}
Also used : DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount)

Aggregations

DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)261 Test (org.testng.annotations.Test)211 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)158 Task (com.evolveum.midpoint.task.api.Task)152 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)40 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)40 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)24 DummyGroup (com.evolveum.icf.dummy.resource.DummyGroup)20 PrismObject (com.evolveum.midpoint.prism.PrismObject)19 ArrayList (java.util.ArrayList)19 OperationProvisioningScriptsType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType)18 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)16 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)14 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)14 DummyPrivilege (com.evolveum.icf.dummy.resource.DummyPrivilege)12 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)12 SchemaViolationException (com.evolveum.icf.dummy.resource.SchemaViolationException)10 QName (javax.xml.namespace.QName)10 ConflictException (com.evolveum.icf.dummy.resource.ConflictException)9 DummyOrg (com.evolveum.icf.dummy.resource.DummyOrg)9