2019-05-17 10:21:11 -06:00
|
|
|
# Pleroma: A lightweight social networking server
|
2021-01-12 23:49:20 -07:00
|
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
2019-05-17 10:21:11 -06:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-06-23 09:16:47 -06:00
|
|
|
defmodule Pleroma.Web.MongooseIMControllerTest do
|
2023-08-01 04:43:50 -06:00
|
|
|
use Pleroma.Web.ConnCase, async: false
|
2019-05-17 10:21:11 -06:00
|
|
|
import Pleroma.Factory
|
|
|
|
|
|
|
|
test "/user_exists", %{conn: conn} do
|
|
|
|
_user = insert(:user, nickname: "lain")
|
|
|
|
_remote_user = insert(:user, nickname: "alice", local: false)
|
2020-10-12 16:42:27 -06:00
|
|
|
_deactivated_user = insert(:user, nickname: "konata", is_active: false)
|
2019-05-17 10:21:11 -06:00
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
2023-08-15 04:22:18 -06:00
|
|
|
|> get(~p"/user_exists", user: "lain")
|
2019-05-17 10:21:11 -06:00
|
|
|
|> json_response(200)
|
|
|
|
|
|
|
|
assert res == true
|
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
2023-08-15 04:22:18 -06:00
|
|
|
|> get(~p"/user_exists", user: "alice")
|
2019-05-17 10:21:11 -06:00
|
|
|
|> json_response(404)
|
|
|
|
|
|
|
|
assert res == false
|
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
2023-08-15 04:22:18 -06:00
|
|
|
|> get(~p"/user_exists", user: "bob")
|
2019-05-17 10:21:11 -06:00
|
|
|
|> json_response(404)
|
|
|
|
|
|
|
|
assert res == false
|
2020-04-27 11:16:05 -06:00
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
2023-08-15 04:22:18 -06:00
|
|
|
|> get(~p"/user_exists", user: "konata")
|
2020-04-27 11:16:05 -06:00
|
|
|
|> json_response(404)
|
|
|
|
|
|
|
|
assert res == false
|
2019-05-17 10:21:11 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
test "/check_password", %{conn: conn} do
|
2022-12-29 19:46:58 -07:00
|
|
|
user = insert(:user, password_hash: Pleroma.Password.hash_pwd_salt("cool"))
|
2020-04-27 17:29:31 -06:00
|
|
|
|
|
|
|
_deactivated_user =
|
|
|
|
insert(:user,
|
|
|
|
nickname: "konata",
|
2020-10-12 16:42:27 -06:00
|
|
|
is_active: false,
|
2022-12-29 19:46:58 -07:00
|
|
|
password_hash: Pleroma.Password.hash_pwd_salt("cool")
|
2020-04-27 17:29:31 -06:00
|
|
|
)
|
2019-05-17 10:21:11 -06:00
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
2023-08-15 04:22:18 -06:00
|
|
|
|> get(~p"/check_password", user: user.nickname, pass: "cool")
|
2019-05-17 10:21:11 -06:00
|
|
|
|> json_response(200)
|
|
|
|
|
|
|
|
assert res == true
|
|
|
|
|
|
|
|
res =
|
|
|
|
conn
|
2023-08-15 04:22:18 -06:00
|
|
|
|> get(~p"/check_password", user: user.nickname, pass: "uncool")
|
2019-05-17 10:21:11 -06:00
|
|
|
|> json_response(403)
|
|
|
|
|
|
|
|
assert res == false
|
|
|
|
|
2020-04-27 10:31:00 -06:00
|
|
|
res =
|
|
|
|
conn
|
2023-08-15 04:22:18 -06:00
|
|
|
|> get(~p"/check_password", user: "konata", pass: "cool")
|
2020-04-27 10:31:00 -06:00
|
|
|
|> json_response(404)
|
|
|
|
|
|
|
|
assert res == false
|
|
|
|
|
2019-05-17 10:21:11 -06:00
|
|
|
res =
|
|
|
|
conn
|
2023-08-15 04:22:18 -06:00
|
|
|
|> get(~p"/check_password", user: "nobody", pass: "cool")
|
2019-05-17 10:21:11 -06:00
|
|
|
|> json_response(404)
|
|
|
|
|
|
|
|
assert res == false
|
|
|
|
end
|
|
|
|
end
|