[#468] Added OAuth scopes-specific tests.

This commit is contained in:
Ivan Tashkinov 2019-02-19 22:28:21 +03:00
commit 04ee877a20
6 changed files with 162 additions and 47 deletions

View file

@ -11,24 +11,26 @@ defmodule Pleroma.Web.OAuth.TokenTest do
import Pleroma.Factory
test "exchanges a auth token for an access token" do
test "exchanges a auth token for an access token, preserving `scopes`" do
{:ok, app} =
Repo.insert(
App.register_changeset(%App{}, %{
client_name: "client",
scopes: ["scope"],
scopes: ["read", "write"],
redirect_uris: "url"
})
)
user = insert(:user)
{:ok, auth} = Authorization.create_authorization(app, user)
{:ok, auth} = Authorization.create_authorization(app, user, ["read"])
assert auth.scopes == ["read"]
{:ok, token} = Token.exchange_token(app, auth)
assert token.app_id == app.id
assert token.user_id == user.id
assert token.scopes == auth.scopes
assert String.length(token.token) > 10
assert String.length(token.refresh_token) > 10