X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Fplugs%2Fauthentication_plug_test.exs;h=1fbc17a924360a0c3eea9decc484c9646ead6043;hb=1b2c24a19e86434f748a4f3cba6fb688253efb15;hp=118ab302a0c956ad1217f141a5c927e20cf3cf93;hpb=2217b35bd40593f5dcfdba4c13dd7b7bded018f3;p=akkoma diff --git a/test/pleroma/web/plugs/authentication_plug_test.exs b/test/pleroma/web/plugs/authentication_plug_test.exs index 118ab302a..1fbc17a92 100644 --- a/test/pleroma/web/plugs/authentication_plug_test.exs +++ b/test/pleroma/web/plugs/authentication_plug_test.exs @@ -17,7 +17,7 @@ defmodule Pleroma.Web.Plugs.AuthenticationPlugTest do user = %User{ id: 1, name: "dude", - password_hash: Pleroma.Password.Pbkdf2.hash_pwd_salt("guy") + password_hash: Pleroma.Password.hash_pwd_salt("guy") } conn = @@ -52,7 +52,7 @@ defmodule Pleroma.Web.Plugs.AuthenticationPlugTest do assert PlugHelper.plug_skipped?(conn, OAuthScopesPlug) end - test "with a bcrypt hash, it updates to a pkbdf2 hash", %{conn: conn} do + test "with a bcrypt hash, it updates to an argon2 hash", %{conn: conn} do user = insert(:user, password_hash: Bcrypt.hash_pwd_salt("123")) assert "$2" <> _ = user.password_hash @@ -67,21 +67,17 @@ defmodule Pleroma.Web.Plugs.AuthenticationPlugTest do assert PlugHelper.plug_skipped?(conn, OAuthScopesPlug) user = User.get_by_id(user.id) - assert "$pbkdf2" <> _ = user.password_hash + assert "$argon2" <> _ = user.password_hash end - @tag :skip_on_mac - test "with a crypt hash, it updates to a pkbdf2 hash", %{conn: conn} do - user = - insert(:user, - password_hash: - "$6$9psBWV8gxkGOZWBz$PmfCycChoxeJ3GgGzwvhlgacb9mUoZ.KUXNCssekER4SJ7bOK53uXrHNb2e4i8yPFgSKyzaW9CcmrDXWIEMtD1" - ) + test "with a pbkdf2 hash, it updates to an argon2 hash", %{conn: conn} do + user = insert(:user, password_hash: Pleroma.Password.Pbkdf2.hash_pwd_salt("123")) + assert "$pbkdf2" <> _ = user.password_hash conn = conn |> assign(:auth_user, user) - |> assign(:auth_credentials, %{password: "password"}) + |> assign(:auth_credentials, %{password: "123"}) |> AuthenticationPlug.call(%{}) assert conn.assigns.user.id == conn.assigns.auth_user.id @@ -89,7 +85,7 @@ defmodule Pleroma.Web.Plugs.AuthenticationPlugTest do assert PlugHelper.plug_skipped?(conn, OAuthScopesPlug) user = User.get_by_id(user.id) - assert "$pbkdf2" <> _ = user.password_hash + assert "$argon2" <> _ = user.password_hash end describe "checkpw/2" do @@ -101,16 +97,16 @@ defmodule Pleroma.Web.Plugs.AuthenticationPlugTest do refute AuthenticationPlug.checkpw("test-password1", hash) end - @tag :skip_on_mac - test "check sha512-crypt hash" do - hash = - "$6$9psBWV8gxkGOZWBz$PmfCycChoxeJ3GgGzwvhlgacb9mUoZ.KUXNCssekER4SJ7bOK53uXrHNb2e4i8yPFgSKyzaW9CcmrDXWIEMtD1" + test "check bcrypt hash" do + hash = "$2a$10$uyhC/R/zoE1ndwwCtMusK.TLVzkQ/Ugsbqp3uXI.CTTz0gBw.24jS" assert AuthenticationPlug.checkpw("password", hash) + refute AuthenticationPlug.checkpw("password1", hash) end - test "check bcrypt hash" do - hash = "$2a$10$uyhC/R/zoE1ndwwCtMusK.TLVzkQ/Ugsbqp3uXI.CTTz0gBw.24jS" + test "check argon2 hash" do + hash = + "$argon2id$v=19$m=65536,t=8,p=2$zEMMsTuK5KkL5AFWbX7jyQ$VyaQD7PF6e9btz0oH1YiAkWwIGZ7WNDZP8l+a/O171g" assert AuthenticationPlug.checkpw("password", hash) refute AuthenticationPlug.checkpw("password1", hash)