Search in sources :

Example 1 with SSOCredentialProvider

use of com.questdb.net.ha.krb.SSOCredentialProvider in project questdb by bluestreak01.

the class AuthorizationTest method testExceptionInCredentialProvider.

@Test
public void testExceptionInCredentialProvider() throws Exception {
    JournalServer server = new JournalServer(new ServerConfig() {

        {
            setHeartbeatFrequency(TimeUnit.MILLISECONDS.toMillis(500));
            setEnableMultiCast(false);
        }
    }, getFactory(), (token, requestedKeys) -> "SECRET".equals(new String(token)));
    final AtomicInteger authErrorCount = new AtomicInteger();
    final CountDownLatch terminated = new CountDownLatch(1);
    JournalClient client = new JournalClient(local, getFactory(), new SSOCredentialProvider("HOST/test"), evt -> {
        switch(evt) {
            case JournalClientEvents.EVT_AUTH_CONFIG_ERROR:
                authErrorCount.incrementAndGet();
                break;
            case JournalClientEvents.EVT_TERMINATED:
                terminated.countDown();
                break;
            default:
                break;
        }
    });
    server.start();
    try {
        client.start();
        Assert.assertTrue(terminated.await(5, TimeUnit.SECONDS));
        Assert.assertEquals(1, authErrorCount.get());
        Assert.assertFalse(client.isRunning());
    } finally {
        server.halt();
    }
}
Also used : ServerConfig(com.questdb.net.ha.config.ServerConfig) SSOCredentialProvider(com.questdb.net.ha.krb.SSOCredentialProvider) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CountDownLatch(java.util.concurrent.CountDownLatch) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Aggregations

ServerConfig (com.questdb.net.ha.config.ServerConfig)1 SSOCredentialProvider (com.questdb.net.ha.krb.SSOCredentialProvider)1 AbstractTest (com.questdb.test.tools.AbstractTest)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Test (org.junit.Test)1