diff options
author | Maxim Filippov <colixer@gmail.com> | 2019-09-24 13:00:48 +0300 |
---|---|---|
committer | Maxim Filippov <colixer@gmail.com> | 2019-09-24 13:00:48 +0300 |
commit | 5e9759cd7d0730c14bcc44e9b3dbda94947d602f (patch) | |
tree | 5917d89cad99d14a246e33f3e8ebd56e70abe20b /test/web/oauth/oauth_controller_test.exs | |
parent | 79c3443b609663ab23a4353ebdb7e5e2f0e6a150 (diff) | |
parent | 29dd8ab9c0ef28f9649fe0a5b29a0bbcfb4c0965 (diff) | |
download | pleroma-5e9759cd7d0730c14bcc44e9b3dbda94947d602f.tar.gz |
Merge branch 'develop' into feature/return-link-for-password-reset
Diffstat (limited to 'test/web/oauth/oauth_controller_test.exs')
-rw-r--r-- | test/web/oauth/oauth_controller_test.exs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/web/oauth/oauth_controller_test.exs b/test/web/oauth/oauth_controller_test.exs index 2780e1746..8b88fd784 100644 --- a/test/web/oauth/oauth_controller_test.exs +++ b/test/web/oauth/oauth_controller_test.exs @@ -831,6 +831,33 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do refute Map.has_key?(resp, "access_token") end + test "rejects token exchange for user with password_reset_pending set to true" do + password = "testpassword" + + user = + insert(:user, + password_hash: Comeonin.Pbkdf2.hashpwsalt(password), + info: %{password_reset_pending: true} + ) + + app = insert(:oauth_app, scopes: ["read", "write"]) + + conn = + build_conn() + |> post("/oauth/token", %{ + "grant_type" => "password", + "username" => user.nickname, + "password" => password, + "client_id" => app.client_id, + "client_secret" => app.client_secret + }) + + assert resp = json_response(conn, 403) + + assert resp["error"] == "Password reset is required" + refute Map.has_key?(resp, "access_token") + end + test "rejects an invalid authorization code" do app = insert(:oauth_app) |