diff options
author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2019-12-15 22:32:42 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2019-12-15 22:32:42 +0300 |
commit | 7973cbdb9fa9120306cb5a265a477eeccd315ee6 (patch) | |
tree | 4df03f3ccaffa065f7a07e171740aae49262b1db /test/support/conn_case.ex | |
parent | 8efacfed677ea2f06ac228294faec77a38060976 (diff) | |
download | pleroma-7973cbdb9fa9120306cb5a265a477eeccd315ee6.tar.gz pleroma-7973cbdb9fa9120306cb5a265a477eeccd315ee6.zip |
OAuthScopesPlug: disallowed nil token (unless with :fallback option). WIP: controller tests modification: OAuth scopes usage.
Diffstat (limited to 'test/support/conn_case.ex')
-rw-r--r-- | test/support/conn_case.ex | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex index 9897f72ce..95bc2492a 100644 --- a/test/support/conn_case.ex +++ b/test/support/conn_case.ex @@ -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 |