diff options
| author | lain <lain@soykaf.club> | 2020-03-04 12:43:06 +0000 | 
|---|---|---|
| committer | lain <lain@soykaf.club> | 2020-03-04 12:43:06 +0000 | 
| commit | 6f7a8c43a200d2d0166e4e544aee1e6104bcb671 (patch) | |
| tree | c3942b6a54f5768b5f3efa6f0e9aa1ea2f40d281 /test/web/mastodon_api/controllers/auth_controller_test.exs | |
| parent | 5992c256ad7c5bc8207240c9d51e03964e50eb64 (diff) | |
| parent | cb60a9c42f48f0b9df1681f9cba229b21eb6095c (diff) | |
| download | pleroma-6f7a8c43a200d2d0166e4e544aee1e6104bcb671.tar.gz pleroma-6f7a8c43a200d2d0166e4e544aee1e6104bcb671.zip | |
Merge branch 'fix/no-email-no-fail' into 'develop'
Do not fail when user has no email
See merge request pleroma/pleroma!2249
Diffstat (limited to 'test/web/mastodon_api/controllers/auth_controller_test.exs')
| -rw-r--r-- | test/web/mastodon_api/controllers/auth_controller_test.exs | 31 | 
1 files changed, 31 insertions, 0 deletions
| diff --git a/test/web/mastodon_api/controllers/auth_controller_test.exs b/test/web/mastodon_api/controllers/auth_controller_test.exs index 5a4d203f4..a485f8e41 100644 --- a/test/web/mastodon_api/controllers/auth_controller_test.exs +++ b/test/web/mastodon_api/controllers/auth_controller_test.exs @@ -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) | 
