-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into config_prod_port
- Loading branch information
Showing
4 changed files
with
25 additions
and
8 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
22 changes: 15 additions & 7 deletions
22
apps/transport/test/transport_web/routing/proxy_routing_test.exs
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 |
---|---|---|
@@ -1,16 +1,24 @@ | ||
defmodule TransportWeb.ProxyRoutingTest do | ||
use TransportWeb.ConnCase, async: true | ||
import Phoenix.ConnTest | ||
|
||
test "accepts proxy. subdomain calls and delegates them to unlock", %{conn: conn} do | ||
conn = | ||
conn | ||
|> Map.put(:host, "proxy.example.com") | ||
|> get(~p"/") | ||
test "accepts proxy. subdomain, calls and delegates them to Unlock", %{conn: conn} do | ||
conn = %{conn | host: "proxy.example.com"} |> get(~p"/") | ||
|
||
[h] = Plug.Conn.get_resp_header(conn, "x-request-id") | ||
assert h | ||
|
||
assert text_response(conn, 200) =~ ~r/Unlock/ | ||
assert text_response(conn, 200) =~ "Unlock" | ||
end | ||
|
||
test "rate limiter is not enabled for proxy", %{conn: conn} do | ||
[blocked_ip] = Application.fetch_env!(:phoenix_ddos, :blocklist_ips) | ||
|
||
response = | ||
%{conn | host: "proxy.example.com"} | ||
|> Plug.Conn.put_req_header("x-forwarded-for", to_string(blocked_ip)) | ||
|> get(~p"/") | ||
|> text_response(200) | ||
|
||
assert response =~ "Unlock" | ||
end | ||
end |