Add the auth pipeline for the Link API path.
continuous-integration/drone/push Build is failing
continuous-integration/drone/tag Build was killed

This commit is contained in:
2023-08-10 20:06:27 +03:00
parent c793b46e53
commit aff4973ea8
7 changed files with 54 additions and 2 deletions
@@ -2,6 +2,7 @@ defmodule LinkShortenerWeb.Api.V1.LinkControllerTest do
use LinkShortenerWeb.ConnCase
import LinkShortener.LinksFixtures
import LinkShortener.AccountsFixtures
alias LinkShortener.Links.Link
alias LinkShortener.Links
@@ -23,7 +24,13 @@ defmodule LinkShortenerWeb.Api.V1.LinkControllerTest do
}
setup %{conn: conn} do
{:ok, conn: put_req_header(conn, "accept", "application/json")}
%{token: token} = create_user_token()
conn = conn
|> put_req_header("accept", "application/json")
|> put_req_header("authorization", "Bearer #{token}")
{:ok, conn: conn}
end
describe "index" do
@@ -90,6 +97,11 @@ defmodule LinkShortenerWeb.Api.V1.LinkControllerTest do
end
end
defp create_user_token() do
token = user_token_fixture()
%{token: token}
end
defp create_link(_) do
link = link_fixture()
%{link: link}