OAuthScopesPlug: disallowed nil token (unless with :fallback option). WIP: controller tests modification: OAuth scopes usage.

This commit is contained in:
Ivan Tashkinov 2019-12-15 22:32:42 +03:00
commit 7973cbdb9f
14 changed files with 638 additions and 912 deletions

View file

@ -28,6 +28,26 @@ defmodule Pleroma.Web.ConnCase do
# The default endpoint for testing
@endpoint Pleroma.Web.Endpoint
# Sets up OAuth access with specified scopes
defp oauth_access(scopes, opts \\ %{}) do
user =
Map.get_lazy(opts, :user, fn ->
Pleroma.Factory.insert(:user)
end)
token =
Map.get_lazy(opts, :oauth_token, fn ->
Pleroma.Factory.insert(:oauth_token, user: user, scopes: scopes)
end)
conn =
build_conn()
|> assign(:user, user)
|> assign(:token, token)
%{user: user, token: token, conn: conn}
end
end
end