use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class TestUnix method test312AccountWallyRemovePosixObjectclassNative.
/**
* Remove posixAccount directly in LDAP server. Then try to get the account. MidPoint should survive that.
*/
@Test
public void test312AccountWallyRemovePosixObjectclassNative() throws Exception {
final String TEST_NAME = "test312AccountWallyRemovePosixObjectclassNative";
TestUtil.displayTestTile(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestUnix.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
openDJController.executeLdifChange("dn: " + accountWallyDn + "\n" + "changetype: modify\n" + "delete: objectclass\n" + "objectclass: posixAccount\n" + "-\n" + "delete: uidNumber\n" + "uidNumber: " + USER_WALLY_UID_NUMBER + "\n" + "-\n" + "delete: gidNumber\n" + "gidNumber: " + USER_WALLY_UID_NUMBER + "\n" + "-\n" + "delete: homeDirectory\n" + "homeDirectory: /home/wally");
Entry entryWallyBefore = openDJController.fetchEntry(accountWallyDn);
display("Wally LDAP account before", entryWallyBefore);
// WHEN
TestUtil.displayWhen(TEST_NAME);
PrismObject<ShadowType> shadow = modelService.getObject(ShadowType.class, accountWallyOid, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
display("Shadow (model)", shadow);
assertBasicAccount(shadow);
PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountWallyOid, null, result);
display("Shadow (repo)", repoShadow);
PrismAsserts.assertNoItem(repoShadow, ShadowType.F_AUXILIARY_OBJECT_CLASS);
// PrismAsserts.assertPropertyValue(repoShadow, ShadowType.F_AUXILIARY_OBJECT_CLASS);
PrismObject<UserType> userAfter = findUserByUsername(USER_WALLY_USERNAME);
assertNotNull("No wally user", userAfter);
display("User after", userAfter);
assertUserPosix(userAfter, USER_WALLY_USERNAME, USER_WALLY_FIST_NAME, USER_WALLY_LAST_NAME, USER_WALLY_UID_NUMBER);
accountMancombOid = getSingleLinkOid(userAfter);
}
use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class TestUnix method test137ReconcileUserLargoAgain.
/**
* Reconcile user again. Without any meddling.
* Just to make sure that the second run will not destroy anything.
*/
@Test
public void test137ReconcileUserLargoAgain() throws Exception {
final String TEST_NAME = "test137ReconcileUserLargoAgain";
TestUtil.displayTestTile(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestUnix.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObject<UserType> userBefore = findUserByUsername(USER_LARGO_USERNAME);
Entry entryBefore = openDJController.fetchEntry(accountLargoDn);
display("Entry before", entryBefore);
dummyAuditService.clear();
// WHEN
TestUtil.displayWhen(TEST_NAME);
reconcileUser(userBefore.getOid(), task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<UserType> userAfter = findUserByUsername(USER_LARGO_USERNAME);
assertNotNull("No user after", userAfter);
display("User after", userAfter);
assertUserPosix(userAfter, USER_LARGO_USERNAME, USER_LARGO_FIST_NAME, USER_LARGO_LAST_NAME, USER_LARGO_UID_NUMBER);
String accountOid = getSingleLinkOid(userAfter);
PrismObject<ShadowType> shadow = getShadowModel(accountOid);
display("Shadow (model)", shadow);
assertBasicAccount(shadow);
display("Audit", dummyAuditService);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertRecords(2);
dummyAuditService.assertExecutionDeltas(0);
}
use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class TestUcfOpenDj method test600CreateAccountWithPassword.
@Test
public void test600CreateAccountWithPassword() throws Exception {
final String TEST_NAME = "test600CreateAccountWithPassword";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
ResourceAttributeContainer resourceObject = createResourceObject("uid=lechuck,ou=people,dc=example,dc=com", "Ghost Pirate LeChuck", "LeChuck");
Set<Operation> additionalOperations = new HashSet<Operation>();
ProtectedStringType ps = protector.encryptString("t4k30v3rTh3W0rld");
// PasswordChangeOperation passOp = new PasswordChangeOperation(ps);
// additionalOperations.add(passOp);
OperationResult addResult = new OperationResult(this.getClass().getName() + "." + TEST_NAME);
PrismObject<ShadowType> shadow = wrapInShadow(ShadowType.class, resourceObject);
CredentialsType credentials = new CredentialsType();
PasswordType pass = new PasswordType();
pass.setValue(ps);
credentials.setPassword(pass);
shadow.asObjectable().setCredentials(credentials);
// WHEN
cc.addObject(shadow, additionalOperations, null, addResult);
// THEN
String entryUuid = (String) resourceObject.getPrimaryIdentifier().getValue().getValue();
Entry entry = openDJController.searchAndAssertByEntryUuid(entryUuid);
display("Entry before change", entry);
String passwordAfter = OpenDJController.getAttributeValue(entry, "userPassword");
assertNotNull(passwordAfter);
System.out.println("Changed password: " + passwordAfter);
// TODO
}
use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class ConsistencyTest method test511AssignAccountMorgan.
/**
* assign account to the user morgan. Account with the same 'uid' (not dn, nut other secondary identifier already exists)
* account should be linked to the user.
* @throws Exception
*/
@Test
public void test511AssignAccountMorgan() throws Exception {
final String TEST_NAME = "test511AssignAccountMorgan";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
openDJController.assumeRunning();
Task task = taskManager.createTaskInstance(ConsistencyTest.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
dummyAuditService.clear();
//prepare new OU in opendj
Entry entry = openDJController.addEntryFromLdifFile(LDIF_CREATE_USERS_OU_FILENAME);
PrismObject<UserType> user = repositoryService.getObject(UserType.class, USER_MORGAN_OID, null, result);
display("User Morgan: ", user);
PrismReference linkRef = user.findReference(UserType.F_LINK_REF);
ExpressionType expression = new ExpressionType();
ObjectFactory of = new ObjectFactory();
RawType raw = new RawType(new PrimitiveXNode("uid=morgan,ou=users,dc=example,dc=com"), prismContext);
JAXBElement val = of.createValue(raw);
expression.getExpressionEvaluator().add(val);
MappingType mapping = new MappingType();
mapping.setExpression(expression);
ResourceAttributeDefinitionType attrDefType = new ResourceAttributeDefinitionType();
attrDefType.setRef(new ItemPathType(new ItemPath(getOpenDjSecondaryIdentifierQName())));
attrDefType.setOutbound(mapping);
ConstructionType construction = new ConstructionType();
construction.getAttribute().add(attrDefType);
construction.setResourceRef(ObjectTypeUtil.createObjectRef(resourceTypeOpenDjrepo));
AssignmentType assignment = new AssignmentType();
assignment.setConstruction(construction);
ObjectDelta<UserType> userDelta = ObjectDelta.createModificationAddContainer(UserType.class, USER_MORGAN_OID, UserType.F_ASSIGNMENT, prismContext, assignment.asPrismContainerValue());
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());
String accountOid = userMorganType.getLinkRef().iterator().next().getOid();
// 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);
ResourceAttribute attributes = ShadowUtil.getAttribute(accountModel, new QName(resourceTypeOpenDjrepo.getNamespace(), "uid"));
assertEquals("morgan", attributes.getAnyRealValue());
// TODO: check OpenDJ Account
}
use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class ConsistencyTest method test110PrepareOpenDjWithAccounts.
/**
* Add account to user. This should result in account provisioning. Check if
* that happens in repo and in LDAP.
*/
@Test
public void test110PrepareOpenDjWithAccounts() throws Exception {
final String TEST_NAME = "test110PrepareOpenDjWithAccounts";
TestUtil.displayTestTile(TEST_NAME);
OperationResult parentResult = new OperationResult(TEST_NAME);
ShadowType jackeAccount = unmarshallValueFromFile(REQUEST_ADD_ACCOUNT_JACKIE, ShadowType.class);
Task task = taskManager.createTaskInstance();
String oid = provisioningService.addObject(jackeAccount.asPrismObject(), null, null, task, parentResult);
PrismObject<ShadowType> jackFromRepo = repositoryService.getObject(ShadowType.class, oid, null, parentResult);
LOGGER.debug("account jack after provisioning: {}", jackFromRepo.debugDump());
PrismObject<UserType> jackUser = repositoryService.getObject(UserType.class, USER_JACK_OID, null, parentResult);
ObjectReferenceType ort = new ObjectReferenceType();
ort.setOid(oid);
ort.setType(ShadowType.COMPLEX_TYPE);
jackUser.asObjectable().getLinkRef().add(ort);
PrismObject<UserType> jackUserRepo = repositoryService.getObject(UserType.class, USER_JACK_OID, null, parentResult);
ObjectDelta delta = DiffUtil.diff(jackUserRepo, jackUser);
repositoryService.modifyObject(UserType.class, USER_JACK_OID, delta.getModifications(), parentResult);
// GIVEN
OperationResult repoResult = new OperationResult("getObject");
// Check if user object was modified in the repo
accountShadowOidOpendj = assertUserOneAccountRef(USER_JACK_OID);
assertFalse(accountShadowOidOpendj.isEmpty());
// Check if shadow was created in the repo
repoResult = new OperationResult("getObject");
PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidOpendj, null, repoResult);
ShadowType repoShadowType = repoShadow.asObjectable();
repoResult.computeStatus();
TestUtil.assertSuccess("getObject has failed", repoResult);
display("Shadow (repository)", repoShadow);
assertNotNull(repoShadowType);
assertEquals(RESOURCE_OPENDJ_OID, repoShadowType.getResourceRef().getOid());
assertNotNull("Shadow stored in repository has no name", repoShadowType.getName());
// Check the "name" property, it should be set to DN, not entryUUID
assertEquals("Wrong name property", USER_JACK_LDAP_DN.toLowerCase(), repoShadowType.getName().getOrig().toLowerCase());
// check attributes in the shadow: should be only identifiers (ICF UID)
String uid = checkRepoShadow(repoShadow);
// check if account was created in LDAP
Entry entry = openDJController.searchAndAssertByEntryUuid(uid);
display("LDAP account", entry);
OpenDJController.assertAttribute(entry, "uid", "jackie");
OpenDJController.assertAttribute(entry, "givenName", "Jack");
OpenDJController.assertAttribute(entry, "sn", "Sparrow");
OpenDJController.assertAttribute(entry, "cn", "Jack Sparrow");
assertNoRepoCache();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
Holder<ObjectType> objectHolder = new Holder<ObjectType>();
// WHEN
PropertyReferenceListType resolve = new PropertyReferenceListType();
// List<ObjectOperationOptions> options = new ArrayList<ObjectOperationOptions>();
modelWeb.getObject(ObjectTypes.SHADOW.getTypeQName(), accountShadowOidOpendj, null, 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_OPENDJ_OID, modelShadow.getResourceRef().getOid());
assertAttributeNotNull(modelShadow, getOpenDjPrimaryIdentifierQName());
assertAttributes(modelShadow, "jackie", "Jack", "Sparrow", "Jack Sparrow");
// "middle of nowhere");
assertNull("carLicense attribute sneaked to LDAP", OpenDJController.getAttributeValue(entry, "carLicense"));
assertNotNull("Activation is null", modelShadow.getActivation());
assertNotNull("No 'enabled' in the shadow", modelShadow.getActivation().getAdministrativeStatus());
assertEquals("The account is not enabled in the shadow", ActivationStatusType.ENABLED, modelShadow.getActivation().getAdministrativeStatus());
TestUtil.displayTestTile("test013prepareOpenDjWithAccounts - add second account");
OperationResult secondResult = new OperationResult("test013prepareOpenDjWithAccounts - add second account");
ShadowType shadow = unmarshallValueFromFile(ACCOUNT_DENIELS_FILENAME, ShadowType.class);
provisioningService.addObject(shadow.asPrismObject(), null, null, task, secondResult);
repoAddObjectFromFile(USER_DENIELS_FILENAME, secondResult);
}
Aggregations