use of com.novell.ldapchai.ChaiEntry in project ldapchai by ldapchai.
the class ChaiTester method testReplicationChecker.
public void testReplicationChecker() throws Exception {
final ChaiEntry testContainer = TestHelper.createTestContainer();
testContainer.writeStringAttribute("description", "testValue" + (new Random()).nextInt());
final int maximumWaitTime = 120 * 1000;
final int pauseTime = 3 * 1000;
final long startTime = System.currentTimeMillis();
boolean replicated = false;
while (System.currentTimeMillis() - startTime < (maximumWaitTime)) {
try {
Thread.sleep(pauseTime);
} catch (InterruptedException e) {
}
replicated = ChaiUtility.testAttributeReplication(testContainer, "description", null);
if (replicated) {
break;
}
}
System.out.println("Attribute replication successful: " + replicated);
Assert.assertTrue("attributes never synchronized", replicated);
}
use of com.novell.ldapchai.ChaiEntry in project ldapchai by ldapchai.
the class ChaiTester method testCreateUser.
public void testCreateUser() throws Exception {
final ChaiEntry testContainer = TestHelper.createTestContainer();
final String createDN = "cn=chaiCreateTestUser," + testContainer.getEntryDN();
final String createClass = "inetOrgPerson";
final Map<String, String> createAttributes = new HashMap<String, String>();
createAttributes.put("givenName", "GivenNameValue");
createAttributes.put("sn", "SurnameValue");
createAttributes.put("title", "test.Tester");
createAttributes.put("mail", "test@test.test");
// perform the create operation in eDirectory
TestHelper.getProvider().createEntry(createDN, createClass, createAttributes);
}
use of com.novell.ldapchai.ChaiEntry in project ldapchai by ldapchai.
the class ChaiTester method testIsPasswordExpired.
public void testIsPasswordExpired() throws Exception {
final ChaiEntry testContainer = TestHelper.createTestContainer();
final String createDN = "cn=chaiPasswordExpiredTestUser," + testContainer.getEntryDN();
final String createClass = "inetOrgPerson";
final Map<String, String> createAttributes = new HashMap<String, String>();
createAttributes.put("givenName", "GivenNameValue");
createAttributes.put("sn", "SurnameValue");
createAttributes.put("title", "test.Tester");
createAttributes.put("mail", "est@test.test");
// perform the create operation in eDirectory
TestHelper.getProvider().createEntry(createDN, createClass, createAttributes);
final ChaiUser theUser = ChaiFactory.createChaiUser(createDN, TestHelper.getProvider());
if (theUser.isPasswordExpired()) {
throw new Exception("password is expired, but shouldn't be");
}
theUser.setPassword("newPAssW04d!");
theUser.writeStringAttribute(ChaiUser.ATTR_PASSWORD_EXPIRE_TIME, EdirEntries.convertDateToZulu(new Date()));
if (!theUser.isPasswordExpired()) {
Assert.fail("password should not be expired, but is");
}
}
use of com.novell.ldapchai.ChaiEntry in project ldapchai by ldapchai.
the class FailOverTester method testSingleServerRestart.
public void testSingleServerRestart() throws Exception {
TestHelper.configureLogging();
final InetSocketAddress destinationAddress = figureDestSocketAddress();
final TcpProxy proxy1 = new TcpProxy(basePort + 1, destinationAddress);
proxy1.start();
final ChaiConfiguration testConfig = makeChaiConfig(figureUrlForProxy(proxy1));
final ChaiProvider testProvider = ChaiProviderFactory.createProvider(testConfig);
final ChaiEntry testContainer = TestHelper.createTestContainer(testProvider);
final ChaiUser testUser = TestHelper.createNewTestUser(testContainer);
TestHelper.doBasicNonDestructiveUserTest(testUser);
proxy1.stop();
TestHelper.pause(1000);
// test to make sure we get errors
boolean gotError = false;
try {
TestHelper.doBasicNonDestructiveUserTest(testUser);
} catch (ChaiUnavailableException e) {
System.out.println("got expected unavailable error: " + e.getMessage());
gotError = true;
}
Assert.assertTrue(gotError);
proxy1.start();
TestHelper.pause(1000);
TestHelper.doBasicNonDestructiveUserTest(testUser);
}
use of com.novell.ldapchai.ChaiEntry in project ldapchai by ldapchai.
the class TestHelper method implCleanUp.
private static void implCleanUp(final ChaiEntry object) throws ChaiUnavailableException, ChaiOperationException {
try {
final Set<ChaiEntry> results = object.getChildObjects();
for (final ChaiEntry loopEntry : results) {
if (!loopEntry.equals(object)) {
implCleanUp(loopEntry);
}
}
if (!object.getEntryDN().equals("")) {
System.out.print(".");
object.getChaiProvider().deleteEntry(object.getEntryDN());
}
} catch (ChaiOperationException e) {
if (e.getErrorCode() != ChaiError.NO_SUCH_ENTRY) {
throw e;
}
}
}
Aggregations