-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also: added debug data for various errors (DATA, PING, WINDOW_UPDATE)
- Loading branch information
Showing
5 changed files
with
74 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
defmodule Kadabra.Connection.ProcessorTest do | ||
use ExUnit.Case | ||
|
||
alias Kadabra.Connection | ||
alias Kadabra.Connection.Processor | ||
alias Kadabra.Frame.{Data, Ping, WindowUpdate} | ||
|
||
defp conn do | ||
%Connection{ | ||
config: %{ | ||
client: self() | ||
}, | ||
flow_control: %Connection.FlowControl{} | ||
} | ||
end | ||
|
||
test "throws connection error on non-zero DATA stream_id" do | ||
bad = %Data{stream_id: 0} | ||
|
||
assert {:connection_error, :PROTOCOL_ERROR, _, _} = | ||
Processor.process(bad, conn()) | ||
end | ||
|
||
describe "process PING" do | ||
test "throws connection error on non-zero stream_id" do | ||
bad = %Ping{stream_id: 1} | ||
|
||
assert {:connection_error, :PROTOCOL_ERROR, _, _} = | ||
Processor.process(bad, conn()) | ||
end | ||
|
||
test "throws connection error if payload not 8 bytes" do | ||
bad = %Ping{data: <<0, 1>>} | ||
|
||
assert {:connection_error, :FRAME_SIZE_ERROR, _, _} = | ||
Processor.process(bad, conn()) | ||
end | ||
end | ||
|
||
describe "process WINDOW_UPDATE" do | ||
test "throws connection error zero or negative increment" do | ||
bad = %WindowUpdate{window_size_increment: 0, stream_id: 0} | ||
bad_2 = %WindowUpdate{window_size_increment: -5, stream_id: 0} | ||
|
||
for b <- [bad, bad_2] do | ||
assert {:connection_error, :PROTOCOL_ERROR, _, _} = | ||
Processor.process(b, conn()) | ||
end | ||
end | ||
end | ||
end |