Merge branch 'feature/add-oauth-tokens-endpoint' into 'develop'
Add OAuth tokens endpoint See merge request pleroma/pleroma!805
This commit is contained in:
commit
7456338ed3
6 changed files with 109 additions and 1 deletions
|
|
@ -13,6 +13,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
alias Pleroma.Object
|
||||
alias Pleroma.Notification
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
alias Pleroma.Web.OAuth.Token
|
||||
alias Pleroma.Web.TwitterAPI.UserView
|
||||
alias Pleroma.Web.TwitterAPI.NotificationView
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
|
@ -1915,4 +1916,38 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
ActivityRepresenter.to_map(activity, %{user: user, for: user})
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /api/oauth_tokens" do
|
||||
setup do
|
||||
token = insert(:oauth_token) |> Repo.preload(:user)
|
||||
|
||||
%{token: token}
|
||||
end
|
||||
|
||||
test "renders list", %{token: token} do
|
||||
response =
|
||||
build_conn()
|
||||
|> assign(:user, token.user)
|
||||
|> get("/api/oauth_tokens")
|
||||
|
||||
keys =
|
||||
json_response(response, 200)
|
||||
|> hd()
|
||||
|> Map.keys()
|
||||
|
||||
assert keys -- ["id", "app_name", "valid_until"] == []
|
||||
end
|
||||
|
||||
test "revoke token", %{token: token} do
|
||||
response =
|
||||
build_conn()
|
||||
|> assign(:user, token.user)
|
||||
|> delete("/api/oauth_tokens/#{token.id}")
|
||||
|
||||
tokens = Token.get_user_tokens(token.user)
|
||||
|
||||
assert tokens == []
|
||||
assert response.status == 201
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue