use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class ConsistencyTest method test152RecomputeUserAccountAndShadowNotFound.
/**
* Recompute user => account not found => reaction: Re-create account
* MID-3093
*/
@Test
public void test152RecomputeUserAccountAndShadowNotFound() throws Exception {
final String TEST_NAME = "test152RecomputeUserAccountAndShadowNotFound";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TEST_NAME);
OperationResult result = task.getResult();
PrismObject<UserType> userBefore = getUser(USER_GUYBRUSH_OID);
display("User before", userBefore);
String accountShadowOid = assertOneAccountRef(userBefore);
PrismObject<ShadowType> shadowBefore = getShadowModel(accountShadowOid);
display("Shadow before", shadowBefore);
String dn = ShadowUtil.getAttributeValue(shadowBefore, RESOURCE_OPENDJ_SECONDARY_IDENTIFIER);
openDJController.delete(dn);
repositoryService.deleteObject(ShadowType.class, accountShadowOid, result);
// WHEN
recomputeUser(USER_GUYBRUSH_OID, task, result);
// THEN
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<UserType> userAfter = getUser(USER_GUYBRUSH_OID);
display("User after", userAfter);
String accountShadowOidAfter = assertOneAccountRef(userAfter);
PrismObject<ShadowType> shadowAfter = getShadowModel(accountShadowOidAfter);
display("Shadow after", shadowAfter);
Entry entryAfter = openDJController.fetchEntry(dn);
display("Entry after", entryAfter);
}
use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class ConsistencyTest method test500AddUserMorganWithAssignment.
/**
* Adding a user (morgan) that has an OpenDJ assignment. But the equivalent account already exists on
* OpenDJ. The account should be linked.
*/
@Test
public void test500AddUserMorganWithAssignment() throws Exception {
final String TEST_NAME = "test500AddUserMorganWithAssignment";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
openDJController.assumeRunning();
Task task = taskManager.createTaskInstance(ConsistencyTest.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
dummyAuditService.clear();
Entry entry = openDJController.addEntryFromLdifFile(LDIF_MORGAN_FILENAME);
display("Entry from LDIF", entry);
PrismObject<UserType> user = PrismTestUtil.parseObject(new File(USER_MORGAN_FILENAME));
display("Adding user", user);
ObjectDelta<UserType> userDelta = ObjectDelta.createAddDelta(user);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
// WHEN
TestUtil.displayWhen(TEST_NAME);
modelService.executeChanges(deltas, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
// assertEquals("Expected handled error but got: " + result.getStatus(), OperationResultStatus.HANDLED_ERROR, result.getStatus());
PrismObject<UserType> userMorgan = modelService.getObject(UserType.class, USER_MORGAN_OID, null, task, result);
display("User morgan after", userMorgan);
UserType userMorganType = userMorgan.asObjectable();
assertEquals("Unexpected number of accountRefs", 1, userMorganType.getLinkRef().size());
ObjectReferenceType accountRefType = userMorganType.getLinkRef().get(0);
String accountOid = accountRefType.getOid();
assertFalse("No accountRef oid", StringUtils.isBlank(accountOid));
// Check shadow
PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result);
assertShadowRepo(accountShadow, accountOid, "uid=morgan,ou=people,dc=example,dc=com", resourceTypeOpenDjrepo, RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS);
// Check account
PrismObject<ShadowType> accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result);
assertShadowModel(accountModel, accountOid, "uid=morgan,ou=people,dc=example,dc=com", resourceTypeOpenDjrepo, RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS);
// TODO: check OpenDJ Account
}
use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class TestOpenDj method test330SearchForPosixAccount.
/**
* Search for account created directly on resource (no shadow in repo). The account has
* posixAccount auxiliary object class. Provisioning should figure that out.
*/
@Test
public void test330SearchForPosixAccount() throws Exception {
final String TEST_NAME = "test330SearchForPosixAccount";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_VANHELGEN_FILE, QueryType.COMPLEX_TYPE);
ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);
provisioningService.applyDefinition(ShadowType.class, query, task, result);
Entry entry = openDJController.addEntryFromLdifFile(ACCOUNT_POSIX_VANHELGEN_LDIF_FILE);
rememberConnectorOperationCount();
rememberConnectorSimulatedPagingSearchCount();
// WHEN
List<PrismObject<ShadowType>> objListType = provisioningService.searchObjects(ShadowType.class, query, null, null, result);
// THEN
for (PrismObject<ShadowType> objType : objListType) {
assertNotNull("Null search result", objType);
display("found object", objType);
}
assertEquals("Unexpected number of objects found", 1, objListType.size());
PrismObject<ShadowType> provisioningShadow = objListType.get(0);
assertAttribute(provisioningShadow, "cn", "Edward Van Helgen");
assertAttribute(provisioningShadow, "homeDirectory", "/home/vanhelgen");
assertAttribute(provisioningShadow, "uidNumber", 1002);
assertConnectorOperationIncrement(1, 3);
assertConnectorSimulatedPagingSearchIncrement(0);
assertShadows(17);
}
use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class TestOpenDj method test416AssociateUserToCorsairs.
@Test
public void test416AssociateUserToCorsairs() throws Exception {
final String TEST_NAME = "test416AssociateUserToCorsairs";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
ObjectDelta<ShadowType> delta = IntegrationTestTools.createEntitleDelta(ACCOUNT_MORGAN_OID, ASSOCIATION_GROUP_NAME, GROUP_CORSAIRS_OID, prismContext);
display("ObjectDelta", delta);
delta.checkConsistence();
// WHEN
TestUtil.displayWhen(TEST_NAME);
provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
Entry groupEntry = openDJController.fetchEntry(GROUP_CORSAIRS_DN);
display("LDAP group", groupEntry);
assertNotNull("No LDAP group entry");
openDJController.assertUniqueMember(groupEntry, ACCOUNT_MORGAN_DN);
assertShadows(22);
}
use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class TestOpenDj method test176AddEnabledAccount.
/**
* Adding account with EXPLICIT enable. This triggers simulated activation in a different way.
*/
@Test
public void test176AddEnabledAccount() throws Exception {
final String TEST_NAME = "test176AddEnabledAccount";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
ShadowType object = parseObjectType(ACCOUNT_NEW_ENABLED_FILE, ShadowType.class);
IntegrationTestTools.display("Adding object", object);
// WHEN
String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, taskManager.createTaskInstance(), result);
// THEN
assertEquals(ACCOUNT_NEW_ENABLED_OID, addedObjectOid);
ShadowType accountType = repositoryService.getObject(ShadowType.class, ACCOUNT_NEW_ENABLED_OID, null, result).asObjectable();
PrismAsserts.assertEqualsPolyString("Wrong ICF name (repo)", "uid=cook,ou=People,dc=example,dc=com", accountType.getName());
ShadowType provisioningAccountType = provisioningService.getObject(ShadowType.class, ACCOUNT_NEW_ENABLED_OID, null, taskManager.createTaskInstance(), result).asObjectable();
PrismAsserts.assertEqualsPolyString("Wrong ICF name (provisioning)", "uid=cook,ou=People,dc=example,dc=com", provisioningAccountType.getName());
String uid = ShadowUtil.getSingleStringAttributeValue(accountType, getPrimaryIdentifierQName());
assertNotNull(uid);
// Check if object was modified in LDAP
Entry response = openDJController.searchAndAssertByEntryUuid(uid);
display("LDAP account", response);
String disabled = openDJController.getAttributeValue(response, "ds-pwp-account-disabled");
assertEquals("ds-pwp-account-disabled not set to \"FALSE\"", "FALSE", disabled);
}
Aggregations