Skip to content

Commit

Permalink
Add test for endpoint with modified scope
Browse files Browse the repository at this point in the history
  • Loading branch information
zoldar committed Jul 2, 2024
1 parent fca9c9d commit 032e567
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,17 @@ defmodule PlausibleWeb.Api.ExternalSitesControllerTest do
assert json_response(conn, 200) == %{"domain" => new_domain, "timezone" => site.timezone}
end

test "get a site with basic scope config", %{conn: conn, user: user, site: site} do
api_key = insert(:api_key, user: user, scopes: ["stats:read:*"])

conn =
conn
|> Plug.Conn.put_req_header("authorization", "Bearer #{api_key.key}")
|> get("/api/v1/sites/" <> site.domain)

assert json_response(conn, 200) == %{"domain" => site.domain, "timezone" => site.timezone}
end

test "is 404 when site cannot be found", %{conn: conn} do
conn = get(conn, "/api/v1/sites/foobar.baz")

Expand Down

0 comments on commit 032e567

Please sign in to comment.