fix(admin-api): reject explicit empty passwords

This commit is contained in:
Lain Soykaf 2026-07-24 22:52:23 +04:00
commit 836f4a2d69
No known key found for this signature in database
4 changed files with 25 additions and 11 deletions

View file

@ -208,6 +208,21 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest do
refute Map.has_key?(account2["data"], "password_reset_link")
end
test "Explicit empty passwords return a conflict", %{conn: conn} do
conn =
conn
|> put_req_header("accept", "application/json")
|> put_req_header("content-type", "application/json")
|> post("/api/pleroma/admin/users", %{
"users" => [
%{"nickname" => "lain", "email" => "lain@example.org", "password" => ""}
]
})
assert [%{"error" => "password can't be blank"}] = json_response(conn, 409)
refute User.get_by_nickname("lain")
end
test "Password reset token failures roll back the user batch", %{conn: conn} do
with_mock Pleroma.PasswordResetToken, [:passthrough],
create_token: fn user ->