add tests for deactivated users for mongoose auth
This commit is contained in:
parent
a626cb682c
commit
5c7cc10917
|
@ -27,8 +27,13 @@ def user_exists(conn, %{"user" => username}) do
|
|||
|
||||
def check_password(conn, %{"user" => username, "pass" => password}) do
|
||||
user = Repo.get_by(User, nickname: username, local: true)
|
||||
|
||||
state = case user do
|
||||
nil -> nil
|
||||
_ -> User.account_status(user)
|
||||
end
|
||||
|
||||
case User.account_status(user) do
|
||||
case state do
|
||||
:deactivated ->
|
||||
conn
|
||||
|> put_status(:not_found)
|
||||
|
|
|
@ -34,6 +34,7 @@ test "/user_exists", %{conn: conn} do
|
|||
|
||||
test "/check_password", %{conn: conn} do
|
||||
user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt("cool"))
|
||||
_deactivated_user = insert(:user, nickname: "konata", local: false, deactivated: true)
|
||||
|
||||
res =
|
||||
conn
|
||||
|
@ -49,6 +50,14 @@ test "/check_password", %{conn: conn} do
|
|||
|
||||
assert res == false
|
||||
|
||||
res =
|
||||
conn
|
||||
|> get(mongoose_im_path(conn, :check_password), user: "konata", pass: "1337")
|
||||
|> json_response(404)
|
||||
|
||||
assert res == false
|
||||
|
||||
|
||||
res =
|
||||
conn
|
||||
|> get(mongoose_im_path(conn, :check_password), user: "nobody", pass: "cool")
|
||||
|
|
Loading…
Reference in New Issue