summaryrefslogtreecommitdiff
path: root/test/web/oauth/oauth_controller_test.exs
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-07-29 11:27:26 +0000
committerlain <lain@soykaf.club>2020-07-29 11:27:26 +0000
commit79f9ddd8b725519f719219b70b8dd8558d5212cf (patch)
tree24f6940744d9d832ea3ab2747e7d1c2fe890fb3a /test/web/oauth/oauth_controller_test.exs
parent93dbba9b8a5aacbbf43a45a07e27b328579eabf8 (diff)
parentf688c8df82b955b50552b3198ddc153a716451c2 (diff)
downloadpleroma-79f9ddd8b725519f719219b70b8dd8558d5212cf.tar.gz
pleroma-79f9ddd8b725519f719219b70b8dd8558d5212cf.zip
Merge branch 'by-approval' into 'develop'
Registrations "by approval" mode Closes #1931 See merge request pleroma/pleroma!2757
Diffstat (limited to 'test/web/oauth/oauth_controller_test.exs')
-rw-r--r--test/web/oauth/oauth_controller_test.exs29
1 files changed, 28 insertions, 1 deletions
diff --git a/test/web/oauth/oauth_controller_test.exs b/test/web/oauth/oauth_controller_test.exs
index d389e4ce0..1200126b8 100644
--- a/test/web/oauth/oauth_controller_test.exs
+++ b/test/web/oauth/oauth_controller_test.exs
@@ -19,7 +19,10 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
key: "_test",
signing_salt: "cooldude"
]
- setup do: clear_config([:instance, :account_activation_required])
+ setup do
+ clear_config([:instance, :account_activation_required])
+ clear_config([:instance, :account_approval_required])
+ end
describe "in OAuth consumer mode, " do
setup do
@@ -995,6 +998,30 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
}
end
+ test "rejects token exchange for valid credentials belonging to an unapproved user" do
+ password = "testpassword"
+
+ user = insert(:user, password_hash: Pbkdf2.hash_pwd_salt(password), approval_pending: true)
+
+ refute Pleroma.User.account_status(user) == :active
+
+ 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)