Skip to content

Commit

Permalink
add test for req (header) config
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoch-cars committed Sep 26, 2023
1 parent 72b28f2 commit d4c2a00
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion test/car_req_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,28 @@ defmodule CarReqTest do
secret = "Token Shh, it's a secret"
not_auth_header = [{"NOTauthorization", secret}]
client = TestClientDupeHeaderImpl.client(headers: not_auth_header, auth: secret)
assert client.headers == not_auth_header
# header is downcased and converted to a map
assert client.headers == %{"notauthorization" => ["Token Shh, it's a secret"]}
end
end

describe "config" do
setup do
Application.put_env(:req, :legacy_headers_as_lists, true)
end

test "supports headers config option" do
Application.get_env(:req, :legacy_headers_as_lists) |> IO.inspect(label: "legacy_headers_as_lists")

defmodule TestClientLegacyHeaderImpl do
use CarReq
end

secret = "Token Shh, it's a secret"
not_mangled_auth_header = [{"NOTauthorization", secret}]
client = TestClientLegacyHeaderImpl.client(headers: not_mangled_auth_header, auth: secret)
# header is not mangled
assert client.headers == not_mangled_auth_header
end
end

Expand Down

0 comments on commit d4c2a00

Please sign in to comment.