Search in sources :

Example 11 with HelloMessage

use of org.neo4j.bolt.v41.messaging.request.HelloMessage in project neo4j by neo4j.

the class HelloMessageDecoderTest method shouldDecodeHelloMessage.

@Test
void shouldDecodeHelloMessage() throws Exception {
    HelloMessage originalMessage = new HelloMessage(map("user_agent", "My Driver", "user", "neo4j", "password", "secret", "routing", Collections.emptyMap()), new RoutingContext(true, Collections.emptyMap()), map("user_agent", "My Driver", "user", "neo4j", "password", "secret"));
    assertOriginalMessageEqualsToDecoded(originalMessage, decoder);
}
Also used : RoutingContext(org.neo4j.bolt.v41.messaging.RoutingContext) HelloMessage(org.neo4j.bolt.v41.messaging.request.HelloMessage) AuthTokenDecoderTest(org.neo4j.bolt.security.auth.AuthTokenDecoderTest) Test(org.junit.jupiter.api.Test)

Example 12 with HelloMessage

use of org.neo4j.bolt.v41.messaging.request.HelloMessage in project neo4j by neo4j.

the class BoltRequestMessageV3Test method shouldHandleCommonMessages.

@Test
void shouldHandleCommonMessages() throws Throwable {
    assertSerializes(new HelloMessage(map("user_agent", "MyClient/1.0", "scheme", "basic")));
    assertSerializes(new RunMessage("CREATE (n) RETURN åäö"));
    assertSerializes(DiscardAllMessage.INSTANCE);
    assertSerializes(PullAllMessage.INSTANCE);
    assertSerializes(new BeginMessage());
    assertSerializes(COMMIT_MESSAGE);
    assertSerializes(ROLLBACK_MESSAGE);
    assertSerializes(ResetMessage.INSTANCE);
    assertSerializes(GOODBYE_MESSAGE);
}
Also used : HelloMessage(org.neo4j.bolt.v3.messaging.request.HelloMessage) BeginMessage(org.neo4j.bolt.v3.messaging.request.BeginMessage) RunMessage(org.neo4j.bolt.v3.messaging.request.RunMessage) Test(org.junit.jupiter.api.Test)

Example 13 with HelloMessage

use of org.neo4j.bolt.v41.messaging.request.HelloMessage in project neo4j by neo4j.

the class HelloMessageDecoderTest method shouldDecodeHelloMessageWithRouting.

@Test
void shouldDecodeHelloMessageWithRouting() throws Exception {
    HelloMessage originalMessage = new HelloMessage(map("user_agent", "My Driver", "user", "neo4j", "password", "secret", "routing", map("policy", "europe")), new RoutingContext(true, stringMap("policy", "europe")), map("user_agent", "My Driver", "user", "neo4j", "password", "secret"));
    assertOriginalMessageEqualsToDecoded(originalMessage, decoder);
}
Also used : RoutingContext(org.neo4j.bolt.v41.messaging.RoutingContext) HelloMessage(org.neo4j.bolt.v41.messaging.request.HelloMessage) AuthTokenDecoderTest(org.neo4j.bolt.security.auth.AuthTokenDecoderTest) Test(org.junit.jupiter.api.Test)

Example 14 with HelloMessage

use of org.neo4j.bolt.v41.messaging.request.HelloMessage in project neo4j by neo4j.

the class HelloMessageDecoderTest method testShouldErrorForMissingUserAgent.

@Test
protected void testShouldErrorForMissingUserAgent() throws Exception {
    Neo4jPack neo4jPack = newNeo4jPack();
    Map<String, Object> authToken = new HashMap<>();
    HelloMessage originalMessage = new HelloMessage(authToken);
    PackedInputArray input = new PackedInputArray(encode(neo4jPack, originalMessage));
    Neo4jPack.Unpacker unpacker = neo4jPack.newUnpacker(input);
    // these two steps are executed before decoding in order to select a correct decoder
    unpacker.unpackStructHeader();
    unpacker.unpackStructSignature();
    BoltIOException exception = assertThrows(BoltIOException.class, () -> decoder.decode(unpacker));
    assertEquals("Expected \"user_agent\" in metadata", exception.getMessage());
}
Also used : BoltIOException(org.neo4j.bolt.messaging.BoltIOException) HelloMessage(org.neo4j.bolt.v3.messaging.request.HelloMessage) HashMap(java.util.HashMap) PackedInputArray(org.neo4j.bolt.packstream.PackedInputArray) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack) BoltProtocolV3ComponentFactory.newNeo4jPack(org.neo4j.bolt.v3.BoltProtocolV3ComponentFactory.newNeo4jPack) AuthTokenDecoderTest(org.neo4j.bolt.security.auth.AuthTokenDecoderTest) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)9 RoutingContext (org.neo4j.bolt.v41.messaging.RoutingContext)9 HelloMessage (org.neo4j.bolt.v41.messaging.request.HelloMessage)9 AuthTokenDecoderTest (org.neo4j.bolt.security.auth.AuthTokenDecoderTest)8 Neo4jPack (org.neo4j.bolt.packstream.Neo4jPack)7 PackedInputArray (org.neo4j.bolt.packstream.PackedInputArray)7 BoltProtocolV3ComponentFactory.newNeo4jPack (org.neo4j.bolt.v3.BoltProtocolV3ComponentFactory.newNeo4jPack)7 HashMap (java.util.HashMap)5 RequestMessage (org.neo4j.bolt.messaging.RequestMessage)5 HelloMessage (org.neo4j.bolt.v3.messaging.request.HelloMessage)5 BoltIOException (org.neo4j.bolt.messaging.BoltIOException)2 BeginMessage (org.neo4j.bolt.v3.messaging.request.BeginMessage)1 RunMessage (org.neo4j.bolt.v3.messaging.request.RunMessage)1