Search in sources :

Example 1 with UnknownSaslMechanismDetectedEvent

use of com.couchbase.client.core.cnc.events.io.UnknownSaslMechanismDetectedEvent in project couchbase-jvm-clients by couchbase.

the class SaslListMechanismsHandlerTest method ignoresUnknownSaslMech.

@Test
void ignoresUnknownSaslMech() {
    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("success_sasl_list_mechs_unknown_mech_response.txt", ErrorMapLoadingHandlerTest.class));
    channel.writeInbound(response);
    channel.runPendingTasks();
    assertTrue(connectFuture.isSuccess());
    Set<SaslMechanism> saslMechanisms = channel.attr(ChannelAttributes.SASL_MECHS_KEY).get();
    assertEquals(saslMechanisms, EnumSet.of(SaslMechanism.SCRAM_SHA1, SaslMechanism.SCRAM_SHA256, SaslMechanism.SCRAM_SHA512));
    UnknownSaslMechanismDetectedEvent event = (UnknownSaslMechanismDetectedEvent) eventBus.publishedEvents().get(0);
    assertEquals("FLAUN", event.mechanism());
}
Also used : ChannelFuture(com.couchbase.client.core.deps.io.netty.channel.ChannelFuture) UnknownSaslMechanismDetectedEvent(com.couchbase.client.core.cnc.events.io.UnknownSaslMechanismDetectedEvent) InetSocketAddress(java.net.InetSocketAddress) SaslMechanism(com.couchbase.client.core.env.SaslMechanism) ByteBuf(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf) Test(org.junit.jupiter.api.Test)

Aggregations

UnknownSaslMechanismDetectedEvent (com.couchbase.client.core.cnc.events.io.UnknownSaslMechanismDetectedEvent)1 ByteBuf (com.couchbase.client.core.deps.io.netty.buffer.ByteBuf)1 ChannelFuture (com.couchbase.client.core.deps.io.netty.channel.ChannelFuture)1 SaslMechanism (com.couchbase.client.core.env.SaslMechanism)1 InetSocketAddress (java.net.InetSocketAddress)1 Test (org.junit.jupiter.api.Test)1