浏览代码

Web.OAuth.OAuthControllerTest: Add test against token formatting

tags/v1.1.4
Haelwenn (lanodan) Monnier 5 年前
父节点
当前提交
bb9e40968a
找不到此签名对应的密钥 GPG 密钥 ID: D5B7A8E43C997DEE
共有 1 个文件被更改,包括 7 次插入5 次删除
  1. +7
    -5
      test/web/oauth/oauth_controller_test.exs

+ 7
- 5
test/web/oauth/oauth_controller_test.exs 查看文件

@@ -165,10 +165,10 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do

test "issues a token for request with HTTP basic auth client credentials" do
user = insert(:user)
app = insert(:oauth_app, scopes: ["scope1", "scope2"])
app = insert(:oauth_app, scopes: ["scope1", "scope2", "scope3"])

{:ok, auth} = Authorization.create_authorization(app, user, ["scope2"])
assert auth.scopes == ["scope2"]
{:ok, auth} = Authorization.create_authorization(app, user, ["scope1", "scope2"])
assert auth.scopes == ["scope1", "scope2"]

app_encoded =
(URI.encode_www_form(app.client_id) <> ":" <> URI.encode_www_form(app.client_secret))
@@ -183,11 +183,13 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
"redirect_uri" => app.redirect_uris
})

assert %{"access_token" => token} = json_response(conn, 200)
assert %{"access_token" => token, "scope" => scope} = json_response(conn, 200)

assert scope == "scope1 scope2"

token = Repo.get_by(Token, token: token)
assert token
assert token.scopes == ["scope2"]
assert token.scopes == ["scope1", "scope2"]
end

test "rejects token exchange with invalid client credentials" do


正在加载...
取消
保存