use of com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel in project couchbase-jvm-clients by couchbase.
the class KeyValueChannelIntegrationTest method failWithInvalidPasswordCredential.
@Test
@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
void failWithInvalidPasswordCredential() throws Exception {
TestNodeConfig node = config().nodes().get(0);
Bootstrap bootstrap = new Bootstrap().remoteAddress(node.hostname(), node.ports().get(Services.KV)).group(eventLoopGroup).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) {
new KeyValueEndpoint.KeyValuePipelineInitializer(endpointContext, Optional.of(config().bucketname()), PasswordAuthenticator.create(config().adminUsername(), "djslkfsdfsoufhoshfoishgs")).init(null, ch.pipeline());
}
});
assertAuthenticationFailure(bootstrap, "Authentication Failure");
}
use of com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel in project couchbase-jvm-clients by couchbase.
the class KeyValueChannelIntegrationTest method failWithInvalidUsernameCredential.
@Test
@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
void failWithInvalidUsernameCredential() throws Exception {
TestNodeConfig node = config().nodes().get(0);
Bootstrap bootstrap = new Bootstrap().remoteAddress(node.hostname(), node.ports().get(Services.KV)).group(eventLoopGroup).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) {
new KeyValueEndpoint.KeyValuePipelineInitializer(endpointContext, Optional.of(config().bucketname()), PasswordAuthenticator.create("vfwmf42343rew", config().adminPassword())).init(null, ch.pipeline());
}
});
assertAuthenticationFailure(bootstrap, "Authentication Failure");
}
use of com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel in project couchbase-jvm-clients by couchbase.
the class KeyValueChannelIntegrationTest method connectNoopAndDisconnect.
/**
* This is the most simple kv test case one can do in a full-stack manner.
*
* <p>It connects to a kv socket, including all auth and bucket selection. It then
* checks that the channel is opened properly and performs a NOOP and checks for a
* successful result. Then it shuts everything down.</p>
*
* @throws Exception if waiting on the response fails.
*/
@Test
void connectNoopAndDisconnect() throws Exception {
TestNodeConfig node = config().nodes().get(0);
Bootstrap bootstrap = new Bootstrap().remoteAddress(node.hostname(), node.ports().get(Services.KV)).group(eventLoopGroup).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) {
new KeyValueEndpoint.KeyValuePipelineInitializer(endpointContext, Optional.of(config().bucketname()), endpointContext.authenticator()).init(null, ch.pipeline());
}
});
Channel channel = bootstrap.connect().awaitUninterruptibly().channel();
assertTrue(channel.isActive());
assertTrue(channel.isOpen());
NoopRequest request = new NoopRequest(Duration.ZERO, endpointContext, null, CollectionIdentifier.fromDefault(config().bucketname()));
channel.writeAndFlush(request);
NoopResponse response = request.response().get(1, TimeUnit.SECONDS);
assertTrue(response.status().success());
channel.close().awaitUninterruptibly();
}
use of com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel in project couchbase-jvm-clients by couchbase.
the class KeyValueChannelIntegrationTest method failWithInvalidBucketCredential.
@Test
void failWithInvalidBucketCredential() throws Exception {
String bucketName = "42eredwefrfe";
TestNodeConfig node = config().nodes().get(0);
Bootstrap bootstrap = new Bootstrap().remoteAddress(node.hostname(), node.ports().get(Services.KV)).group(eventLoopGroup).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) {
new KeyValueEndpoint.KeyValuePipelineInitializer(endpointContext, Optional.of(bucketName), endpointContext.authenticator()).init(null, ch.pipeline());
}
});
assertAuthenticationFailure(bootstrap, "Either the bucket with name \"" + bucketName + "\" is not present " + "or the user does not have the right privileges to access it");
}
Aggregations