diff options
author | kaniini <ariadne@dereferenced.org> | 2019-09-23 22:42:34 +0000 |
---|---|---|
committer | kaniini <ariadne@dereferenced.org> | 2019-09-23 22:42:34 +0000 |
commit | 29dd8ab9c0ef28f9649fe0a5b29a0bbcfb4c0965 (patch) | |
tree | 09ebc5e8d932fbedb7e5485d9de1e7f78fd7786c /test/web/oauth/oauth_controller_test.exs | |
parent | 19263f30c3819f922586b537467e888574c334d7 (diff) | |
parent | cf1960d5961a3a01a6d92c44ab4a6d0ce9570a09 (diff) | |
download | pleroma-29dd8ab9c0ef28f9649fe0a5b29a0bbcfb4c0965.tar.gz |
Merge branch 'feature/force-password-reset' into 'develop'
Admin API: Add ability to require password reset
See merge request pleroma/pleroma!1705
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) |