diff options
author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-04-15 21:19:16 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-04-15 21:19:16 +0300 |
commit | bde1189c349dc114aca2e9310dda840a1007825f (patch) | |
tree | d806c6f02e1381d912cc92be06d92864a4f0f3a8 /test/plugs/oauth_scopes_plug_test.exs | |
parent | bedf92e064ec96f0b9bb95c2263616a2fe49017d (diff) | |
download | pleroma-bde1189c349dc114aca2e9310dda840a1007825f.tar.gz pleroma-bde1189c349dc114aca2e9310dda840a1007825f.zip |
[#2349] Made :skip_plug/2 prevent plug from being executed even if explicitly called. Refactoring. Tests.
Diffstat (limited to 'test/plugs/oauth_scopes_plug_test.exs')
-rw-r--r-- | test/plugs/oauth_scopes_plug_test.exs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/plugs/oauth_scopes_plug_test.exs b/test/plugs/oauth_scopes_plug_test.exs index e79ecf263..abab7abb0 100644 --- a/test/plugs/oauth_scopes_plug_test.exs +++ b/test/plugs/oauth_scopes_plug_test.exs @@ -7,6 +7,7 @@ defmodule Pleroma.Plugs.OAuthScopesPlugTest do alias Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug alias Pleroma.Plugs.OAuthScopesPlug + alias Pleroma.Plugs.PlugHelper alias Pleroma.Repo import Mock @@ -16,6 +17,18 @@ defmodule Pleroma.Plugs.OAuthScopesPlugTest do :ok end + test "is not performed if marked as skipped", %{conn: conn} do + with_mock OAuthScopesPlug, [:passthrough], perform: &passthrough([&1, &2]) do + conn = + conn + |> PlugHelper.append_to_skipped_plugs(OAuthScopesPlug) + |> OAuthScopesPlug.call(%{scopes: ["random_scope"]}) + + refute called(OAuthScopesPlug.perform(:_, :_)) + refute conn.halted + end + end + test "if `token.scopes` fulfills specified 'any of' conditions, " <> "proceeds with no op", %{conn: conn} do |