1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.OAuth.OAuthControllerTest do
6 use Pleroma.Web.ConnCase
10 alias Pleroma.Registration
12 alias Pleroma.Web.OAuth.Authorization
13 alias Pleroma.Web.OAuth.OAuthController
14 alias Pleroma.Web.OAuth.Token
16 @oauth_config_path [:oauth2, :issue_new_refresh_token]
20 signing_salt: "cooldude"
23 describe "in OAuth consumer mode, " do
25 oauth_consumer_strategies_path = [:auth, :oauth_consumer_strategies]
26 oauth_consumer_strategies = Pleroma.Config.get(oauth_consumer_strategies_path)
27 Pleroma.Config.put(oauth_consumer_strategies_path, ~w(twitter facebook))
30 Pleroma.Config.put(oauth_consumer_strategies_path, oauth_consumer_strategies)
34 app: insert(:oauth_app),
37 |> Plug.Session.call(Plug.Session.init(@session_opts))
42 test "GET /oauth/authorize renders auth forms, including OAuth consumer form", %{
51 "response_type" => "code",
52 "client_id" => app.client_id,
53 "redirect_uri" => OAuthController.default_redirect_uri(app),
58 assert response = html_response(conn, 200)
59 assert response =~ "Sign in with Twitter"
60 assert response =~ o_auth_path(conn, :prepare_request)
63 test "GET /oauth/prepare_request encodes parameters as `state` and redirects", %{
70 "/oauth/prepare_request",
72 "provider" => "twitter",
74 "scope" => "read follow",
75 "client_id" => app.client_id,
76 "redirect_uri" => OAuthController.default_redirect_uri(app),
82 assert response = html_response(conn, 302)
84 redirect_query = URI.parse(redirected_to(conn)).query
85 assert %{"state" => state_param} = URI.decode_query(redirect_query)
86 assert {:ok, state_components} = Poison.decode(state_param)
88 expected_client_id = app.client_id
89 expected_redirect_uri = app.redirect_uris
92 "scope" => "read follow",
93 "client_id" => ^expected_client_id,
94 "redirect_uri" => ^expected_redirect_uri,
99 test "with user-bound registration, GET /oauth/<provider>/callback redirects to `redirect_uri` with `code`",
100 %{app: app, conn: conn} do
101 registration = insert(:registration)
102 redirect_uri = OAuthController.default_redirect_uri(app)
105 "scope" => Enum.join(app.scopes, " "),
106 "client_id" => app.client_id,
107 "redirect_uri" => redirect_uri,
111 with_mock Pleroma.Web.Auth.Authenticator,
112 get_registration: fn _ -> {:ok, registration} end do
116 "/oauth/twitter/callback",
118 "oauth_token" => "G-5a3AAAAAAAwMH9AAABaektfSM",
119 "oauth_verifier" => "QZl8vUqNvXMTKpdmUnGejJxuHG75WWWs",
120 "provider" => "twitter",
121 "state" => Poison.encode!(state_params)
125 assert response = html_response(conn, 302)
126 assert redirected_to(conn) =~ ~r/#{redirect_uri}\?code=.+/
130 test "with user-unbound registration, GET /oauth/<provider>/callback renders registration_details page",
131 %{app: app, conn: conn} do
132 registration = insert(:registration, user: nil)
135 "scope" => "read write",
136 "client_id" => app.client_id,
137 "redirect_uri" => OAuthController.default_redirect_uri(app),
141 with_mock Pleroma.Web.Auth.Authenticator,
142 get_registration: fn _ -> {:ok, registration} end do
146 "/oauth/twitter/callback",
148 "oauth_token" => "G-5a3AAAAAAAwMH9AAABaektfSM",
149 "oauth_verifier" => "QZl8vUqNvXMTKpdmUnGejJxuHG75WWWs",
150 "provider" => "twitter",
151 "state" => Poison.encode!(state_params)
155 assert response = html_response(conn, 200)
156 assert response =~ ~r/name="op" type="submit" value="register"/
157 assert response =~ ~r/name="op" type="submit" value="connect"/
158 assert response =~ Registration.email(registration)
159 assert response =~ Registration.nickname(registration)
163 test "on authentication error, GET /oauth/<provider>/callback redirects to `redirect_uri`", %{
168 "scope" => Enum.join(app.scopes, " "),
169 "client_id" => app.client_id,
170 "redirect_uri" => OAuthController.default_redirect_uri(app),
176 |> assign(:ueberauth_failure, %{errors: [%{message: "(error description)"}]})
178 "/oauth/twitter/callback",
180 "oauth_token" => "G-5a3AAAAAAAwMH9AAABaektfSM",
181 "oauth_verifier" => "QZl8vUqNvXMTKpdmUnGejJxuHG75WWWs",
182 "provider" => "twitter",
183 "state" => Poison.encode!(state_params)
187 assert response = html_response(conn, 302)
188 assert redirected_to(conn) == app.redirect_uris
189 assert get_flash(conn, :error) == "Failed to authenticate: (error description)."
192 test "GET /oauth/registration_details renders registration details form", %{
199 "/oauth/registration_details",
201 "authorization" => %{
202 "scopes" => app.scopes,
203 "client_id" => app.client_id,
204 "redirect_uri" => OAuthController.default_redirect_uri(app),
205 "state" => "a_state",
207 "email" => "john@doe.com"
212 assert response = html_response(conn, 200)
213 assert response =~ ~r/name="op" type="submit" value="register"/
214 assert response =~ ~r/name="op" type="submit" value="connect"/
217 test "with valid params, POST /oauth/register?op=register redirects to `redirect_uri` with `code`",
222 registration = insert(:registration, user: nil, info: %{"nickname" => nil, "email" => nil})
223 redirect_uri = OAuthController.default_redirect_uri(app)
227 |> put_session(:registration_id, registration.id)
232 "authorization" => %{
233 "scopes" => app.scopes,
234 "client_id" => app.client_id,
235 "redirect_uri" => redirect_uri,
236 "state" => "a_state",
237 "nickname" => "availablenick",
238 "email" => "available@email.com"
243 assert response = html_response(conn, 302)
244 assert redirected_to(conn) =~ ~r/#{redirect_uri}\?code=.+/
247 test "with unlisted `redirect_uri`, POST /oauth/register?op=register results in HTTP 401",
252 registration = insert(:registration, user: nil, info: %{"nickname" => nil, "email" => nil})
253 unlisted_redirect_uri = "http://cross-site-request.com"
257 |> put_session(:registration_id, registration.id)
262 "authorization" => %{
263 "scopes" => app.scopes,
264 "client_id" => app.client_id,
265 "redirect_uri" => unlisted_redirect_uri,
266 "state" => "a_state",
267 "nickname" => "availablenick",
268 "email" => "available@email.com"
273 assert response = html_response(conn, 401)
276 test "with invalid params, POST /oauth/register?op=register renders registration_details page",
281 another_user = insert(:user)
282 registration = insert(:registration, user: nil, info: %{"nickname" => nil, "email" => nil})
286 "authorization" => %{
287 "scopes" => app.scopes,
288 "client_id" => app.client_id,
289 "redirect_uri" => OAuthController.default_redirect_uri(app),
290 "state" => "a_state",
291 "nickname" => "availablenickname",
292 "email" => "available@email.com"
296 for {bad_param, bad_param_value} <-
297 [{"nickname", another_user.nickname}, {"email", another_user.email}] do
298 bad_registration_attrs = %{
299 "authorization" => Map.put(params["authorization"], bad_param, bad_param_value)
302 bad_params = Map.merge(params, bad_registration_attrs)
306 |> put_session(:registration_id, registration.id)
307 |> post("/oauth/register", bad_params)
309 assert html_response(conn, 403) =~ ~r/name="op" type="submit" value="register"/
310 assert get_flash(conn, :error) == "Error: #{bad_param} has already been taken."
314 test "with valid params, POST /oauth/register?op=connect redirects to `redirect_uri` with `code`",
319 user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt("testpassword"))
320 registration = insert(:registration, user: nil)
321 redirect_uri = OAuthController.default_redirect_uri(app)
325 |> put_session(:registration_id, registration.id)
330 "authorization" => %{
331 "scopes" => app.scopes,
332 "client_id" => app.client_id,
333 "redirect_uri" => redirect_uri,
334 "state" => "a_state",
335 "name" => user.nickname,
336 "password" => "testpassword"
341 assert response = html_response(conn, 302)
342 assert redirected_to(conn) =~ ~r/#{redirect_uri}\?code=.+/
345 test "with unlisted `redirect_uri`, POST /oauth/register?op=connect results in HTTP 401`",
350 user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt("testpassword"))
351 registration = insert(:registration, user: nil)
352 unlisted_redirect_uri = "http://cross-site-request.com"
356 |> put_session(:registration_id, registration.id)
361 "authorization" => %{
362 "scopes" => app.scopes,
363 "client_id" => app.client_id,
364 "redirect_uri" => unlisted_redirect_uri,
365 "state" => "a_state",
366 "name" => user.nickname,
367 "password" => "testpassword"
372 assert response = html_response(conn, 401)
375 test "with invalid params, POST /oauth/register?op=connect renders registration_details page",
381 registration = insert(:registration, user: nil)
385 "authorization" => %{
386 "scopes" => app.scopes,
387 "client_id" => app.client_id,
388 "redirect_uri" => OAuthController.default_redirect_uri(app),
389 "state" => "a_state",
390 "name" => user.nickname,
391 "password" => "wrong password"
397 |> put_session(:registration_id, registration.id)
398 |> post("/oauth/register", params)
400 assert html_response(conn, 401) =~ ~r/name="op" type="submit" value="connect"/
401 assert get_flash(conn, :error) == "Invalid Username/Password"
405 describe "GET /oauth/authorize" do
408 app: insert(:oauth_app, redirect_uris: "https://redirect.url"),
411 |> Plug.Session.call(Plug.Session.init(@session_opts))
416 test "renders authentication page", %{app: app, conn: conn} do
422 "response_type" => "code",
423 "client_id" => app.client_id,
424 "redirect_uri" => OAuthController.default_redirect_uri(app),
429 assert html_response(conn, 200) =~ ~s(type="submit")
432 test "properly handles internal calls with `authorization`-wrapped params", %{
441 "authorization" => %{
442 "response_type" => "code",
443 "client_id" => app.client_id,
444 "redirect_uri" => OAuthController.default_redirect_uri(app),
450 assert html_response(conn, 200) =~ ~s(type="submit")
453 test "renders authentication page if user is already authenticated but `force_login` is tru-ish",
454 %{app: app, conn: conn} do
455 token = insert(:oauth_token, app_id: app.id)
459 |> put_session(:oauth_token, token.token)
463 "response_type" => "code",
464 "client_id" => app.client_id,
465 "redirect_uri" => OAuthController.default_redirect_uri(app),
467 "force_login" => "true"
471 assert html_response(conn, 200) =~ ~s(type="submit")
474 test "with existing authentication and non-OOB `redirect_uri`, redirects to app with `token` and `state` params",
479 token = insert(:oauth_token, app_id: app.id)
483 |> put_session(:oauth_token, token.token)
487 "response_type" => "code",
488 "client_id" => app.client_id,
489 "redirect_uri" => OAuthController.default_redirect_uri(app),
490 "state" => "specific_client_state",
495 assert URI.decode(redirected_to(conn)) ==
496 "https://redirect.url?access_token=#{token.token}&state=specific_client_state"
499 test "with existing authentication and unlisted non-OOB `redirect_uri`, redirects without credentials",
504 unlisted_redirect_uri = "http://cross-site-request.com"
505 token = insert(:oauth_token, app_id: app.id)
509 |> put_session(:oauth_token, token.token)
513 "response_type" => "code",
514 "client_id" => app.client_id,
515 "redirect_uri" => unlisted_redirect_uri,
516 "state" => "specific_client_state",
521 assert redirected_to(conn) == unlisted_redirect_uri
524 test "with existing authentication and OOB `redirect_uri`, redirects to app with `token` and `state` params",
529 token = insert(:oauth_token, app_id: app.id)
533 |> put_session(:oauth_token, token.token)
537 "response_type" => "code",
538 "client_id" => app.client_id,
539 "redirect_uri" => "urn:ietf:wg:oauth:2.0:oob",
544 assert html_response(conn, 200) =~ "Authorization exists"
548 describe "POST /oauth/authorize" do
549 test "redirects with oauth authorization" do
551 app = insert(:oauth_app, scopes: ["read", "write", "follow"])
552 redirect_uri = OAuthController.default_redirect_uri(app)
556 |> post("/oauth/authorize", %{
557 "authorization" => %{
558 "name" => user.nickname,
559 "password" => "test",
560 "client_id" => app.client_id,
561 "redirect_uri" => redirect_uri,
562 "scope" => "read write",
563 "state" => "statepassed"
567 target = redirected_to(conn)
568 assert target =~ redirect_uri
570 query = URI.parse(target).query |> URI.query_decoder() |> Map.new()
572 assert %{"state" => "statepassed", "code" => code} = query
573 auth = Repo.get_by(Authorization, token: code)
575 assert auth.scopes == ["read", "write"]
578 test "returns 401 for wrong credentials", %{conn: conn} do
580 app = insert(:oauth_app)
581 redirect_uri = OAuthController.default_redirect_uri(app)
585 |> post("/oauth/authorize", %{
586 "authorization" => %{
587 "name" => user.nickname,
588 "password" => "wrong",
589 "client_id" => app.client_id,
590 "redirect_uri" => redirect_uri,
591 "state" => "statepassed",
592 "scope" => Enum.join(app.scopes, " ")
595 |> html_response(:unauthorized)
598 assert result =~ app.client_id
599 assert result =~ redirect_uri
602 assert result =~ "Invalid Username/Password"
605 test "returns 401 for missing scopes", %{conn: conn} do
607 app = insert(:oauth_app)
608 redirect_uri = OAuthController.default_redirect_uri(app)
612 |> post("/oauth/authorize", %{
613 "authorization" => %{
614 "name" => user.nickname,
615 "password" => "test",
616 "client_id" => app.client_id,
617 "redirect_uri" => redirect_uri,
618 "state" => "statepassed",
622 |> html_response(:unauthorized)
625 assert result =~ app.client_id
626 assert result =~ redirect_uri
629 assert result =~ "This action is outside the authorized scopes"
632 test "returns 401 for scopes beyond app scopes", %{conn: conn} do
634 app = insert(:oauth_app, scopes: ["read", "write"])
635 redirect_uri = OAuthController.default_redirect_uri(app)
639 |> post("/oauth/authorize", %{
640 "authorization" => %{
641 "name" => user.nickname,
642 "password" => "test",
643 "client_id" => app.client_id,
644 "redirect_uri" => redirect_uri,
645 "state" => "statepassed",
646 "scope" => "read write follow"
649 |> html_response(:unauthorized)
652 assert result =~ app.client_id
653 assert result =~ redirect_uri
656 assert result =~ "This action is outside the authorized scopes"
660 describe "POST /oauth/token" do
661 test "issues a token for an all-body request" do
663 app = insert(:oauth_app, scopes: ["read", "write"])
665 {:ok, auth} = Authorization.create_authorization(app, user, ["write"])
669 |> post("/oauth/token", %{
670 "grant_type" => "authorization_code",
671 "code" => auth.token,
672 "redirect_uri" => OAuthController.default_redirect_uri(app),
673 "client_id" => app.client_id,
674 "client_secret" => app.client_secret
677 assert %{"access_token" => token, "me" => ap_id} = json_response(conn, 200)
679 token = Repo.get_by(Token, token: token)
681 assert token.scopes == auth.scopes
682 assert user.ap_id == ap_id
685 test "issues a token for `password` grant_type with valid credentials, with full permissions by default" do
686 password = "testpassword"
687 user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt(password))
689 app = insert(:oauth_app, scopes: ["read", "write"])
691 # Note: "scope" param is intentionally omitted
694 |> post("/oauth/token", %{
695 "grant_type" => "password",
696 "username" => user.nickname,
697 "password" => password,
698 "client_id" => app.client_id,
699 "client_secret" => app.client_secret
702 assert %{"access_token" => token} = json_response(conn, 200)
704 token = Repo.get_by(Token, token: token)
706 assert token.scopes == app.scopes
709 test "issues a token for request with HTTP basic auth client credentials" do
711 app = insert(:oauth_app, scopes: ["scope1", "scope2", "scope3"])
713 {:ok, auth} = Authorization.create_authorization(app, user, ["scope1", "scope2"])
714 assert auth.scopes == ["scope1", "scope2"]
717 (URI.encode_www_form(app.client_id) <> ":" <> URI.encode_www_form(app.client_secret))
722 |> put_req_header("authorization", "Basic " <> app_encoded)
723 |> post("/oauth/token", %{
724 "grant_type" => "authorization_code",
725 "code" => auth.token,
726 "redirect_uri" => OAuthController.default_redirect_uri(app)
729 assert %{"access_token" => token, "scope" => scope} = json_response(conn, 200)
731 assert scope == "scope1 scope2"
733 token = Repo.get_by(Token, token: token)
735 assert token.scopes == ["scope1", "scope2"]
738 test "issue a token for client_credentials grant type" do
739 app = insert(:oauth_app, scopes: ["read", "write"])
743 |> post("/oauth/token", %{
744 "grant_type" => "client_credentials",
745 "client_id" => app.client_id,
746 "client_secret" => app.client_secret
749 assert %{"access_token" => token, "refresh_token" => refresh, "scope" => scope} =
750 json_response(conn, 200)
753 token_from_db = Repo.get_by(Token, token: token)
756 assert scope == "read write"
759 test "rejects token exchange with invalid client credentials" do
761 app = insert(:oauth_app)
763 {:ok, auth} = Authorization.create_authorization(app, user)
767 |> put_req_header("authorization", "Basic JTIxOiVGMCU5RiVBNCVCNwo=")
768 |> post("/oauth/token", %{
769 "grant_type" => "authorization_code",
770 "code" => auth.token,
771 "redirect_uri" => OAuthController.default_redirect_uri(app)
774 assert resp = json_response(conn, 400)
775 assert %{"error" => _} = resp
776 refute Map.has_key?(resp, "access_token")
779 test "rejects token exchange for valid credentials belonging to unconfirmed user and confirmation is required" do
780 setting = Pleroma.Config.get([:instance, :account_activation_required])
783 Pleroma.Config.put([:instance, :account_activation_required], true)
784 on_exit(fn -> Pleroma.Config.put([:instance, :account_activation_required], setting) end)
787 password = "testpassword"
788 user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt(password))
789 info_change = Pleroma.User.Info.confirmation_changeset(user.info, need_confirmation: true)
793 |> Ecto.Changeset.change()
794 |> Ecto.Changeset.put_embed(:info, info_change)
797 refute Pleroma.User.auth_active?(user)
799 app = insert(:oauth_app)
803 |> post("/oauth/token", %{
804 "grant_type" => "password",
805 "username" => user.nickname,
806 "password" => password,
807 "client_id" => app.client_id,
808 "client_secret" => app.client_secret
811 assert resp = json_response(conn, 403)
812 assert %{"error" => _} = resp
813 refute Map.has_key?(resp, "access_token")
816 test "rejects token exchange for valid credentials belonging to deactivated user" do
817 password = "testpassword"
821 password_hash: Comeonin.Pbkdf2.hashpwsalt(password),
822 info: %{deactivated: true}
825 app = insert(:oauth_app)
829 |> post("/oauth/token", %{
830 "grant_type" => "password",
831 "username" => user.nickname,
832 "password" => password,
833 "client_id" => app.client_id,
834 "client_secret" => app.client_secret
837 assert resp = json_response(conn, 403)
838 assert %{"error" => _} = resp
839 refute Map.has_key?(resp, "access_token")
842 test "rejects an invalid authorization code" do
843 app = insert(:oauth_app)
847 |> post("/oauth/token", %{
848 "grant_type" => "authorization_code",
849 "code" => "Imobviouslyinvalid",
850 "redirect_uri" => OAuthController.default_redirect_uri(app),
851 "client_id" => app.client_id,
852 "client_secret" => app.client_secret
855 assert resp = json_response(conn, 400)
856 assert %{"error" => _} = json_response(conn, 400)
857 refute Map.has_key?(resp, "access_token")
861 describe "POST /oauth/token - refresh token" do
863 oauth_token_config = Pleroma.Config.get(@oauth_config_path)
866 Pleroma.Config.get(@oauth_config_path, oauth_token_config)
870 test "issues a new access token with keep fresh token" do
871 Pleroma.Config.put(@oauth_config_path, true)
873 app = insert(:oauth_app, scopes: ["read", "write"])
875 {:ok, auth} = Authorization.create_authorization(app, user, ["write"])
876 {:ok, token} = Token.exchange_token(app, auth)
880 |> post("/oauth/token", %{
881 "grant_type" => "refresh_token",
882 "refresh_token" => token.refresh_token,
883 "client_id" => app.client_id,
884 "client_secret" => app.client_secret
886 |> json_response(200)
893 "token_type" => "Bearer",
896 "refresh_token" => _,
902 refute Repo.get_by(Token, token: token.token)
903 new_token = Repo.get_by(Token, token: response["access_token"])
904 assert new_token.refresh_token == token.refresh_token
905 assert new_token.scopes == auth.scopes
906 assert new_token.user_id == user.id
907 assert new_token.app_id == app.id
910 test "issues a new access token with new fresh token" do
911 Pleroma.Config.put(@oauth_config_path, false)
913 app = insert(:oauth_app, scopes: ["read", "write"])
915 {:ok, auth} = Authorization.create_authorization(app, user, ["write"])
916 {:ok, token} = Token.exchange_token(app, auth)
920 |> post("/oauth/token", %{
921 "grant_type" => "refresh_token",
922 "refresh_token" => token.refresh_token,
923 "client_id" => app.client_id,
924 "client_secret" => app.client_secret
926 |> json_response(200)
933 "token_type" => "Bearer",
936 "refresh_token" => _,
942 refute Repo.get_by(Token, token: token.token)
943 new_token = Repo.get_by(Token, token: response["access_token"])
944 refute new_token.refresh_token == token.refresh_token
945 assert new_token.scopes == auth.scopes
946 assert new_token.user_id == user.id
947 assert new_token.app_id == app.id
950 test "returns 400 if we try use access token" do
952 app = insert(:oauth_app, scopes: ["read", "write"])
954 {:ok, auth} = Authorization.create_authorization(app, user, ["write"])
955 {:ok, token} = Token.exchange_token(app, auth)
959 |> post("/oauth/token", %{
960 "grant_type" => "refresh_token",
961 "refresh_token" => token.token,
962 "client_id" => app.client_id,
963 "client_secret" => app.client_secret
965 |> json_response(400)
967 assert %{"error" => "Invalid credentials"} == response
970 test "returns 400 if refresh_token invalid" do
971 app = insert(:oauth_app, scopes: ["read", "write"])
975 |> post("/oauth/token", %{
976 "grant_type" => "refresh_token",
977 "refresh_token" => "token.refresh_token",
978 "client_id" => app.client_id,
979 "client_secret" => app.client_secret
981 |> json_response(400)
983 assert %{"error" => "Invalid credentials"} == response
986 test "issues a new token if token expired" do
988 app = insert(:oauth_app, scopes: ["read", "write"])
990 {:ok, auth} = Authorization.create_authorization(app, user, ["write"])
991 {:ok, token} = Token.exchange_token(app, auth)
994 Ecto.Changeset.change(
996 %{valid_until: NaiveDateTime.add(NaiveDateTime.utc_now(), -86_400 * 30)}
999 {:ok, access_token} = Repo.update(change)
1003 |> post("/oauth/token", %{
1004 "grant_type" => "refresh_token",
1005 "refresh_token" => access_token.refresh_token,
1006 "client_id" => app.client_id,
1007 "client_secret" => app.client_secret
1009 |> json_response(200)
1016 "token_type" => "Bearer",
1017 "expires_in" => 600,
1018 "access_token" => _,
1019 "refresh_token" => _,
1025 refute Repo.get_by(Token, token: token.token)
1026 token = Repo.get_by(Token, token: response["access_token"])
1028 assert token.scopes == auth.scopes
1029 assert token.user_id == user.id
1030 assert token.app_id == app.id
1034 describe "POST /oauth/token - bad request" do
1035 test "returns 500" do
1038 |> post("/oauth/token", %{})
1039 |> json_response(500)
1041 assert %{"error" => "Bad request"} == response
1045 describe "POST /oauth/revoke - bad request" do
1046 test "returns 500" do
1049 |> post("/oauth/revoke", %{})
1050 |> json_response(500)
1052 assert %{"error" => "Bad request"} == response