diff options
author | Maksim Pechnikov <parallel588@gmail.com> | 2020-03-08 14:10:45 +0300 |
---|---|---|
committer | Maksim Pechnikov <parallel588@gmail.com> | 2020-03-08 14:10:59 +0300 |
commit | edb659dc579fe56227adef0b0704ff13b6ef717e (patch) | |
tree | e9d48cd8afd99877d5b4c696d8b7a62a9d2121bd /test/web/mastodon_api/controllers/auth_controller_test.exs | |
parent | 10f452ad1feae9a882b6dc4cd35e09adb7e78208 (diff) | |
parent | 6d797b99282ff1067c6af04b3e1775ff2281333b (diff) | |
download | pleroma-edb659dc579fe56227adef0b0704ff13b6ef717e.tar.gz pleroma-edb659dc579fe56227adef0b0704ff13b6ef717e.zip |
Merge branch 'develop' into issue/1276
Diffstat (limited to 'test/web/mastodon_api/controllers/auth_controller_test.exs')
-rw-r--r-- | test/web/mastodon_api/controllers/auth_controller_test.exs | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/test/web/mastodon_api/controllers/auth_controller_test.exs b/test/web/mastodon_api/controllers/auth_controller_test.exs index 98b2a82e7..a485f8e41 100644 --- a/test/web/mastodon_api/controllers/auth_controller_test.exs +++ b/test/web/mastodon_api/controllers/auth_controller_test.exs @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.MastodonAPI.AuthControllerTest do @@ -85,6 +85,37 @@ defmodule Pleroma.Web.MastodonAPI.AuthControllerTest do end end + describe "POST /auth/password, with nickname" do + test "it returns 204", %{conn: conn} do + user = insert(:user) + + assert conn + |> post("/auth/password?nickname=#{user.nickname}") + |> json_response(:no_content) + + ObanHelpers.perform_all() + token_record = Repo.get_by(Pleroma.PasswordResetToken, user_id: user.id) + + email = Pleroma.Emails.UserEmail.password_reset_email(user, token_record.token) + notify_email = Config.get([:instance, :notify_email]) + instance_name = Config.get([:instance, :name]) + + assert_email_sent( + from: {instance_name, notify_email}, + to: {user.name, user.email}, + html_body: email.html_body + ) + end + + test "it doesn't fail when a user has no email", %{conn: conn} do + user = insert(:user, %{email: nil}) + + assert conn + |> post("/auth/password?nickname=#{user.nickname}") + |> json_response(:no_content) + end + end + describe "POST /auth/password, with invalid parameters" do setup do user = insert(:user) |