mirror of
https://github.com/plausible/analytics.git
synced 2024-12-25 02:24:55 +03:00
5de43b758d
* Set pg pool size for MIX_ENV=test
* Include slow tests in CI run
* Exclude slow tests by default
* Mark tests slow/async where applicable
* Restructure captcha mocks
* Revert async where env is relied upon
* Add --max-failures=1 to CI run
* Set warnings as errors
* Disable async where various mocks are used
* Revert "Disable async where various mocks are used"
This reverts commit 2446b72a29
.
* Disable async for test using vcr
30 lines
676 B
Elixir
30 lines
676 B
Elixir
defmodule PlausibleWeb.FirewallTest do
|
|
use Plausible.DataCase
|
|
use Plug.Test
|
|
alias PlausibleWeb.Firewall
|
|
|
|
@allowed_ip "127.0.0.1"
|
|
@blocked_ip "127.0.0.2"
|
|
@opts [blocklist: [@blocked_ip]]
|
|
|
|
setup_patch_env(PlausibleWeb.Firewall, blocklist: [@blocked_ip])
|
|
|
|
test "ignores request if IP is allowed" do
|
|
conn =
|
|
conn(:get, "/")
|
|
|> put_req_header("x-forwarded-for", @allowed_ip)
|
|
|> Firewall.call(@opts)
|
|
|
|
assert conn.status == nil
|
|
end
|
|
|
|
test "responds with 404 if IP is blocked" do
|
|
conn =
|
|
conn(:get, "/")
|
|
|> put_req_header("x-forwarded-for", @blocked_ip)
|
|
|> Firewall.call(@opts)
|
|
|
|
assert conn.status == 404
|
|
end
|
|
end
|