use of com.couchbase.client.core.error.AuthenticationFailureException in project couchbase-jvm-clients by couchbase.
the class KeyValueChannelIntegrationTest method assertAuthenticationFailure.
/**
* Helper method to assert authentication failure in different scenarios.
*/
private void assertAuthenticationFailure(final Bootstrap bootstrap, final String msg) throws Exception {
CountDownLatch latch = new CountDownLatch(1);
bootstrap.connect().addListener((ChannelFutureListener) future -> {
try {
assertFalse(future.isSuccess());
Throwable ex = future.cause();
assertTrue(ex instanceof AuthenticationFailureException);
assertEquals(msg, ex.getMessage());
} finally {
latch.countDown();
}
});
latch.await();
}
use of com.couchbase.client.core.error.AuthenticationFailureException in project couchbase-jvm-clients by couchbase.
the class SaslListMechanismsHandlerTest method failConnectIfStatusNotSuccess.
@Test
void failConnectIfStatusNotSuccess() {
SaslListMechanismsHandler handler = new SaslListMechanismsHandler(endpointContext);
channel.pipeline().addLast(handler);
assertEquals(handler, channel.pipeline().get(SaslListMechanismsHandler.class));
ChannelFuture connectFuture = channel.connect(new InetSocketAddress("1.2.3.4", 1234));
assertFalse(connectFuture.isDone());
channel.pipeline().fireChannelActive();
channel.runPendingTasks();
ByteBuf writtenRequest = channel.readOutbound();
verifyRequest(writtenRequest, MemcacheProtocol.Opcode.SASL_LIST_MECHS.opcode(), false, false, false);
assertNotNull(channel.pipeline().get(SaslListMechanismsHandler.class));
ReferenceCountUtil.release(writtenRequest);
ByteBuf response = decodeHexDump(readResource("error_sasl_list_mechs_response.txt", ErrorMapLoadingHandlerTest.class));
channel.writeInbound(response);
channel.runPendingTasks();
assertFalse(connectFuture.isSuccess());
AuthenticationFailureException cause = (AuthenticationFailureException) connectFuture.cause();
assertTrue(cause.getMessage().contains("Received non-success status from server"));
}
Aggregations