Fix discord discriminant tests
This commit is contained in:
parent
2acd6f3f38
commit
744c7999e8
@ -2,7 +2,7 @@ defmodule Chessh.Auth.PasswordAuthenticatorTest do
|
|||||||
use ExUnit.Case
|
use ExUnit.Case
|
||||||
alias Chessh.{Player, Repo}
|
alias Chessh.{Player, Repo}
|
||||||
|
|
||||||
@valid_user %{username: "logan", password: "password", discord_id: "1"}
|
@valid_user %{username: "lizzy", password: "password", discord_id: "1"}
|
||||||
|
|
||||||
setup_all do
|
setup_all do
|
||||||
Ecto.Adapters.SQL.Sandbox.checkout(Repo)
|
Ecto.Adapters.SQL.Sandbox.checkout(Repo)
|
||||||
@ -26,7 +26,7 @@ defmodule Chessh.Auth.PasswordAuthenticatorTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "Password can authenticate a user instance" do
|
test "Password can authenticate a user instance" do
|
||||||
player = Repo.get_by(Player, username: "logan")
|
player = Repo.get_by(Player, username: "lizzy")
|
||||||
|
|
||||||
assert Chessh.Auth.PasswordAuthenticator.authenticate(
|
assert Chessh.Auth.PasswordAuthenticator.authenticate(
|
||||||
player,
|
player,
|
||||||
|
@ -2,7 +2,7 @@ defmodule Chessh.Auth.PublicKeyAuthenticatorTest do
|
|||||||
use ExUnit.Case
|
use ExUnit.Case
|
||||||
alias Chessh.{Key, Repo, Player}
|
alias Chessh.{Key, Repo, Player}
|
||||||
|
|
||||||
@valid_user %{username: "logan", password: "password", discord_id: "2"}
|
@valid_user %{username: "lizzy", password: "password", discord_id: "2"}
|
||||||
@valid_key %{
|
@valid_key %{
|
||||||
name: "The Gamer Machine",
|
name: "The Gamer Machine",
|
||||||
key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ/2LOJGGEd/dhFgRxJ5MMv0jJw4s4pA8qmMbZyulN44"
|
key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ/2LOJGGEd/dhFgRxJ5MMv0jJw4s4pA8qmMbZyulN44"
|
||||||
|
@ -4,17 +4,17 @@ defmodule Chessh.Schema.KeyTest do
|
|||||||
alias Chessh.Key
|
alias Chessh.Key
|
||||||
|
|
||||||
@valid_attrs %{
|
@valid_attrs %{
|
||||||
name: "Logan's Key",
|
name: "Lizzy's Key",
|
||||||
key:
|
key:
|
||||||
{{{:ECPoint,
|
{{{:ECPoint,
|
||||||
<<159, 246, 44, 226, 70, 24, 71, 127, 118, 17, 96, 71, 18, 121, 48, 203, 244, 140, 156,
|
<<159, 246, 44, 226, 70, 24, 71, 127, 118, 17, 96, 71, 18, 121, 48, 203, 244, 140, 156,
|
||||||
56, 179, 138, 64, 242, 169, 140, 109, 156, 174, 148, 222, 56>>},
|
56, 179, 138, 64, 242, 169, 140, 109, 156, 174, 148, 222, 56>>},
|
||||||
{:namedCurve, {1, 3, 101, 112}}}, [comment: 'logan@yagami']}
|
{:namedCurve, {1, 3, 101, 112}}}, [comment: 'lizzy@yagami']}
|
||||||
}
|
}
|
||||||
@valid_key_attrs %{
|
@valid_key_attrs %{
|
||||||
name: "asdf key",
|
name: "asdf key",
|
||||||
key:
|
key:
|
||||||
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBC7Mpf2QIL32MmKxcrXAoZM3l7/hBy+8d+WqTRMun+tC/XYNiXSIDuZv01an3D1d22fmSpZiprFQzjB4yEz23qw= logan@yagami"
|
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBC7Mpf2QIL32MmKxcrXAoZM3l7/hBy+8d+WqTRMun+tC/XYNiXSIDuZv01an3D1d22fmSpZiprFQzjB4yEz23qw= lizzy@yagami"
|
||||||
}
|
}
|
||||||
@invalid_key_attrs %{
|
@invalid_key_attrs %{
|
||||||
name: "An Invalid Key",
|
name: "An Invalid Key",
|
||||||
|
@ -3,10 +3,9 @@ defmodule Chessh.Auth.UserRegistrationTest do
|
|||||||
use ExUnit.Case
|
use ExUnit.Case
|
||||||
alias Chessh.{Player, Repo}
|
alias Chessh.{Player, Repo}
|
||||||
|
|
||||||
@valid_user %{username: "logan", password: "password", discord_id: "4"}
|
@valid_user %{username: "lizzy#0003", password: "password", discord_id: "4"}
|
||||||
@invalid_username %{username: "a", password: "password", discord_id: "7"}
|
@invalid_username %{username: "a", password: "password", discord_id: "7"}
|
||||||
@invalid_password %{username: "aasdf", password: "pass", discord_id: "6"}
|
@invalid_password %{username: "lizzy#0003", password: "pass", discord_id: "6"}
|
||||||
@repeated_username %{username: "LoGan", password: "password", discord_id: "5"}
|
|
||||||
|
|
||||||
test "Password must be at least 8 characters and username must be at least 2" do
|
test "Password must be at least 8 characters and username must be at least 2" do
|
||||||
refute Player.registration_changeset(%Player{}, @invalid_password).valid?
|
refute Player.registration_changeset(%Player{}, @invalid_password).valid?
|
||||||
@ -40,7 +39,7 @@ defmodule Chessh.Auth.UserRegistrationTest do
|
|||||||
refute changeset.changes.hashed_password == @valid_user.password
|
refute changeset.changes.hashed_password == @valid_user.password
|
||||||
end
|
end
|
||||||
|
|
||||||
test "Username is uniquely case insensitive" do
|
test "Username is uniquely case sensitive" do
|
||||||
assert Repo.insert(Player.registration_changeset(%Player{}, @valid_user))
|
assert Repo.insert(Player.registration_changeset(%Player{}, @valid_user))
|
||||||
|
|
||||||
assert {:error,
|
assert {:error,
|
||||||
|
@ -5,7 +5,7 @@ defmodule Chessh.SSH.AuthTest do
|
|||||||
@localhost '127.0.0.1'
|
@localhost '127.0.0.1'
|
||||||
@localhost_inet {{127, 0, 0, 1}, 1}
|
@localhost_inet {{127, 0, 0, 1}, 1}
|
||||||
@key_name "The Gamer Machine"
|
@key_name "The Gamer Machine"
|
||||||
@valid_user %{username: "logan", password: "password", discord_id: "3"}
|
@valid_user %{username: "lizzy", password: "password", discord_id: "3"}
|
||||||
@client_test_keys_dir Path.join(Application.compile_env!(:chessh, :key_dir), "client_keys")
|
@client_test_keys_dir Path.join(Application.compile_env!(:chessh, :key_dir), "client_keys")
|
||||||
@client_pub_key 'id_ed25519.pub'
|
@client_pub_key 'id_ed25519.pub'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user