summaryrefslogtreecommitdiff
path: root/test/plugs/oauth_scopes_plug_test.exs
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-08-28 12:17:19 +0000
committerlain <lain@soykaf.club>2020-08-28 12:17:19 +0000
commit73dd5bdb7dcdf804bdbabcf632671d4de5042ebc (patch)
treeefcb0b8e68f86d067de98a23f40a24c7dab79d2f /test/plugs/oauth_scopes_plug_test.exs
parentf891e2b2f1d1daa122b9856e4b660be394d31e34 (diff)
parentb141e35d641e733dffe7bd6a45a5bbcafe586c56 (diff)
Merge branch 'release/2.1.0' into 'stable'v2.1.0
Release/2.1.0 See merge request pleroma/pleroma!2927
Diffstat (limited to 'test/plugs/oauth_scopes_plug_test.exs')
-rw-r--r--test/plugs/oauth_scopes_plug_test.exs38
1 files changed, 2 insertions, 36 deletions
diff --git a/test/plugs/oauth_scopes_plug_test.exs b/test/plugs/oauth_scopes_plug_test.exs
index d855d4f54..884de7b4d 100644
--- a/test/plugs/oauth_scopes_plug_test.exs
+++ b/test/plugs/oauth_scopes_plug_test.exs
@@ -5,17 +5,12 @@
defmodule Pleroma.Plugs.OAuthScopesPlugTest do
use Pleroma.Web.ConnCase, async: true
- alias Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug
alias Pleroma.Plugs.OAuthScopesPlug
alias Pleroma.Repo
import Mock
import Pleroma.Factory
- setup_with_mocks([{EnsurePublicOrAuthenticatedPlug, [], [call: fn conn, _ -> conn end]}]) do
- :ok
- end
-
test "is not performed if marked as skipped", %{conn: conn} do
with_mock OAuthScopesPlug, [:passthrough], perform: &passthrough([&1, &2]) do
conn =
@@ -60,7 +55,7 @@ defmodule Pleroma.Plugs.OAuthScopesPlugTest do
describe "with `fallback: :proceed_unauthenticated` option, " do
test "if `token.scopes` doesn't fulfill specified conditions, " <>
- "clears :user and :token assigns and calls EnsurePublicOrAuthenticatedPlug",
+ "clears :user and :token assigns",
%{conn: conn} do
user = insert(:user)
token1 = insert(:oauth_token, scopes: ["read", "write"], user: user)
@@ -79,35 +74,6 @@ defmodule Pleroma.Plugs.OAuthScopesPlugTest do
refute ret_conn.halted
refute ret_conn.assigns[:user]
refute ret_conn.assigns[:token]
-
- assert called(EnsurePublicOrAuthenticatedPlug.call(ret_conn, :_))
- end
- end
-
- test "with :skip_instance_privacy_check option, " <>
- "if `token.scopes` doesn't fulfill specified conditions, " <>
- "clears :user and :token assigns and does NOT call EnsurePublicOrAuthenticatedPlug",
- %{conn: conn} do
- user = insert(:user)
- token1 = insert(:oauth_token, scopes: ["read:statuses", "write"], user: user)
-
- for token <- [token1, nil], op <- [:|, :&] do
- ret_conn =
- conn
- |> assign(:user, user)
- |> assign(:token, token)
- |> OAuthScopesPlug.call(%{
- scopes: ["read"],
- op: op,
- fallback: :proceed_unauthenticated,
- skip_instance_privacy_check: true
- })
-
- refute ret_conn.halted
- refute ret_conn.assigns[:user]
- refute ret_conn.assigns[:token]
-
- refute called(EnsurePublicOrAuthenticatedPlug.call(ret_conn, :_))
end
end
end
@@ -205,7 +171,7 @@ defmodule Pleroma.Plugs.OAuthScopesPlugTest do
end
describe "transform_scopes/2" do
- clear_config([:auth, :enforce_oauth_admin_scope_usage])
+ setup do: clear_config([:auth, :enforce_oauth_admin_scope_usage])
setup do
{:ok, %{f: &OAuthScopesPlug.transform_scopes/2}}