EnsureHostMatchesPlug: Add more tests
This commit is contained in:
parent
90e390e45b
commit
35b5447f3f
1 changed files with 25 additions and 0 deletions
|
|
@ -55,6 +55,19 @@ defmodule Pleroma.Web.Plugs.EnsureHostMatchesPlugTest do
|
|||
assert conn.resp_body == "Host header does not match this instance"
|
||||
end
|
||||
|
||||
test "it rejects Host header not matching Endpoint with port", %{conn: conn} do
|
||||
endpoint = URI.parse(Endpoint.url())
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> set_host("invalid.example.com:#{endpoint.port}")
|
||||
|> EnsureHostMatchesPlug.call(%{})
|
||||
|
||||
assert conn.status == 400
|
||||
assert conn.halted == true
|
||||
assert conn.resp_body == "Host header does not match this instance"
|
||||
end
|
||||
|
||||
test "it rejects Host header not matching Endpoint port", %{conn: conn} do
|
||||
endpoint = URI.parse(Endpoint.url())
|
||||
|
||||
|
|
@ -80,6 +93,18 @@ defmodule Pleroma.Web.Plugs.EnsureHostMatchesPlugTest do
|
|||
assert conn.resp_body == "More than one Host header provided"
|
||||
end
|
||||
|
||||
test "it works for Host header without port", %{conn: conn} do
|
||||
endpoint = URI.parse(Endpoint.url())
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> set_host("#{endpoint.host}")
|
||||
|> EnsureHostMatchesPlug.call(%{})
|
||||
|
||||
assert conn.halted == false
|
||||
assert Map.get(conn.assigns, :valid_host_header, nil)
|
||||
end
|
||||
|
||||
test "it works for Host header with port as 80", %{conn: conn} do
|
||||
endpoint = URI.parse(Endpoint.url())
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue