summaryrefslogtreecommitdiff
path: root/test/web/oauth/oauth_controller_test.exs
diff options
context:
space:
mode:
authorRoman Chvanikov <chvanikoff@gmail.com>2019-05-29 18:18:22 +0300
committerRoman Chvanikov <chvanikoff@gmail.com>2019-05-29 18:18:22 +0300
commitce47017c8927b8b2d31668d5e32e387d80739502 (patch)
treebe77acd4dc0c6b9d7b6cb8515470e1dae3212aa7 /test/web/oauth/oauth_controller_test.exs
parentf1f7a11222f4689f000825147d16b366d915f393 (diff)
parent57e58d26029388a5831cd2ac3fbc419c27c4d7c6 (diff)
downloadpleroma-ce47017c8927b8b2d31668d5e32e387d80739502.tar.gz
pleroma-ce47017c8927b8b2d31668d5e32e387d80739502.zip
Merge develop
Diffstat (limited to 'test/web/oauth/oauth_controller_test.exs')
-rw-r--r--test/web/oauth/oauth_controller_test.exs23
1 files changed, 22 insertions, 1 deletions
diff --git a/test/web/oauth/oauth_controller_test.exs b/test/web/oauth/oauth_controller_test.exs
index cb6836983..1c04ac9ad 100644
--- a/test/web/oauth/oauth_controller_test.exs
+++ b/test/web/oauth/oauth_controller_test.exs
@@ -614,6 +614,27 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
assert token.scopes == ["scope1", "scope2"]
end
+ test "issue a token for client_credentials grant type" do
+ app = insert(:oauth_app, scopes: ["read", "write"])
+
+ conn =
+ build_conn()
+ |> post("/oauth/token", %{
+ "grant_type" => "client_credentials",
+ "client_id" => app.client_id,
+ "client_secret" => app.client_secret
+ })
+
+ assert %{"access_token" => token, "refresh_token" => refresh, "scope" => scope} =
+ json_response(conn, 200)
+
+ assert token
+ token_from_db = Repo.get_by(Token, token: token)
+ assert token_from_db
+ assert refresh
+ assert scope == "read write"
+ end
+
test "rejects token exchange with invalid client credentials" do
user = insert(:user)
app = insert(:oauth_app)
@@ -644,7 +665,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
password = "testpassword"
user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt(password))
- info_change = Pleroma.User.Info.confirmation_changeset(user.info, :unconfirmed)
+ info_change = Pleroma.User.Info.confirmation_changeset(user.info, need_confirmation: true)
{:ok, user} =
user