diff options
| author | Simponic <loganhunt@simponic.xyz> | 2022-12-19 20:45:01 -0700 |
|---|---|---|
| committer | Simponic <loganhunt@simponic.xyz> | 2022-12-19 20:45:01 -0700 |
| commit | 110eb0b1990d5d5ee77f9368a9b7653cfdc07131 (patch) | |
| tree | bfe5744255cdfbdc9412d148236a2bf5f8aad7c1 /test/auth/password_test.exs | |
| parent | fe661a935ac887b11aec31ff049ace2db7ccbf84 (diff) | |
| download | chessh-110eb0b1990d5d5ee77f9368a9b7653cfdc07131.tar.gz chessh-110eb0b1990d5d5ee77f9368a9b7653cfdc07131.zip | |
Implement public key and add tests
Diffstat (limited to 'test/auth/password_test.exs')
| -rw-r--r-- | test/auth/password_test.exs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/auth/password_test.exs b/test/auth/password_test.exs new file mode 100644 index 0000000..974f2fa --- /dev/null +++ b/test/auth/password_test.exs @@ -0,0 +1,27 @@ +defmodule Chessh.Auth.PasswordAuthenticatorTest do + use ExUnit.Case + alias Chessh.Player + alias Chessh.Repo + + @valid_user %{username: "logan", password: "password"} + + setup do + :ok = Ecto.Adapters.SQL.Sandbox.checkout(Chessh.Repo) + + {:ok, _user} = Repo.insert(Player.registration_changeset(%Player{}, @valid_user)) + + :ok + end + + test "User can sign in with their password" do + assert Chessh.Auth.PasswordAuthenticator.authenticate( + String.to_charlist(@valid_user.username), + String.to_charlist(@valid_user.password) + ) + + refute Chessh.Auth.PasswordAuthenticator.authenticate( + String.to_charlist(@valid_user.username), + String.to_charlist("a_bad_password") + ) + end +end |
