use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class TestOpenDj method test429DeleteAccountMorgan.
/**
* Morgan has a group associations. If the account is gone the group memberships should also be gone.
*/
@Test
public void test429DeleteAccountMorgan() throws Exception {
final String TEST_NAME = "test429DeleteAccountMorgan";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
// WHEN
provisioningService.deleteObject(ShadowType.class, ACCOUNT_MORGAN_OID, null, null, task, result);
ShadowType objType = null;
try {
objType = provisioningService.getObject(ShadowType.class, ACCOUNT_MORGAN_OID, null, task, result).asObjectable();
Assert.fail("Expected exception ObjectNotFoundException, but haven't got one.");
} catch (ObjectNotFoundException ex) {
System.out.println("Catched ObjectNotFoundException.");
assertNull(objType);
}
try {
objType = repositoryService.getObject(ShadowType.class, ACCOUNT_MORGAN_OID, null, result).asObjectable();
// objType = container.getObject();
Assert.fail("Expected exception, but haven't got one.");
} catch (Exception ex) {
assertNull(objType);
assertEquals(ex.getClass(), ObjectNotFoundException.class);
assertTrue(ex.getMessage().contains(ACCOUNT_MORGAN_OID));
}
Entry groupEntry = openDJController.fetchEntry(GROUP_SWASHBUCKLERS_DN);
display("LDAP group", groupEntry);
assertNotNull("No LDAP group entry");
openDJController.assertNoUniqueMember(groupEntry, ACCOUNT_MORGAN_DN);
assertShadows(21);
}
use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class TestOpenDj method test320AddAccountPosix.
@Test
public void test320AddAccountPosix() throws Exception {
final String TEST_NAME = "test320AddAccountPosix";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
ShadowType object = parseObjectType(ACCOUNT_POSIX_MCMUTTON_FILE, ShadowType.class);
display("Adding account", object);
// WHEN
TestUtil.displayWhen(TEST_NAME);
String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
assertEquals(ACCOUNT_POSIX_MCMUTTON_OID, addedObjectOid);
ShadowType repoShadowType = repositoryService.getObject(ShadowType.class, ACCOUNT_POSIX_MCMUTTON_OID, null, result).asObjectable();
display("Repo shadow", repoShadowType);
PrismAsserts.assertEqualsPolyString("Name not equal (repo)", ACCOUNT_POSIX_MCMUTTON_DN, repoShadowType.getName());
assertAttribute(repoShadowType, getSecondaryIdentifierQName(), StringUtils.lowerCase(ACCOUNT_POSIX_MCMUTTON_DN));
MidPointAsserts.assertObjectClass(repoShadowType, RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS, RESOURCE_OPENDJ_POSIX_ACCOUNT_OBJECTCLASS);
ShadowType provisioningShadowType = provisioningService.getObject(ShadowType.class, ACCOUNT_POSIX_MCMUTTON_OID, null, task, result).asObjectable();
display("Provisioning shadow", provisioningShadowType);
PrismAsserts.assertEqualsPolyString("Name not equal.", ACCOUNT_POSIX_MCMUTTON_DN, provisioningShadowType.getName());
MidPointAsserts.assertObjectClass(provisioningShadowType, RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS, RESOURCE_OPENDJ_POSIX_ACCOUNT_OBJECTCLASS);
assertAttribute(provisioningShadowType, "cn", "Haggis McMutton");
assertAttribute(provisioningShadowType, "sn", "McMutton");
assertAttribute(provisioningShadowType, "homeDirectory", "/home/scotland");
assertAttribute(provisioningShadowType, "uidNumber", 1001);
String uid = ShadowUtil.getSingleStringAttributeValue(repoShadowType, getPrimaryIdentifierQName());
assertNotNull(uid);
// Check if object was modified in LDAP
Entry entry = openDJController.searchAndAssertByEntryUuid(uid);
display("LDAP account", entry);
OpenDJController.assertAttribute(entry, "cn", "Haggis McMutton");
OpenDJController.assertAttribute(entry, "sn", "McMutton");
OpenDJController.assertAttribute(entry, "uidNumber", "1001");
OpenDJController.assertAttribute(entry, "loginShell", "/bin/whisky");
OpenDJController.assertAttribute(entry, "homeDirectory", "/home/scotland");
assertShadows(17);
}
use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class TestOpenDj method test151AddObjectWithPassword.
@Test
public void test151AddObjectWithPassword() throws Exception {
final String TEST_NAME = "test151AddObjectWithPassword";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
ShadowType object = parseObjectType(ACCOUNT_NEW_WITH_PASSWORD_FILE, ShadowType.class);
System.out.println(SchemaDebugUtil.prettyPrint(object));
System.out.println(object.asPrismObject().debugDump());
String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, taskManager.createTaskInstance(), result);
assertEquals(ACCOUNT_NEW_WITH_PASSWORD_OID, addedObjectOid);
ShadowType accountType = repositoryService.getObject(ShadowType.class, ACCOUNT_NEW_WITH_PASSWORD_OID, null, result).asObjectable();
// assertEquals("lechuck", accountType.getName());
PrismAsserts.assertEqualsPolyString("Name not equal.", "uid=lechuck,ou=People,dc=example,dc=com", accountType.getName());
ShadowType provisioningAccountType = provisioningService.getObject(ShadowType.class, ACCOUNT_NEW_WITH_PASSWORD_OID, null, taskManager.createTaskInstance(), result).asObjectable();
PrismAsserts.assertEqualsPolyString("Name not equal.", "uid=lechuck,ou=People,dc=example,dc=com", provisioningAccountType.getName());
// assertEquals("lechuck", provisioningAccountType.getName());
String uid = null;
for (Object e : accountType.getAttributes().getAny()) {
if (getPrimaryIdentifierQName().equals(JAXBUtil.getElementQName(e))) {
uid = ((Element) e).getTextContent();
}
}
assertNotNull(uid);
// Check if object was created in LDAP and that there is a password
Entry entryAfter = openDJController.searchAndAssertByEntryUuid(uid);
display("LDAP account after", entryAfter);
String passwordAfter = OpenDJController.getAttributeValue(entryAfter, "userPassword");
assertNotNull("The password was not changed", passwordAfter);
System.out.println("Account password: " + passwordAfter);
openDJController.assertPassword(entryAfter.getDN().toString(), "t4k30v3rTh3W0rld");
assertShadows(5);
}
use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class TestOpenDj method test145ModifyAccountJackJpegPhoto.
@Test
public void test145ModifyAccountJackJpegPhoto() throws Exception {
final String TEST_NAME = "test145ModifyAccountJackJpegPhoto";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
byte[] bytesIn = Files.readAllBytes(Paths.get(ProvisioningTestUtil.DOT_JPG_FILENAME));
display("Bytes in", MiscUtil.binaryToHex(bytesIn));
QName jpegPhotoQName = new QName(RESOURCE_OPENDJ_NS, "jpegPhoto");
PropertyDelta<byte[]> jpegPhotoDelta = new PropertyDelta<>(new ItemPath(ShadowType.F_ATTRIBUTES, jpegPhotoQName), null, prismContext);
jpegPhotoDelta.setValueToReplace(new PrismPropertyValue<byte[]>(bytesIn));
Collection<? extends ItemDelta> modifications = MiscSchemaUtil.createCollection(jpegPhotoDelta);
display("Modifications", modifications);
// WHEN
TestUtil.displayWhen(TEST_NAME);
provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
Entry entry = openDJController.searchByUid("rename");
display("LDAP Entry", entry);
byte[] jpegPhotoLdap = OpenDJController.getAttributeValueBinary(entry, "jpegPhoto");
assertNotNull("No jpegPhoto in LDAP entry", jpegPhotoLdap);
assertEquals("Byte length changed (LDAP)", bytesIn.length, jpegPhotoLdap.length);
assertTrue("Bytes do not match (LDAP)", Arrays.equals(bytesIn, jpegPhotoLdap));
PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_JACK_OID, null, taskManager.createTaskInstance(), result);
display("Object after change", shadow);
PrismContainer<?> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
PrismProperty<byte[]> jpegPhotoAttr = attributesContainer.findProperty(jpegPhotoQName);
byte[] bytesOut = jpegPhotoAttr.getValues().get(0).getValue();
display("Bytes out", MiscUtil.binaryToHex(bytesOut));
assertEquals("Byte length changed (shadow)", bytesIn.length, bytesOut.length);
assertTrue("Bytes do not match (shadow)", Arrays.equals(bytesIn, bytesOut));
assertShadows(3);
}
use of org.opends.server.types.Entry in project midpoint by Evolveum.
the class TestOpenDj method test147ModifyAccountJackGivenNameDuplicit.
/**
* Make a duplicate modification. Add a givenName value that is already there.
* Normal LDAP should fail. So check that connector and midPoitn handles that.
*/
@Test
public void test147ModifyAccountJackGivenNameDuplicit() throws Exception {
final String TEST_NAME = "test147ModifyAccountJackGivenNameDuplicit";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
PropertyDelta<String> givenNameDelta = new PropertyDelta<>(new ItemPath(ShadowType.F_ATTRIBUTES, new QName(RESOURCE_OPENDJ_NS, "givenName")), null, prismContext);
givenNameDelta.addValueToAdd(new PrismPropertyValue<String>("Jack"));
// Also make an ordinary non-conflicting modification. We need to make sure that
// the operation was not ignored as a whole
PropertyDelta<String> titleDelta = new PropertyDelta<>(new ItemPath(ShadowType.F_ATTRIBUTES, new QName(RESOURCE_OPENDJ_NS, "title")), null, prismContext);
titleDelta.addValueToAdd(new PrismPropertyValue<String>("Great Captain"));
Collection<? extends ItemDelta> modifications = MiscSchemaUtil.createCollection(givenNameDelta, titleDelta);
display("Modifications", modifications);
// WHEN
TestUtil.displayWhen(TEST_NAME);
provisioningService.modifyObject(ShadowType.class, ACCOUNT_JACK_OID, modifications, null, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
Entry entry = openDJController.searchByUid("rename");
display("LDAP Entry", entry);
OpenDJController.assertAttribute(entry, "givenName", "Jack");
OpenDJController.assertAttribute(entry, "title", "Great Captain");
PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_JACK_OID, null, taskManager.createTaskInstance(), result);
display("Object after change", shadow);
PrismContainer<?> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
PrismAsserts.assertPropertyValue(attributesContainer, new QName(RESOURCE_OPENDJ_NS, "givenName"), "Jack");
PrismAsserts.assertPropertyValue(attributesContainer, new QName(RESOURCE_OPENDJ_NS, "title"), "Great Captain");
assertShadows(3);
}
Aggregations