diff options
author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-04-21 08:20:50 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-04-21 08:20:50 +0300 |
commit | bb5d0eafa437c9d32cdd8ccdb92b2eabb8ccccf1 (patch) | |
tree | 307120b8958a5be8dad4a16e6e2ff779336a30e3 /lib/pleroma/tests/oauth_test_controller.ex | |
parent | f7e623c11c4b6f4f323a4317e9489092be73f9cd (diff) | |
parent | e57c1b60e4a0f882d5217bf1be8b1a7240aa322d (diff) | |
download | pleroma-bb5d0eafa437c9d32cdd8ccdb92b2eabb8ccccf1.tar.gz |
Merge remote-tracking branch 'remotes/origin/develop' into 1364-no-pushes-from-blocked-domains-users
# 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 |