[#2068] Introduced proper OAuth tokens usage to controller tests.

This commit is contained in:
Ivan Tashkinov 2019-12-19 17:23:27 +03:00
commit 455e072d27
23 changed files with 548 additions and 1045 deletions

View file

@ -18,6 +18,7 @@ defmodule Pleroma.Web.MastodonAPI.MastoFEController do
conn =
conn
|> assign(:user, user)
|> assign(:token, insert(:oauth_token, user: user, scopes: ["write:accounts"]))
|> put("/api/web/settings", %{"data" => %{"programming" => "socks"}})
assert _result = json_response(conn, 200)
@ -63,12 +64,12 @@ defmodule Pleroma.Web.MastodonAPI.MastoFEController do
end
test "does not redirect logged in users to the login page", %{conn: conn, path: path} do
token = insert(:oauth_token)
token = insert(:oauth_token, scopes: ["read"])
conn =
conn
|> assign(:user, token.user)
|> put_session(:oauth_token, token.token)
|> assign(:token, token)
|> get(path)
assert conn.status == 200