diff options
author | Egor Kislitsyn <egor@kislitsyn.com> | 2019-05-24 21:05:57 +0700 |
---|---|---|
committer | Egor Kislitsyn <egor@kislitsyn.com> | 2019-05-24 21:05:57 +0700 |
commit | f333041a0a2b9c2f1ef2236254b8dd3e9a55a688 (patch) | |
tree | 317be4a8b7c0b9a231853ee05547554f5da74c3f /test/web/mongooseim/mongoose_im_controller_test.exs | |
parent | 3b71612d3d8b5e2ad53bda4399eb7f687cd6c30e (diff) | |
parent | 6499adc6a83b4064f7283de3c729053e62ade7b2 (diff) | |
download | pleroma-f333041a0a2b9c2f1ef2236254b8dd3e9a55a688.tar.gz pleroma-f333041a0a2b9c2f1ef2236254b8dd3e9a55a688.zip |
Merge remote-tracking branch 'pleroma/develop' into feature/addressable-lists
Diffstat (limited to 'test/web/mongooseim/mongoose_im_controller_test.exs')
-rw-r--r-- | test/web/mongooseim/mongoose_im_controller_test.exs | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/web/mongooseim/mongoose_im_controller_test.exs b/test/web/mongooseim/mongoose_im_controller_test.exs new file mode 100644 index 000000000..eb83999bb --- /dev/null +++ b/test/web/mongooseim/mongoose_im_controller_test.exs @@ -0,0 +1,59 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Web.MongooseIMController do + use Pleroma.Web.ConnCase + import Pleroma.Factory + + test "/user_exists", %{conn: conn} do + _user = insert(:user, nickname: "lain") + _remote_user = insert(:user, nickname: "alice", local: false) + + res = + conn + |> get(mongoose_im_path(conn, :user_exists), user: "lain") + |> json_response(200) + + assert res == true + + res = + conn + |> get(mongoose_im_path(conn, :user_exists), user: "alice") + |> json_response(404) + + assert res == false + + res = + conn + |> get(mongoose_im_path(conn, :user_exists), user: "bob") + |> json_response(404) + + assert res == false + end + + test "/check_password", %{conn: conn} do + user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt("cool")) + + res = + conn + |> get(mongoose_im_path(conn, :check_password), user: user.nickname, pass: "cool") + |> json_response(200) + + assert res == true + + res = + conn + |> get(mongoose_im_path(conn, :check_password), user: user.nickname, pass: "uncool") + |> json_response(403) + + assert res == false + + res = + conn + |> get(mongoose_im_path(conn, :check_password), user: "nobody", pass: "cool") + |> json_response(404) + + assert res == false + end +end |