Fl4m3Ph03n1x

Fl4m3Ph03n1x

Bypass fails test with TLS error

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?

Marked As Solved

trisolaran

trisolaran

You can’t use https with Bypass. You should configure your application to use http for the tests.

Where Next?

Popular in Questions Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New

We're in Beta

About us Mission Statement