Search in sources :

Example 6 with TransportConnection

use of org.neo4j.bolt.v1.transport.socket.client.TransportConnection in project neo4j by neo4j.

the class AuthProceduresInteractionTestBase method shouldTerminateConnectionsOnUserSuspension.

@Test
public void shouldTerminateConnectionsOnUserSuspension() throws Exception {
    TransportConnection conn = startBoltSession("writeSubject", "abc");
    Map<String, Long> boltConnections = countBoltConnectionsByUsername();
    assertThat(boltConnections.get("writeSubject"), equalTo(IS_BOLT ? 2L : 1L));
    assertEmpty(adminSubject, "CALL dbms.security.suspendUser( 'writeSubject' )");
    boltConnections = countBoltConnectionsByUsername();
    assertThat(boltConnections.get("writeSubject"), equalTo(null));
    conn.disconnect();
}
Also used : TransportConnection(org.neo4j.bolt.v1.transport.socket.client.TransportConnection) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 7 with TransportConnection

use of org.neo4j.bolt.v1.transport.socket.client.TransportConnection in project neo4j by neo4j.

the class LdapAuthIT method clearAuthCacheFromDifferentConnection.

private void clearAuthCacheFromDifferentConnection() throws Exception {
    TransportConnection adminClient = cf.newInstance();
    // Login as admin
    Map<String, Object> authToken = authToken("neo4j", "abc123", null);
    adminClient.connect(address).send(TransportTestUtil.acceptedVersions(1, 0, 0, 0)).send(TransportTestUtil.chunk(init("TestClient/1.1", authToken)));
    assertThat(adminClient, eventuallyReceives(new byte[] { 0, 0, 0, 1 }));
    assertThat(adminClient, eventuallyReceives(msgSuccess()));
    // Clear auth cache
    adminClient.send(TransportTestUtil.chunk(run("CALL dbms.security.clearAuthCache()"), pullAll()));
    assertThat(adminClient, eventuallyReceives(msgSuccess(), msgSuccess()));
}
Also used : TransportConnection(org.neo4j.bolt.v1.transport.socket.client.TransportConnection)

Example 8 with TransportConnection

use of org.neo4j.bolt.v1.transport.socket.client.TransportConnection in project neo4j by neo4j.

the class TransportTestUtil method eventuallyReceives.

public static Matcher<TransportConnection> eventuallyReceives(final Matcher<ResponseMessage>... messages) {
    return new TypeSafeMatcher<TransportConnection>() {

        @Override
        protected boolean matchesSafely(TransportConnection conn) {
            try {
                for (Matcher<ResponseMessage> matchesMessage : messages) {
                    final ResponseMessage message = receiveOneResponseMessage(conn);
                    assertThat(message, matchesMessage);
                }
                return true;
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        @Override
        public void describeTo(Description description) {
            description.appendValueList("Messages[", ",", "]", messages);
        }
    };
}
Also used : TypeSafeMatcher(org.hamcrest.TypeSafeMatcher) TransportConnection(org.neo4j.bolt.v1.transport.socket.client.TransportConnection) Description(org.hamcrest.Description) ResponseMessage(org.neo4j.bolt.v1.messaging.message.ResponseMessage) IOException(java.io.IOException)

Aggregations

TransportConnection (org.neo4j.bolt.v1.transport.socket.client.TransportConnection)7 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Test (org.junit.Test)2 ResponseMessage (org.neo4j.bolt.v1.messaging.message.ResponseMessage)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Callable (java.util.concurrent.Callable)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Description (org.hamcrest.Description)1 TypeSafeMatcher (org.hamcrest.TypeSafeMatcher)1 AuthenticationException (org.neo4j.bolt.security.auth.AuthenticationException)1 FailureMessage (org.neo4j.bolt.v1.messaging.message.FailureMessage)1 RecordMessage (org.neo4j.bolt.v1.messaging.message.RecordMessage)1 SuccessMessage (org.neo4j.bolt.v1.messaging.message.SuccessMessage)1 SocketConnection (org.neo4j.bolt.v1.transport.socket.client.SocketConnection)1 HostnamePort (org.neo4j.helpers.HostnamePort)1