Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ public class HandshakeProtocolTests
[InlineData("{\"protocol\":\"dummy\",\"version\":1}\u001e", "dummy", 1)]
[InlineData("{\"protocol\":\"\",\"version\":10}\u001e", "", 10)]
[InlineData("{\"protocol\":\"\",\"version\":10,\"unknown\":null}\u001e", "", 10)]
[InlineData("{\"protocol\":\"firstProtocol\",\"protocol\":\"secondProtocol\",\"version\":1}\u001e", "secondProtocol", 1)]
[InlineData("{\"protocol\":\"firstProtocol\",\"protocol\":\"secondProtocol\",\"version\":1,\"version\":75}\u001e", "secondProtocol", 75)]
[InlineData("{\"protocol\":\"dummy\",\"version\":1,\"ignoredField\":99}\u001e", "dummy", 1)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if there's multiple json objects prior to the \u001e delimiter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some tests for escaped property names too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if there's multiple json objects prior to the \u001e delimiter.

For the handshake, the parsing logic returns as soon as the end of the json object is found. So the paylod
"{\"protocol\":\"json\",\"version\":1}{\"protocol\":\"wrong\",\"version\":99}\u001e" would result in a Handshake request message with json and version 1.

[InlineData("{\"protocol\":\"dummy\",\"version\":1}{\"protocol\":\"wrong\",\"version\":99}\u001e", "dummy", 1)]
[InlineData("{\"protocol\":\"\\u0064ummy\",\"version\":1}\u001e", "dummy", 1)]
[InlineData("{\"\\u0070rotoco\\u006c\":\"\\u0064ummy\",\"version\":1}\u001e", "dummy", 1)]
public void ParsingHandshakeRequestMessageSuccessForValidMessages(string json, string protocol, int version)
{
var message = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(json));
Expand Down