Search in sources :

Example 1 with SocketChannel

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");
}
Also used : NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) SocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel) NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) Bootstrap(com.couchbase.client.core.deps.io.netty.bootstrap.Bootstrap) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 2 with SocketChannel

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");
}
Also used : NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) SocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel) NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) Bootstrap(com.couchbase.client.core.deps.io.netty.bootstrap.Bootstrap) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 3 with SocketChannel

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();
}
Also used : NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) NoopRequest(com.couchbase.client.core.msg.kv.NoopRequest) NoopResponse(com.couchbase.client.core.msg.kv.NoopResponse) SocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel) NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) SocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel) Channel(com.couchbase.client.core.deps.io.netty.channel.Channel) NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) Bootstrap(com.couchbase.client.core.deps.io.netty.bootstrap.Bootstrap) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 4 with SocketChannel

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");
}
Also used : NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) SocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel) NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) Bootstrap(com.couchbase.client.core.deps.io.netty.bootstrap.Bootstrap) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

Bootstrap (com.couchbase.client.core.deps.io.netty.bootstrap.Bootstrap)4 SocketChannel (com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel)4 NioSocketChannel (com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel)4 CoreIntegrationTest (com.couchbase.client.core.util.CoreIntegrationTest)4 TestNodeConfig (com.couchbase.client.test.TestNodeConfig)4 Test (org.junit.jupiter.api.Test)4 IgnoreWhen (com.couchbase.client.test.IgnoreWhen)2 Channel (com.couchbase.client.core.deps.io.netty.channel.Channel)1 NoopRequest (com.couchbase.client.core.msg.kv.NoopRequest)1 NoopResponse (com.couchbase.client.core.msg.kv.NoopResponse)1