oauth_test_controller.ex (772B)
1 # Pleroma: A lightweight social networking server 2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> 3 # SPDX-License-Identifier: AGPL-3.0-only 4 5 # A test controller reachable only in :test env. 6 # Serves to test OAuth scopes check skipping / enforcement. 7 defmodule Pleroma.Tests.OAuthTestController do 8 @moduledoc false 9 10 use Pleroma.Web, :controller 11 12 alias Pleroma.Plugs.OAuthScopesPlug 13 14 plug(:skip_plug, OAuthScopesPlug when action == :skipped_oauth) 15 16 plug(OAuthScopesPlug, %{scopes: ["read"]} when action != :missed_oauth) 17 18 def skipped_oauth(conn, _params) do 19 noop(conn) 20 end 21 22 def performed_oauth(conn, _params) do 23 noop(conn) 24 end 25 26 def missed_oauth(conn, _params) do 27 noop(conn) 28 end 29 30 defp noop(conn), do: json(conn, %{}) 31 end