diff options
author | rinpatch <rinpatch@sdf.org> | 2020-05-02 16:22:21 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-05-02 16:22:21 +0000 |
commit | 019a192e43c2421c74e5126e753aac095db8ad54 (patch) | |
tree | 3415b92ed0cb9e59f39946a1439fd918c6ea07ee /lib/pleroma/tests | |
parent | 3b15a0eecc62f79465620a697f12b576ed87b0fc (diff) | |
parent | 04f23294d327f044a72ecd3f269846c2f6198cf1 (diff) | |
download | pleroma-2.0.3.tar.gz |
Merge branch 'release/2.0.3' into 'stable'v2.0.3
Release/2.0.3
See merge request pleroma/secteam/pleroma!3
Diffstat (limited to 'lib/pleroma/tests')
-rw-r--r-- | lib/pleroma/tests/oauth_test_controller.ex | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/pleroma/tests/oauth_test_controller.ex b/lib/pleroma/tests/oauth_test_controller.ex new file mode 100644 index 000000000..58d517f78 --- /dev/null +++ b/lib/pleroma/tests/oauth_test_controller.ex @@ -0,0 +1,31 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +# A test controller reachable only in :test env. +# Serves to test OAuth scopes check skipping / enforcement. +defmodule Pleroma.Tests.OAuthTestController do + @moduledoc false + + use Pleroma.Web, :controller + + alias Pleroma.Plugs.OAuthScopesPlug + + plug(:skip_plug, OAuthScopesPlug when action == :skipped_oauth) + + plug(OAuthScopesPlug, %{scopes: ["read"]} when action != :missed_oauth) + + def skipped_oauth(conn, _params) do + noop(conn) + end + + def performed_oauth(conn, _params) do + noop(conn) + end + + def missed_oauth(conn, _params) do + noop(conn) + end + + defp noop(conn), do: json(conn, %{}) +end |