Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Add test for firewall
Uku Taht2e1904e5f05d
diff --git a/test/plausible_web/plugs/firewall_test.exs b/test/plausible_web/plugs/firewall_test.exsnew file mode 100644index 0000000000..204c1f1284--- /dev/null+++ b/test/plausible_web/plugs/firewall_test.exs@@ -0,0 +1,28 @@+defmodule PlausibleWeb.FirewallTest do+ use Plausible.DataCase+ use Plug.Test+ alias PlausibleWeb.Firewall++ @allowed_ip "127.0.0.2"+ @blocked_ip "127.0.0.1"+ @opts [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