You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ji...@apache.org on 2025/01/01 17:55:56 UTC
(couchdb) 04/10: Remove warnings about `test_chttpd_auth_lockout_warning`
This is an automated email from the ASF dual-hosted git repository.
jiahuili430 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit e35979565b3a90b9c79cd16abc887d2f9052c737
Author: Jiahui Li <li...@gmail.com>
AuthorDate: Sun Dec 29 22:44:46 2024 -0600
Remove warnings about `test_chttpd_auth_lockout_warning`
```
warning: function test_chttpd_auth_lockout_warning/0 is unused
│
48 │ defp test_chttpd_auth_lockout_warning do
│ ~
│
└─ test/elixir/test/auth_lockout_test.exs:48:8: AuthLockoutTest (module)
```
---
test/elixir/test/auth_lockout_test.exs | 38 ++++++++++++++++++++--------------
1 file changed, 22 insertions(+), 16 deletions(-)
diff --git a/test/elixir/test/auth_lockout_test.exs b/test/elixir/test/auth_lockout_test.exs
index b039c86eb..67d7752d4 100644
--- a/test/elixir/test/auth_lockout_test.exs
+++ b/test/elixir/test/auth_lockout_test.exs
@@ -20,10 +20,19 @@ defmodule AuthLockoutTest do
}
]
- run_on_modified_server(
- server_config,
- fn -> test_chttpd_auth_lockout_enforcement() end
- )
+ run_on_modified_server(server_config, &test_chttpd_auth_lockout_enforcement/0)
+ end
+
+ test "do not lockout after multiple failed authentications", _context do
+ server_config = [
+ %{
+ :section => "chttpd_auth_lockout",
+ :key => "mode",
+ :value => "warn"
+ }
+ ]
+
+ run_on_modified_server(server_config, &test_chttpd_auth_lockout_warning/0)
end
defp test_chttpd_auth_lockout_enforcement do
@@ -31,34 +40,31 @@ defmodule AuthLockoutTest do
for _n <- 1..5 do
resp = Couch.get("/_all_dbs",
no_auth: true,
- headers: [authorization: "Basic #{:base64.encode("chttpd_auth_lockout:baz")}"]
- )
+ headers: [authorization: "Basic #{:base64.encode("chttpd_auth_lockout:baz")}"]
+ )
+
assert resp.status_code == 401
end
# locked out?
resp = Couch.get("/_all_dbs",
no_auth: true,
- headers: [authorization: "Basic #{:base64.encode("chttpd_auth_lockout:baz")}"]
+ headers: [authorization: "Basic #{:base64.encode("chttpd_auth_lockout:baz")}"]
)
+
assert resp.status_code == 403
assert resp.body["reason"] == "Account is temporarily locked due to multiple authentication failures"
end
defp test_chttpd_auth_lockout_warning do
# exceed the lockout threshold
- for _n <- 1..5 do
+ for _n <- 1..6 do
resp = Couch.get("/_all_dbs",
no_auth: true,
- headers: [authorization: "Basic #{:base64.encode("chttpd_auth_lockout:baz")}"]
- )
+ headers: [authorization: "Basic #{:base64.encode("chttpd_auth_lockout:baz")}"]
+ )
+
assert resp.status_code == 401
end
-
- # warning?
- _resp = Couch.get("/_all_dbs",
- no_auth: true,
- headers: [authorization: "Basic #{:base64.encode("chttpd_auth_lockout:baz")}"]
- )
end
end