[#468] Added OAuth scopes-specific tests.
This commit is contained in:
parent
c0ecbf6669
commit
04ee877a20
6 changed files with 162 additions and 47 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue