aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoreugenijm <eugenijm@protonmail.com>2019-04-06 00:22:42 +0300
committereugenijm <eugenijm@protonmail.com>2019-04-06 23:27:55 +0300
commit7aa53d52bd982b5ab233a65048f5fb1823127d4a (patch)
tree3c6e13c0f7f77acd5ba2f65f3bc0f5a34256560d /test
parente3ca9f708fdb004771708c06095ed7b7e4cfce4d (diff)
downloadpleroma-7aa53d52bd982b5ab233a65048f5fb1823127d4a.tar.gz
Return 403 on oauth token exchange for a deactivated user
Diffstat (limited to 'test')
-rw-r--r--test/web/oauth/oauth_controller_test.exs26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/web/oauth/oauth_controller_test.exs b/test/web/oauth/oauth_controller_test.exs
index a9a0b9ed4..a68528420 100644
--- a/test/web/oauth/oauth_controller_test.exs
+++ b/test/web/oauth/oauth_controller_test.exs
@@ -327,6 +327,32 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
refute Map.has_key?(resp, "access_token")
end
+ test "rejects token exchange for valid credentials belonging to deactivated user" do
+ password = "testpassword"
+
+ user =
+ insert(:user,
+ password_hash: Comeonin.Pbkdf2.hashpwsalt(password),
+ info: %{deactivated: true}
+ )
+
+ app = insert(:oauth_app)
+
+ 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 %{"error" => _} = resp
+ refute Map.has_key?(resp, "access_token")
+ end
+
test "rejects an invalid authorization code" do
app = insert(:oauth_app)