use of com.couchbase.client.core.endpoint.EndpointContext in project couchbase-jvm-clients by couchbase.
the class PasswordAuthenticatorTest method ldapCompatibleOnlyEnablesPlain.
@Test
void ldapCompatibleOnlyEnablesPlain() {
PasswordAuthenticator authenticator = PasswordAuthenticator.ldapCompatible("user", "pass");
EndpointContext ctx = mock(EndpointContext.class);
when(ctx.environment()).thenReturn(ENV);
EmbeddedChannel channel = new EmbeddedChannel();
authenticator.authKeyValueConnection(ctx, channel.pipeline());
SaslAuthenticationHandler handler = channel.pipeline().get(SaslAuthenticationHandler.class);
assertEquals(EnumSet.of(SaslMechanism.PLAIN), handler.allowedMechanisms());
}
use of com.couchbase.client.core.endpoint.EndpointContext in project couchbase-jvm-clients by couchbase.
the class PasswordAuthenticatorTest method allowsToEnablePlainInAddition.
@Test
void allowsToEnablePlainInAddition() {
PasswordAuthenticator authenticator = PasswordAuthenticator.builder().username("user").password("pass").enablePlainSaslMechanism().build();
EndpointContext ctx = mock(EndpointContext.class);
when(ctx.environment()).thenReturn(ENV);
EmbeddedChannel channel = new EmbeddedChannel();
authenticator.authKeyValueConnection(ctx, channel.pipeline());
SaslAuthenticationHandler handler = channel.pipeline().get(SaslAuthenticationHandler.class);
assertEquals(EnumSet.allOf(SaslMechanism.class), handler.allowedMechanisms());
}
use of com.couchbase.client.core.endpoint.EndpointContext in project couchbase-jvm-clients by couchbase.
the class PasswordAuthenticatorTest method shouldOnlyNegotiatePlainWhenTlsEnabled.
/**
* Regression test for JVMCBC-890.
*/
@Test
void shouldOnlyNegotiatePlainWhenTlsEnabled() {
PasswordAuthenticator authenticator = PasswordAuthenticator.create("user", "pass");
CoreEnvironment tlsEnvironment = CoreEnvironment.builder().securityConfig(SecurityConfig.enableTls(true).trustManagerFactory(InsecureTrustManagerFactory.INSTANCE)).build();
try {
EndpointContext ctx = mock(EndpointContext.class);
when(ctx.environment()).thenReturn(tlsEnvironment);
EmbeddedChannel channel = new EmbeddedChannel();
authenticator.authKeyValueConnection(ctx, channel.pipeline());
SaslAuthenticationHandler handler = channel.pipeline().get(SaslAuthenticationHandler.class);
assertEquals(EnumSet.of(SaslMechanism.PLAIN), handler.allowedMechanisms());
} finally {
tlsEnvironment.shutdown();
}
}
use of com.couchbase.client.core.endpoint.EndpointContext in project couchbase-jvm-clients by couchbase.
the class KeyValueChannelIntegrationTest method beforeAll.
@BeforeAll
static void beforeAll() {
TestNodeConfig node = config().nodes().get(0);
env = environment().eventBus(eventBus).build();
Core core = Core.create(env, authenticator(), seedNodes());
endpointContext = new EndpointContext(core.context(), new HostAndPort(node.hostname(), node.ports().get(Services.KV)), null, ServiceType.KV, Optional.empty(), Optional.of(config().bucketname()), Optional.empty());
eventLoopGroup = new NioEventLoopGroup(1);
}
use of com.couchbase.client.core.endpoint.EndpointContext in project couchbase-jvm-clients by couchbase.
the class MemcacheProtocolVerificationHandlerTest method shouldVerifyCorrectResponses.
/**
* Verifies good responses are passed through.
*
* @param inputHolder the good input packets.
*/
@ParameterizedTest(name = "{0}")
@MethodSource
void shouldVerifyCorrectResponses(final InputHolder inputHolder) {
EndpointContext ctx = mock(EndpointContext.class);
final EmbeddedChannel channel = new EmbeddedChannel(new MemcacheProtocolVerificationHandler(ctx));
try {
channel.writeInbound(inputHolder.input);
ByteBuf written = channel.readInbound();
assertEquals(inputHolder.input, written);
} finally {
channel.finishAndReleaseAll();
}
}
Aggregations