Search in sources :

Example 11 with ChaiEntry

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);
}
Also used : ChaiEntry(com.novell.ldapchai.ChaiEntry)

Example 12 with ChaiEntry

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);
}
Also used : ChaiEntry(com.novell.ldapchai.ChaiEntry)

Example 13 with ChaiEntry

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");
    }
}
Also used : ChaiUser(com.novell.ldapchai.ChaiUser) ChaiEntry(com.novell.ldapchai.ChaiEntry) ChaiValidationException(com.novell.ldapchai.exception.ChaiValidationException)

Example 14 with ChaiEntry

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);
}
Also used : ChaiUnavailableException(com.novell.ldapchai.exception.ChaiUnavailableException) ChaiProvider(com.novell.ldapchai.provider.ChaiProvider) ChaiUser(com.novell.ldapchai.ChaiUser) InetSocketAddress(java.net.InetSocketAddress) ChaiEntry(com.novell.ldapchai.ChaiEntry) TcpProxy(com.novell.ldapchai.tests.util.TcpProxy) ChaiConfiguration(com.novell.ldapchai.provider.ChaiConfiguration)

Example 15 with ChaiEntry

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;
        }
    }
}
Also used : ChaiEntry(com.novell.ldapchai.ChaiEntry) ChaiOperationException(com.novell.ldapchai.exception.ChaiOperationException)

Aggregations

ChaiEntry (com.novell.ldapchai.ChaiEntry)31 ChaiProvider (com.novell.ldapchai.provider.ChaiProvider)12 ChaiConfiguration (com.novell.ldapchai.provider.ChaiConfiguration)8 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)7 ChaiUser (com.novell.ldapchai.ChaiUser)6 ChaiOperationException (com.novell.ldapchai.exception.ChaiOperationException)5 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)4 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)3 ChaiException (com.novell.ldapchai.exception.ChaiException)2 ChaiValidationException (com.novell.ldapchai.exception.ChaiValidationException)2 NmasResponseSet (com.novell.ldapchai.impl.edir.NmasResponseSet)2 TcpProxy (com.novell.ldapchai.tests.util.TcpProxy)2 InetSocketAddress (java.net.InetSocketAddress)2 MalformedURLException (java.net.MalformedURLException)2 UnknownHostException (java.net.UnknownHostException)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2