mirror of
https://github.com/plausible/analytics.git
synced 2024-12-26 02:55:02 +03:00
a4b9c3b8ba
* Disable super-admin checks on small build * Mute a test writing to stdout * Move sampling outside of small build * Convert waiting_first_pageview to heex and stop relying on env vars * Set site limit unlimited on small build * Stop relying on app env to get trial expiry * Remove custom domains - including migration * Remove is_selfhosted from layout view * Quota fixup * Stop relying on app env for self hosted registration * Stop relying on app env for pass reset success * Apply on_trial? check only on full build * Update templates relying on app env * Adjusts auth controller tests for small build * Trial fixup * Fixup * Stop relying on app env * Rest of the fsckn owl * Update typespecs * Fix dialyzer warning * Remove unused module * Credo + format * GeoIP is not, for full build * Use `small_build?()` where applicable * Implement bypassing FirstLaunchPlug without insertions * Get Marko's patchde58a18a85
* Test is-dbip=false presence * Fix typespec * Remove future hardcodes * Handle `nil` from `Plausible.Geo.database_type()` * Remove XXX marker * Use one typespec for two clauses * Introduce `MIX_ENV=small_dev` * Revert "Use one typespec for two clauses" This reverts commit8d8cd21764
.
54 lines
1.4 KiB
Elixir
54 lines
1.4 KiB
Elixir
defmodule PlausibleWeb.AuthController.LogsTest do
|
|
use PlausibleWeb.ConnCase
|
|
import ExUnit.CaptureLog
|
|
|
|
setup {PlausibleWeb.FirstLaunchPlug.Test, :skip}
|
|
|
|
describe "POST /login" do
|
|
setup do
|
|
patch_env(:log_failed_login_attempts, true)
|
|
end
|
|
|
|
test "logs on missing user", %{conn: conn} do
|
|
logs =
|
|
capture_log(fn ->
|
|
post(conn, "/login", email: "user@example.com", password: "password")
|
|
end)
|
|
|
|
assert logs =~ "[warning] [login] user not found for user@example.com"
|
|
end
|
|
|
|
test "logs on wrong password", %{conn: conn} do
|
|
user = insert(:user, password: "password")
|
|
|
|
logs =
|
|
capture_log(fn ->
|
|
post(conn, "/login", email: user.email, password: "wrong")
|
|
end)
|
|
|
|
assert logs =~ "[warning] [login] wrong password for #{user.email}"
|
|
end
|
|
|
|
test "logs on too many login attempts", %{conn: conn} do
|
|
user = insert(:user, password: "password")
|
|
|
|
capture_log(fn ->
|
|
for _ <- 1..5 do
|
|
build_conn()
|
|
|> put_req_header("x-forwarded-for", "1.1.1.1")
|
|
|> post("/login", email: user.email, password: "wrong")
|
|
end
|
|
end)
|
|
|
|
logs =
|
|
capture_log(fn ->
|
|
conn
|
|
|> put_req_header("x-forwarded-for", "1.1.1.1")
|
|
|> post("/login", email: user.email, password: "wrong")
|
|
end)
|
|
|
|
assert logs =~ "[warning] [login] too many logging attempts for #{user.email}"
|
|
end
|
|
end
|
|
end
|