diff options
Diffstat (limited to 'test/web')
| -rw-r--r-- | test/web/mastodon_api/mastodon_api_controller_test.exs | 5 | ||||
| -rw-r--r-- | test/web/oauth/oauth_controller_test.exs | 33 | 
2 files changed, 35 insertions, 3 deletions
| diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 78d0d3771..707723421 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -542,7 +542,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do        |> assign(:user, user)        |> get("/api/v1/accounts/verify_credentials") -    assert %{"id" => id, "source" => %{"privacy" => "public"}} = json_response(conn, 200) +    response = json_response(conn, 200) + +    assert %{"id" => id, "source" => %{"privacy" => "public"}} = response +    assert response["pleroma"]["chat_token"]      assert id == to_string(user.id)    end diff --git a/test/web/oauth/oauth_controller_test.exs b/test/web/oauth/oauth_controller_test.exs index 1c04ac9ad..242b7fdb3 100644 --- a/test/web/oauth/oauth_controller_test.exs +++ b/test/web/oauth/oauth_controller_test.exs @@ -408,7 +408,11 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do        assert html_response(conn, 200) =~ ~s(type="submit")      end -    test "redirects to app if user is already authenticated", %{app: app, conn: conn} do +    test "with existing authentication and non-OOB `redirect_uri`, redirects to app with `token` and `state` params", +         %{ +           app: app, +           conn: conn +         } do        token = insert(:oauth_token, app_id: app.id)        conn = @@ -420,11 +424,36 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do              "response_type" => "code",              "client_id" => app.client_id,              "redirect_uri" => app.redirect_uris, +            "state" => "specific_client_state", +            "scope" => "read" +          } +        ) + +      assert URI.decode(redirected_to(conn)) == +               "https://redirect.url?access_token=#{token.token}&state=specific_client_state" +    end + +    test "with existing authentication and OOB `redirect_uri`, redirects to app with `token` and `state` params", +         %{ +           app: app, +           conn: conn +         } do +      token = insert(:oauth_token, app_id: app.id) + +      conn = +        conn +        |> put_session(:oauth_token, token.token) +        |> get( +          "/oauth/authorize", +          %{ +            "response_type" => "code", +            "client_id" => app.client_id, +            "redirect_uri" => "urn:ietf:wg:oauth:2.0:oob",              "scope" => "read"            }          ) -      assert redirected_to(conn) == "https://redirect.url" +      assert html_response(conn, 200) =~ "Authorization exists"      end    end | 
