diff options
author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-04-17 16:23:58 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-04-17 16:23:58 +0300 |
commit | 6e6f95c6aed77cbde1a58edcdbb5cc4f68416bca (patch) | |
tree | 923a489a9a6144bd31ff54d24140c1fd1259ae05 /lib/pleroma/tests/oauth_test_controller.ex | |
parent | ac672a9d6bfdd3cba7692f80a883bd38b0b09a57 (diff) | |
parent | 09bd1d12c112fe45563c25a76afde65a3381aa26 (diff) | |
download | pleroma-6e6f95c6aed77cbde1a58edcdbb5cc4f68416bca.tar.gz |
Merge remote-tracking branch 'remotes/origin/develop' into 1559-follow-request-notifications
# Conflicts:
# CHANGELOG.md
Diffstat (limited to 'lib/pleroma/tests/oauth_test_controller.ex')
-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 |