1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 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
11 alias Pleroma.Web.OAuth.Authorization
12 alias Pleroma.Web.OAuth.OAuthController
13 alias Pleroma.Web.OAuth.Token
18 signing_salt: "cooldude"
20 clear_config_all([:instance, :account_activation_required])
22 describe "in OAuth consumer mode, " do
25 app: insert(:oauth_app),
28 |> Plug.Session.call(Plug.Session.init(@session_opts))
33 clear_config([:auth, :oauth_consumer_strategies]) do
35 [:auth, :oauth_consumer_strategies],
40 test "GET /oauth/authorize renders auth forms, including OAuth consumer form", %{
49 "response_type" => "code",
50 "client_id" => app.client_id,
51 "redirect_uri" => OAuthController.default_redirect_uri(app),
56 assert response = html_response(conn, 200)
57 assert response =~ "Sign in with Twitter"
58 assert response =~ o_auth_path(conn, :prepare_request)
61 test "GET /oauth/prepare_request encodes parameters as `state` and redirects", %{
68 "/oauth/prepare_request",
70 "provider" => "twitter",
72 "scope" => "read follow",
73 "client_id" => app.client_id,
74 "redirect_uri" => OAuthController.default_redirect_uri(app),
80 assert response = html_response(conn, 302)
82 redirect_query = URI.parse(redirected_to(conn)).query
83 assert %{"state" => state_param} = URI.decode_query(redirect_query)
84 assert {:ok, state_components} = Poison.decode(state_param)
86 expected_client_id = app.client_id
87 expected_redirect_uri = app.redirect_uris
90 "scope" => "read follow",
91 "client_id" => ^expected_client_id,
92 "redirect_uri" => ^expected_redirect_uri,
97 test "with user-bound registration, GET /oauth/<provider>/callback redirects to `redirect_uri` with `code`",
98 %{app: app, conn: conn} do
99 registration = insert(:registration)
100 redirect_uri = OAuthController.default_redirect_uri(app)
103 "scope" => Enum.join(app.scopes, " "),
104 "client_id" => app.client_id,
105 "redirect_uri" => redirect_uri,
111 |> assign(:ueberauth_auth, %{provider: registration.provider, uid: registration.uid})
113 "/oauth/twitter/callback",
115 "oauth_token" => "G-5a3AAAAAAAwMH9AAABaektfSM",
116 "oauth_verifier" => "QZl8vUqNvXMTKpdmUnGejJxuHG75WWWs",
117 "provider" => "twitter",
118 "state" => Poison.encode!(state_params)
122 assert response = html_response(conn, 302)
123 assert redirected_to(conn) =~ ~r/#{redirect_uri}\?code=.+/
126 test "with user-unbound registration, GET /oauth/<provider>/callback renders registration_details page",
127 %{app: app, conn: conn} do
131 "scope" => "read write",
132 "client_id" => app.client_id,
133 "redirect_uri" => OAuthController.default_redirect_uri(app),
139 |> assign(:ueberauth_auth, %{
142 info: %{nickname: user.nickname, email: user.email, name: user.name, description: nil}
145 "/oauth/twitter/callback",
147 "oauth_token" => "G-5a3AAAAAAAwMH9AAABaektfSM",
148 "oauth_verifier" => "QZl8vUqNvXMTKpdmUnGejJxuHG75WWWs",
149 "provider" => "twitter",
150 "state" => Poison.encode!(state_params)
154 assert response = html_response(conn, 200)
155 assert response =~ ~r/name="op" type="submit" value="register"/
156 assert response =~ ~r/name="op" type="submit" value="connect"/
157 assert response =~ user.email
158 assert response =~ user.nickname
161 test "on authentication error, GET /oauth/<provider>/callback redirects to `redirect_uri`", %{
166 "scope" => Enum.join(app.scopes, " "),
167 "client_id" => app.client_id,
168 "redirect_uri" => OAuthController.default_redirect_uri(app),
174 |> assign(:ueberauth_failure, %{errors: [%{message: "(error description)"}]})
176 "/oauth/twitter/callback",
178 "oauth_token" => "G-5a3AAAAAAAwMH9AAABaektfSM",
179 "oauth_verifier" => "QZl8vUqNvXMTKpdmUnGejJxuHG75WWWs",
180 "provider" => "twitter",
181 "state" => Poison.encode!(state_params)
185 assert response = html_response(conn, 302)
186 assert redirected_to(conn) == app.redirect_uris
187 assert get_flash(conn, :error) == "Failed to authenticate: (error description)."
190 test "GET /oauth/registration_details renders registration details form", %{
197 "/oauth/registration_details",
199 "authorization" => %{
200 "scopes" => app.scopes,
201 "client_id" => app.client_id,
202 "redirect_uri" => OAuthController.default_redirect_uri(app),
203 "state" => "a_state",
205 "email" => "john@doe.com"
210 assert response = html_response(conn, 200)
211 assert response =~ ~r/name="op" type="submit" value="register"/
212 assert response =~ ~r/name="op" type="submit" value="connect"/
215 test "with valid params, POST /oauth/register?op=register redirects to `redirect_uri` with `code`",
220 registration = insert(:registration, user: nil, info: %{"nickname" => nil, "email" => nil})
221 redirect_uri = OAuthController.default_redirect_uri(app)
225 |> put_session(:registration_id, registration.id)
230 "authorization" => %{
231 "scopes" => app.scopes,
232 "client_id" => app.client_id,
233 "redirect_uri" => redirect_uri,
234 "state" => "a_state",
235 "nickname" => "availablenick",
236 "email" => "available@email.com"
241 assert response = html_response(conn, 302)
242 assert redirected_to(conn) =~ ~r/#{redirect_uri}\?code=.+/
245 test "with unlisted `redirect_uri`, POST /oauth/register?op=register results in HTTP 401",
250 registration = insert(:registration, user: nil, info: %{"nickname" => nil, "email" => nil})
251 unlisted_redirect_uri = "http://cross-site-request.com"
255 |> put_session(:registration_id, registration.id)
260 "authorization" => %{
261 "scopes" => app.scopes,
262 "client_id" => app.client_id,
263 "redirect_uri" => unlisted_redirect_uri,
264 "state" => "a_state",
265 "nickname" => "availablenick",
266 "email" => "available@email.com"
271 assert response = html_response(conn, 401)
274 test "with invalid params, POST /oauth/register?op=register renders registration_details page",
279 another_user = insert(:user)
280 registration = insert(:registration, user: nil, info: %{"nickname" => nil, "email" => nil})
284 "authorization" => %{
285 "scopes" => app.scopes,
286 "client_id" => app.client_id,
287 "redirect_uri" => OAuthController.default_redirect_uri(app),
288 "state" => "a_state",
289 "nickname" => "availablenickname",
290 "email" => "available@email.com"
294 for {bad_param, bad_param_value} <-
295 [{"nickname", another_user.nickname}, {"email", another_user.email}] do
296 bad_registration_attrs = %{
297 "authorization" => Map.put(params["authorization"], bad_param, bad_param_value)
300 bad_params = Map.merge(params, bad_registration_attrs)
304 |> put_session(:registration_id, registration.id)
305 |> post("/oauth/register", bad_params)
307 assert html_response(conn, 403) =~ ~r/name="op" type="submit" value="register"/
308 assert get_flash(conn, :error) == "Error: #{bad_param} has already been taken."
312 test "with valid params, POST /oauth/register?op=connect redirects to `redirect_uri` with `code`",
317 user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt("testpassword"))
318 registration = insert(:registration, user: nil)
319 redirect_uri = OAuthController.default_redirect_uri(app)
323 |> put_session(:registration_id, registration.id)
328 "authorization" => %{
329 "scopes" => app.scopes,
330 "client_id" => app.client_id,
331 "redirect_uri" => redirect_uri,
332 "state" => "a_state",
333 "name" => user.nickname,
334 "password" => "testpassword"
339 assert response = html_response(conn, 302)
340 assert redirected_to(conn) =~ ~r/#{redirect_uri}\?code=.+/
343 test "with unlisted `redirect_uri`, POST /oauth/register?op=connect results in HTTP 401`",
348 user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt("testpassword"))
349 registration = insert(:registration, user: nil)
350 unlisted_redirect_uri = "http://cross-site-request.com"
354 |> put_session(:registration_id, registration.id)
359 "authorization" => %{
360 "scopes" => app.scopes,
361 "client_id" => app.client_id,
362 "redirect_uri" => unlisted_redirect_uri,
363 "state" => "a_state",
364 "name" => user.nickname,
365 "password" => "testpassword"
370 assert response = html_response(conn, 401)
373 test "with invalid params, POST /oauth/register?op=connect renders registration_details page",
379 registration = insert(:registration, user: nil)
383 "authorization" => %{
384 "scopes" => app.scopes,
385 "client_id" => app.client_id,
386 "redirect_uri" => OAuthController.default_redirect_uri(app),
387 "state" => "a_state",
388 "name" => user.nickname,
389 "password" => "wrong password"
395 |> put_session(:registration_id, registration.id)
396 |> post("/oauth/register", params)
398 assert html_response(conn, 401) =~ ~r/name="op" type="submit" value="connect"/
399 assert get_flash(conn, :error) == "Invalid Username/Password"
403 describe "GET /oauth/authorize" do
406 app: insert(:oauth_app, redirect_uris: "https://redirect.url"),
409 |> Plug.Session.call(Plug.Session.init(@session_opts))
414 test "renders authentication page", %{app: app, conn: conn} do
420 "response_type" => "code",
421 "client_id" => app.client_id,
422 "redirect_uri" => OAuthController.default_redirect_uri(app),
427 assert html_response(conn, 200) =~ ~s(type="submit")
430 test "properly handles internal calls with `authorization`-wrapped params", %{
439 "authorization" => %{
440 "response_type" => "code",
441 "client_id" => app.client_id,
442 "redirect_uri" => OAuthController.default_redirect_uri(app),
448 assert html_response(conn, 200) =~ ~s(type="submit")
451 test "renders authentication page if user is already authenticated but `force_login` is tru-ish",
452 %{app: app, conn: conn} do
453 token = insert(:oauth_token, app_id: app.id)
457 |> put_session(:oauth_token, token.token)
461 "response_type" => "code",
462 "client_id" => app.client_id,
463 "redirect_uri" => OAuthController.default_redirect_uri(app),
465 "force_login" => "true"
469 assert html_response(conn, 200) =~ ~s(type="submit")
472 test "with existing authentication and non-OOB `redirect_uri`, redirects to app with `token` and `state` params",
477 token = insert(:oauth_token, app_id: app.id)
481 |> put_session(:oauth_token, token.token)
485 "response_type" => "code",
486 "client_id" => app.client_id,
487 "redirect_uri" => OAuthController.default_redirect_uri(app),
488 "state" => "specific_client_state",
493 assert URI.decode(redirected_to(conn)) ==
494 "https://redirect.url?access_token=#{token.token}&state=specific_client_state"
497 test "with existing authentication and unlisted non-OOB `redirect_uri`, redirects without credentials",
502 unlisted_redirect_uri = "http://cross-site-request.com"
503 token = insert(:oauth_token, app_id: app.id)
507 |> put_session(:oauth_token, token.token)
511 "response_type" => "code",
512 "client_id" => app.client_id,
513 "redirect_uri" => unlisted_redirect_uri,
514 "state" => "specific_client_state",
519 assert redirected_to(conn) == unlisted_redirect_uri
522 test "with existing authentication and OOB `redirect_uri`, redirects to app with `token` and `state` params",
527 token = insert(:oauth_token, app_id: app.id)
531 |> put_session(:oauth_token, token.token)
535 "response_type" => "code",
536 "client_id" => app.client_id,
537 "redirect_uri" => "urn:ietf:wg:oauth:2.0:oob",
542 assert html_response(conn, 200) =~ "Authorization exists"
546 describe "POST /oauth/authorize" do
547 test "redirects with oauth authorization" do
549 app = insert(:oauth_app, scopes: ["read", "write", "follow"])
550 redirect_uri = OAuthController.default_redirect_uri(app)
554 |> post("/oauth/authorize", %{
555 "authorization" => %{
556 "name" => user.nickname,
557 "password" => "test",
558 "client_id" => app.client_id,
559 "redirect_uri" => redirect_uri,
560 "scope" => "read:subscope write",
561 "state" => "statepassed"
565 target = redirected_to(conn)
566 assert target =~ redirect_uri
568 query = URI.parse(target).query |> URI.query_decoder() |> Map.new()
570 assert %{"state" => "statepassed", "code" => code} = query
571 auth = Repo.get_by(Authorization, token: code)
573 assert auth.scopes == ["read:subscope", "write"]
576 test "returns 401 for wrong credentials", %{conn: conn} do
578 app = insert(:oauth_app)
579 redirect_uri = OAuthController.default_redirect_uri(app)
583 |> post("/oauth/authorize", %{
584 "authorization" => %{
585 "name" => user.nickname,
586 "password" => "wrong",
587 "client_id" => app.client_id,
588 "redirect_uri" => redirect_uri,
589 "state" => "statepassed",
590 "scope" => Enum.join(app.scopes, " ")
593 |> html_response(:unauthorized)
596 assert result =~ app.client_id
597 assert result =~ redirect_uri
600 assert result =~ "Invalid Username/Password"
603 test "returns 401 for missing scopes", %{conn: conn} do
605 app = insert(:oauth_app)
606 redirect_uri = OAuthController.default_redirect_uri(app)
610 |> post("/oauth/authorize", %{
611 "authorization" => %{
612 "name" => user.nickname,
613 "password" => "test",
614 "client_id" => app.client_id,
615 "redirect_uri" => redirect_uri,
616 "state" => "statepassed",
620 |> html_response(:unauthorized)
623 assert result =~ app.client_id
624 assert result =~ redirect_uri
627 assert result =~ "This action is outside the authorized scopes"
630 test "returns 401 for scopes beyond app scopes hierarchy", %{conn: conn} do
632 app = insert(:oauth_app, scopes: ["read", "write"])
633 redirect_uri = OAuthController.default_redirect_uri(app)
637 |> post("/oauth/authorize", %{
638 "authorization" => %{
639 "name" => user.nickname,
640 "password" => "test",
641 "client_id" => app.client_id,
642 "redirect_uri" => redirect_uri,
643 "state" => "statepassed",
644 "scope" => "read write follow"
647 |> html_response(:unauthorized)
650 assert result =~ app.client_id
651 assert result =~ redirect_uri
654 assert result =~ "This action is outside the authorized scopes"
658 describe "POST /oauth/token" do
659 test "issues a token for an all-body request" do
661 app = insert(:oauth_app, scopes: ["read", "write"])
663 {:ok, auth} = Authorization.create_authorization(app, user, ["write"])
667 |> post("/oauth/token", %{
668 "grant_type" => "authorization_code",
669 "code" => auth.token,
670 "redirect_uri" => OAuthController.default_redirect_uri(app),
671 "client_id" => app.client_id,
672 "client_secret" => app.client_secret
675 assert %{"access_token" => token, "me" => ap_id} = json_response(conn, 200)
677 token = Repo.get_by(Token, token: token)
679 assert token.scopes == auth.scopes
680 assert user.ap_id == ap_id
683 test "issues a token for `password` grant_type with valid credentials, with full permissions by default" do
684 password = "testpassword"
685 user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt(password))
687 app = insert(:oauth_app, scopes: ["read", "write"])
689 # Note: "scope" param is intentionally omitted
692 |> post("/oauth/token", %{
693 "grant_type" => "password",
694 "username" => user.nickname,
695 "password" => password,
696 "client_id" => app.client_id,
697 "client_secret" => app.client_secret
700 assert %{"access_token" => token} = json_response(conn, 200)
702 token = Repo.get_by(Token, token: token)
704 assert token.scopes == app.scopes
707 test "issues a token for request with HTTP basic auth client credentials" do
709 app = insert(:oauth_app, scopes: ["scope1", "scope2", "scope3"])
711 {:ok, auth} = Authorization.create_authorization(app, user, ["scope1", "scope2"])
712 assert auth.scopes == ["scope1", "scope2"]
715 (URI.encode_www_form(app.client_id) <> ":" <> URI.encode_www_form(app.client_secret))
720 |> put_req_header("authorization", "Basic " <> app_encoded)
721 |> post("/oauth/token", %{
722 "grant_type" => "authorization_code",
723 "code" => auth.token,
724 "redirect_uri" => OAuthController.default_redirect_uri(app)
727 assert %{"access_token" => token, "scope" => scope} = json_response(conn, 200)
729 assert scope == "scope1 scope2"
731 token = Repo.get_by(Token, token: token)
733 assert token.scopes == ["scope1", "scope2"]
736 test "issue a token for client_credentials grant type" do
737 app = insert(:oauth_app, scopes: ["read", "write"])
741 |> post("/oauth/token", %{
742 "grant_type" => "client_credentials",
743 "client_id" => app.client_id,
744 "client_secret" => app.client_secret
747 assert %{"access_token" => token, "refresh_token" => refresh, "scope" => scope} =
748 json_response(conn, 200)
751 token_from_db = Repo.get_by(Token, token: token)
754 assert scope == "read write"
757 test "rejects token exchange with invalid client credentials" do
759 app = insert(:oauth_app)
761 {:ok, auth} = Authorization.create_authorization(app, user)
765 |> put_req_header("authorization", "Basic JTIxOiVGMCU5RiVBNCVCNwo=")
766 |> post("/oauth/token", %{
767 "grant_type" => "authorization_code",
768 "code" => auth.token,
769 "redirect_uri" => OAuthController.default_redirect_uri(app)
772 assert resp = json_response(conn, 400)
773 assert %{"error" => _} = resp
774 refute Map.has_key?(resp, "access_token")
777 test "rejects token exchange for valid credentials belonging to unconfirmed user and confirmation is required" do
778 Pleroma.Config.put([:instance, :account_activation_required], true)
779 password = "testpassword"
782 insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt(password))
783 |> User.change_info(&User.Info.confirmation_changeset(&1, need_confirmation: true))
786 refute Pleroma.User.auth_active?(user)
788 app = insert(:oauth_app)
792 |> post("/oauth/token", %{
793 "grant_type" => "password",
794 "username" => user.nickname,
795 "password" => password,
796 "client_id" => app.client_id,
797 "client_secret" => app.client_secret
800 assert resp = json_response(conn, 403)
801 assert %{"error" => _} = resp
802 refute Map.has_key?(resp, "access_token")
805 test "rejects token exchange for valid credentials belonging to deactivated user" do
806 password = "testpassword"
810 password_hash: Comeonin.Pbkdf2.hashpwsalt(password),
811 info: %{deactivated: true}
814 app = insert(:oauth_app)
818 |> post("/oauth/token", %{
819 "grant_type" => "password",
820 "username" => user.nickname,
821 "password" => password,
822 "client_id" => app.client_id,
823 "client_secret" => app.client_secret
826 assert resp = json_response(conn, 403)
827 assert %{"error" => _} = resp
828 refute Map.has_key?(resp, "access_token")
831 test "rejects token exchange for user with password_reset_pending set to true" do
832 password = "testpassword"
836 password_hash: Comeonin.Pbkdf2.hashpwsalt(password),
837 info: %{password_reset_pending: true}
840 app = insert(:oauth_app, scopes: ["read", "write"])
844 |> post("/oauth/token", %{
845 "grant_type" => "password",
846 "username" => user.nickname,
847 "password" => password,
848 "client_id" => app.client_id,
849 "client_secret" => app.client_secret
852 assert resp = json_response(conn, 403)
854 assert resp["error"] == "Password reset is required"
855 assert resp["identifier"] == "password_reset_required"
856 refute Map.has_key?(resp, "access_token")
859 test "rejects an invalid authorization code" do
860 app = insert(:oauth_app)
864 |> post("/oauth/token", %{
865 "grant_type" => "authorization_code",
866 "code" => "Imobviouslyinvalid",
867 "redirect_uri" => OAuthController.default_redirect_uri(app),
868 "client_id" => app.client_id,
869 "client_secret" => app.client_secret
872 assert resp = json_response(conn, 400)
873 assert %{"error" => _} = json_response(conn, 400)
874 refute Map.has_key?(resp, "access_token")
878 describe "POST /oauth/token - refresh token" do
879 clear_config([:oauth2, :issue_new_refresh_token])
881 test "issues a new access token with keep fresh token" do
882 Pleroma.Config.put([:oauth2, :issue_new_refresh_token], true)
884 app = insert(:oauth_app, scopes: ["read", "write"])
886 {:ok, auth} = Authorization.create_authorization(app, user, ["write"])
887 {:ok, token} = Token.exchange_token(app, auth)
891 |> post("/oauth/token", %{
892 "grant_type" => "refresh_token",
893 "refresh_token" => token.refresh_token,
894 "client_id" => app.client_id,
895 "client_secret" => app.client_secret
897 |> json_response(200)
904 "token_type" => "Bearer",
907 "refresh_token" => _,
913 refute Repo.get_by(Token, token: token.token)
914 new_token = Repo.get_by(Token, token: response["access_token"])
915 assert new_token.refresh_token == token.refresh_token
916 assert new_token.scopes == auth.scopes
917 assert new_token.user_id == user.id
918 assert new_token.app_id == app.id
921 test "issues a new access token with new fresh token" do
922 Pleroma.Config.put([:oauth2, :issue_new_refresh_token], false)
924 app = insert(:oauth_app, scopes: ["read", "write"])
926 {:ok, auth} = Authorization.create_authorization(app, user, ["write"])
927 {:ok, token} = Token.exchange_token(app, auth)
931 |> post("/oauth/token", %{
932 "grant_type" => "refresh_token",
933 "refresh_token" => token.refresh_token,
934 "client_id" => app.client_id,
935 "client_secret" => app.client_secret
937 |> json_response(200)
944 "token_type" => "Bearer",
947 "refresh_token" => _,
953 refute Repo.get_by(Token, token: token.token)
954 new_token = Repo.get_by(Token, token: response["access_token"])
955 refute new_token.refresh_token == token.refresh_token
956 assert new_token.scopes == auth.scopes
957 assert new_token.user_id == user.id
958 assert new_token.app_id == app.id
961 test "returns 400 if we try use access token" do
963 app = insert(:oauth_app, scopes: ["read", "write"])
965 {:ok, auth} = Authorization.create_authorization(app, user, ["write"])
966 {:ok, token} = Token.exchange_token(app, auth)
970 |> post("/oauth/token", %{
971 "grant_type" => "refresh_token",
972 "refresh_token" => token.token,
973 "client_id" => app.client_id,
974 "client_secret" => app.client_secret
976 |> json_response(400)
978 assert %{"error" => "Invalid credentials"} == response
981 test "returns 400 if refresh_token invalid" do
982 app = insert(:oauth_app, scopes: ["read", "write"])
986 |> post("/oauth/token", %{
987 "grant_type" => "refresh_token",
988 "refresh_token" => "token.refresh_token",
989 "client_id" => app.client_id,
990 "client_secret" => app.client_secret
992 |> json_response(400)
994 assert %{"error" => "Invalid credentials"} == response
997 test "issues a new token if token expired" do
999 app = insert(:oauth_app, scopes: ["read", "write"])
1001 {:ok, auth} = Authorization.create_authorization(app, user, ["write"])
1002 {:ok, token} = Token.exchange_token(app, auth)
1005 Ecto.Changeset.change(
1007 %{valid_until: NaiveDateTime.add(NaiveDateTime.utc_now(), -86_400 * 30)}
1010 {:ok, access_token} = Repo.update(change)
1014 |> post("/oauth/token", %{
1015 "grant_type" => "refresh_token",
1016 "refresh_token" => access_token.refresh_token,
1017 "client_id" => app.client_id,
1018 "client_secret" => app.client_secret
1020 |> json_response(200)
1027 "token_type" => "Bearer",
1028 "expires_in" => 600,
1029 "access_token" => _,
1030 "refresh_token" => _,
1036 refute Repo.get_by(Token, token: token.token)
1037 token = Repo.get_by(Token, token: response["access_token"])
1039 assert token.scopes == auth.scopes
1040 assert token.user_id == user.id
1041 assert token.app_id == app.id
1045 describe "POST /oauth/token - bad request" do
1046 test "returns 500" do
1049 |> post("/oauth/token", %{})
1050 |> json_response(500)
1052 assert %{"error" => "Bad request"} == response
1056 describe "POST /oauth/revoke - bad request" do
1057 test "returns 500" do
1060 |> post("/oauth/revoke", %{})
1061 |> json_response(500)
1063 assert %{"error" => "Bad request"} == response