Search in sources :

Example 1 with TestCompletion

use of io.vertx.ext.unit.TestCompletion in project apiman by apiman.

the class LdapBindTests method bindPasswordSuccess.

@Test
public void bindPasswordSuccess() {
    config.setBindDn("uid=admin,ou=system");
    config.setBindPassword("secret");
    TestCompletion completion = TestSuite.create("").test("", context -> {
        Async async = context.async();
        ldapClientComponent.bind(config, result -> {
            if (result.isError())
                result.getError().printStackTrace(System.out);
            context.assertTrue(result.isSuccess());
            context.assertEquals(LdapResultCode.SUCCESS, result.getResult().getResultCode());
            async.complete();
        });
        async.awaitSuccess();
    }).run();
    completion.awaitSuccess();
}
Also used : TestSuite(io.vertx.ext.unit.TestSuite) LdapResultCode(io.apiman.gateway.engine.components.ldap.result.LdapResultCode) Async(io.vertx.ext.unit.Async) Test(org.junit.Test) TestCompletion(io.vertx.ext.unit.TestCompletion) Async(io.vertx.ext.unit.Async) TestCompletion(io.vertx.ext.unit.TestCompletion) Test(org.junit.Test)

Example 2 with TestCompletion

use of io.vertx.ext.unit.TestCompletion in project apiman by apiman.

the class LdapBindTests method shouldFailWhenPasswordInvalid.

@Test
public void shouldFailWhenPasswordInvalid() {
    config.setBindDn("uid=admin,ou=system");
    config.setBindPassword("miso-soup");
    TestCompletion completion = TestSuite.create("").test("", context -> {
        Async async = context.async();
        ldapClientComponent.bind(config, result -> {
            context.assertTrue(result.isSuccess());
            context.assertEquals(LdapResultCode.INVALID_CREDENTIALS, result.getResult().getResultCode());
            async.complete();
        });
        async.awaitSuccess();
    }).run();
    completion.awaitSuccess();
}
Also used : TestSuite(io.vertx.ext.unit.TestSuite) LdapResultCode(io.apiman.gateway.engine.components.ldap.result.LdapResultCode) Async(io.vertx.ext.unit.Async) Test(org.junit.Test) TestCompletion(io.vertx.ext.unit.TestCompletion) Async(io.vertx.ext.unit.Async) TestCompletion(io.vertx.ext.unit.TestCompletion) Test(org.junit.Test)

Example 3 with TestCompletion

use of io.vertx.ext.unit.TestCompletion in project apiman by apiman.

the class LdapQueryTests method connect.

private void connect(DoubleHandler<ILdapClientConnection, TestContext> handler) {
    TestCompletion completion = TestSuite.create("").test("", context -> {
        Async async = context.async();
        ldapClientComponent.connect(config, connectionResult -> {
            context.assertTrue(connectionResult.isSuccess());
            connection = connectionResult.getResult();
            handler.handle(connection, context);
            async.complete();
        });
        async.awaitSuccess();
    }).run();
    completion.awaitSuccess();
}
Also used : TestContext(io.vertx.ext.unit.TestContext) TestSuite(io.vertx.ext.unit.TestSuite) LdapSearchScope(io.apiman.gateway.engine.components.ldap.LdapSearchScope) LdapResultCode(io.apiman.gateway.engine.components.ldap.result.LdapResultCode) Async(io.vertx.ext.unit.Async) List(java.util.List) After(org.junit.After) ILdapClientConnection(io.apiman.gateway.engine.components.ldap.ILdapClientConnection) Test(org.junit.Test) ILdapSearchEntry(io.apiman.gateway.engine.components.ldap.ILdapSearchEntry) TestCompletion(io.vertx.ext.unit.TestCompletion) Async(io.vertx.ext.unit.Async) TestCompletion(io.vertx.ext.unit.TestCompletion)

Example 4 with TestCompletion

use of io.vertx.ext.unit.TestCompletion in project apiman by apiman.

the class LdapBindTests method shouldFailWhenUidInvalid.

@Test
public void shouldFailWhenUidInvalid() {
    config.setBindDn("uid=tacos,ou=system");
    config.setBindPassword("secret");
    TestCompletion completion = TestSuite.create("").test("", context -> {
        Async async = context.async();
        ldapClientComponent.bind(config, result -> {
            if (result.isError())
                result.getError().printStackTrace(System.out);
            context.assertTrue(result.isSuccess());
            context.assertEquals(LdapResultCode.INVALID_CREDENTIALS, result.getResult().getResultCode());
            async.complete();
        });
        async.awaitSuccess();
    }).run();
    completion.awaitSuccess();
}
Also used : TestSuite(io.vertx.ext.unit.TestSuite) LdapResultCode(io.apiman.gateway.engine.components.ldap.result.LdapResultCode) Async(io.vertx.ext.unit.Async) Test(org.junit.Test) TestCompletion(io.vertx.ext.unit.TestCompletion) Async(io.vertx.ext.unit.Async) TestCompletion(io.vertx.ext.unit.TestCompletion) Test(org.junit.Test)

Example 5 with TestCompletion

use of io.vertx.ext.unit.TestCompletion in project apiman by apiman.

the class LdapBindTests method shouldFailWhenOuInvalid.

@Test
public void shouldFailWhenOuInvalid() {
    config.setBindDn("uid=admin,ou=tacos");
    config.setBindPassword("secret");
    TestCompletion completion = TestSuite.create("").test("", context -> {
        Async async = context.async();
        ldapClientComponent.bind(config, result -> {
            if (result.isError())
                result.getError().printStackTrace(System.out);
            context.assertTrue(result.isSuccess());
            context.assertEquals(LdapResultCode.INVALID_CREDENTIALS, result.getResult().getResultCode());
            async.complete();
        });
        async.awaitSuccess();
    }).run();
    completion.awaitSuccess();
}
Also used : TestSuite(io.vertx.ext.unit.TestSuite) LdapResultCode(io.apiman.gateway.engine.components.ldap.result.LdapResultCode) Async(io.vertx.ext.unit.Async) Test(org.junit.Test) TestCompletion(io.vertx.ext.unit.TestCompletion) Async(io.vertx.ext.unit.Async) TestCompletion(io.vertx.ext.unit.TestCompletion) Test(org.junit.Test)

Aggregations

LdapResultCode (io.apiman.gateway.engine.components.ldap.result.LdapResultCode)6 Async (io.vertx.ext.unit.Async)6 TestCompletion (io.vertx.ext.unit.TestCompletion)6 TestSuite (io.vertx.ext.unit.TestSuite)6 Test (org.junit.Test)6 ILdapClientConnection (io.apiman.gateway.engine.components.ldap.ILdapClientConnection)2 ILdapSearchEntry (io.apiman.gateway.engine.components.ldap.ILdapSearchEntry)2 LdapSearchScope (io.apiman.gateway.engine.components.ldap.LdapSearchScope)2 TestContext (io.vertx.ext.unit.TestContext)2 List (java.util.List)2 After (org.junit.After)2