Background
I am using bypass to test an endpoint from my code. To achieve that I am using the following test code:
@test_port 8082
setup do
bypass = Bypass.open(port: @test_port)
%{
bypass: bypass
}
end
describe "get_user_orders/2" do
test "returns {:ok, [placed_order]} ", %{ bypass: bypass } do
# Arrange
Bypass.expect(bypass, "GET", "/v1/profile/:username/orders", fn conn ->
response = %{
"payload" => %{
"buy_orders" => [],
"sell_orders" => [
%{
"item" => %{
"cs" => %{"item_name" => "Arcane Agility"},
"url_name" => "arcane_agility"
}
},
%{
"item" => %{
"cs" => %{"item_name" => "Abating Link"},
"url_name" => "abating_link"
},
}
]
}
}
Plug.Conn.resp(conn, 200, Jason.encode!(response))
end)
# Act
assert {:ok, [ ... ]} == Server.get_user_orders( "MY_SUPER_USERNAME")
end
end
Problem
The issue here is that even though the code seems to be working correctly, I get this very weird error (and the test fails) using bypass.
URL IS: "https://localhost:8082/v1/profile/MY_SUPER_USERNAME/orders"
12:08:18.188 [notice] TLS :client: In state :hello at tls_record.erl:561 generated CLIENT ALERT: Fatal - Unexpected Message
- {:unsupported_record_type, 72}
1) test get_user_orders/2 (AuctionHouseTest)
apps/auction_house/test/integration/auction_house_test.exs:360
Assertion with == failed
code: {:ok, [ ... ]} == Server.get_user_orders( "MY_SUPER_USERNAME")
left: {
:error,
{:tls_alert, {:unexpected_message, ~c"TLS client: In state hello at tls_record.erl:561 generated CLIENT ALERT: Fatal - Unexpected Message\n {unsupported_record_type,72}"}},
"MY_SUPER_USERNAME"
}
right: {:ok,[...]}
stacktrace:
test/integration/auction_house_test.exs:467: (test)
Finished in 0.3 seconds (0.00s async, 0.3s sync)
7 tests, 1 failure, 6 excluded
The code is returning the correct result, but I get this weird TLS error. How can I fix this?