diff options
| author | Egor Kislitsyn <egor@kislitsyn.com> | 2020-03-12 16:02:24 +0400 |
|---|---|---|
| committer | Egor Kislitsyn <egor@kislitsyn.com> | 2020-03-12 16:02:24 +0400 |
| commit | d1c7f8e576e31487544b57d67802843b8ef38388 (patch) | |
| tree | 891a5578ef2ad9d48230432d32b9e85cf9d575fc /test/web/mastodon_api/controllers/auth_controller_test.exs | |
| parent | 0f386110c6e15148ff1ff5ea3451885485fcb7ff (diff) | |
| parent | 00d17520314e3591caaa7ab4ca39c6227a6bdf15 (diff) | |
| download | pleroma-d1c7f8e576e31487544b57d67802843b8ef38388.tar.gz pleroma-d1c7f8e576e31487544b57d67802843b8ef38388.zip | |
Merge remote-tracking branch 'origin/develop' into global-status-expiration
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) |
