Search in sources :

Example 1 with SecureConnectionFailedEvent

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

the class TransportEncryptionIntegrationTest method failsIfWrongCertPresent.

@Test
@SuppressWarnings("unchecked")
void failsIfWrongCertPresent() {
    SimpleEventBus eventBus = new SimpleEventBus(true);
    CoreEnvironment env = secureEnvironment(SecurityConfig.enableTls(true).trustCertificates(mock(List.class)), eventBus);
    Core core = Core.create(env, authenticator(), secureSeeds());
    try {
        core.openBucket(config().bucketname());
        waitUntilCondition(() -> {
            boolean hasEndpointConnectFailedEvent = false;
            boolean hasSecureConnectionFailedEvent = false;
            for (Event event : eventBus.publishedEvents()) {
                if (event instanceof EndpointConnectionFailedEvent) {
                    hasEndpointConnectFailedEvent = true;
                }
                if (event instanceof SecureConnectionFailedEvent) {
                    hasSecureConnectionFailedEvent = true;
                }
            }
            return hasEndpointConnectFailedEvent && hasSecureConnectionFailedEvent;
        });
    } finally {
        core.shutdown().block();
        env.shutdown();
    }
}
Also used : CoreEnvironment(com.couchbase.client.core.env.CoreEnvironment) SecureConnectionFailedEvent(com.couchbase.client.core.cnc.events.io.SecureConnectionFailedEvent) SimpleEventBus(com.couchbase.client.core.cnc.SimpleEventBus) SecureConnectionFailedEvent(com.couchbase.client.core.cnc.events.io.SecureConnectionFailedEvent) EndpointConnectionFailedEvent(com.couchbase.client.core.cnc.events.endpoint.EndpointConnectionFailedEvent) Event(com.couchbase.client.core.cnc.Event) EndpointConnectionFailedEvent(com.couchbase.client.core.cnc.events.endpoint.EndpointConnectionFailedEvent) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

Event (com.couchbase.client.core.cnc.Event)1 SimpleEventBus (com.couchbase.client.core.cnc.SimpleEventBus)1 EndpointConnectionFailedEvent (com.couchbase.client.core.cnc.events.endpoint.EndpointConnectionFailedEvent)1 SecureConnectionFailedEvent (com.couchbase.client.core.cnc.events.io.SecureConnectionFailedEvent)1 CoreEnvironment (com.couchbase.client.core.env.CoreEnvironment)1 CoreIntegrationTest (com.couchbase.client.core.util.CoreIntegrationTest)1 Test (org.junit.jupiter.api.Test)1