blob: 1516bdf3b0e74545e0282f2744ecf669c3791928 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
defmodule Chessh.Auth.PasswordAuthenticatorTest do
use ExUnit.Case
alias Chessh.{Player, Repo}
@valid_user %{username: "logan", password: "password"}
setup_all do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Chessh.Repo)
{:ok, _user} = Repo.insert(Player.registration_changeset(%Player{}, @valid_user))
:ok
end
test "Password can authenticate a hashed 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
|