Skip to content

Commit 9e98044

Browse files
robsdedudeMaxAakeinjectives
authored
Bolt handshake v2 (#641)
Adds test for the handshake manifest, additionally moves tests on bolt 4.1 to bolt 4.2, as drivers are dropping 4.1 from the handshake. Co-authored-by: MaxAake <[email protected]> Co-authored-by: Dmitriy Tverdiakov <[email protected]>
1 parent 023c7d8 commit 9e98044

File tree

82 files changed

+1047
-299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1047
-299
lines changed

boltstub/README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,17 @@ The following options are available:
2424
Furthermore, with `!: AUTO GOODBYE`, the driver can reach the end of the script at any point which greatly decreases the usefulness of asserting a full script playthrough (i.e. successful Stubserver shutdown). Instead, use auto lines (see further down).
2525
* `!: BOLT ${BOLT VERSION}` **(required)**
2626
Configure the Bolt version the server is speaking.
27-
E.g., `!: BOLT 4.0` or `!: BOLT 4`
27+
E.g., `!: BOLT 4.0` or `!: BOLT 4`
28+
The bolt maximum handshake version (non-manifest, manifest vX) is chosen automatically based on the specified Bolt version.
29+
Previous versions might also be accepted mirroring the behavior of the Neo4j server.
30+
For Bolt handshake version 2 (requires Bolt version 5.7+), feature flags can be specified following the protocol version.
31+
They're to be specified in raw hex bytes and must be a valid varint encoded integer.
32+
The server expects the client to opt into all feature flags offered.
33+
E.g., `!: BOLT 5.7 FF 01` (sending feature flags 1 through 7 and 14)
34+
* `!: HANDSHAKE_MANIFEST ${MANIFEST VERSION}`
35+
E.g., `!: HANDSHAKE_MANIFEST 1`
36+
Force the bolt version to be negotiated using the specified manifest version.
37+
`0` indicates non-manifest negotiation.
2838
* `!: ALLOW RESTART`
2939
By default, the server shuts itself down as soon as the end of the script is reached or the client sends an unexpected message.
3040
If this bang line is part of the head, the server will allow a new connection every time the script has successfully been played through until the end with the previous connection.
@@ -39,6 +49,11 @@ The following options are available:
3949
By default the server automatically performs a handshake (incl. protocol version negotiation) with the client upon connection (https://7687.org/bolt/bolt-protocol-handshake-specification.html).
4050
This bang line allows for overwriting the response of the server that normally contains the protocol version which the server wants to speak with the client.
4151
E.g. `!: HANDSHAKE FF 00 00 01`
52+
* `!: HANDSHAKE_RESPONSE ${HEX BYTES}`
53+
This field requires `!: HANDSKE ${HEX BYTES}` to be present.
54+
It's main purpose is to facilitate Bolt handshake v2 overwrites.
55+
The data (`${HEX BYTES}`) will be expected to be received from the client after the server has sent the handshake data specified in `!: HANDSHAKE ${HEX BYTES}`.
56+
E.g. `!: HANDSHAKE 00 00 01 FF 00 00 00 07 05 00` and `!: HANDSHAKE_RESPONSE 00 00 07 05`
4257
* `!: HANDSHAKE_DELAY ${DELAY_IN_S}`
4358
Wait for `${DELAY_IN_S}` (can be int or float) seconds before sending the handshake response.
4459
* `!: PY ${ARBITRATY PYTHON CODE}`

boltstub/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,11 @@ class BoltActor:
214214
def __init__(self, script: Script, wire, eval_context: EvalContext):
215215
self.script = script
216216
self.channel = Channel(
217-
wire, script.context.bolt_version, log_cb=self.log,
217+
wire, script.context.bolt_version, script.context.bolt_features,
218+
log_cb=self.log,
219+
handshake_manifest=script.context.handshake_manifest,
218220
handshake_data=self.script.context.handshake,
221+
handshake_response_data=self.script.context.handshake_response,
219222
handshake_delay=self.script.context.handshake_delay,
220223
eval_context=eval_context,
221224
)

0 commit comments

Comments
 (0)