analytics/test/plausible_web/controllers/avatar_controller_test.exs
Uku Taht 97b24c0492
Nolt sso (along with a better nav dropdown) (#3395)
* Add SSO link with signed JWT token

* Falls back to Nolt URL without SSO if token cannot be generated

* Add profile image (gravatar) to Nolt SSO link

* Improve navbar dropdown

* Add 'contact support' link to nav dropdown

* Add CSS rule to prevent horizontal jumps

* Dark mode styling

* Close dropdown when link is clicked

* Clarify links in dropdown

* Clarify CSS comment

* Use Alpine.data() over window

* Rename suggestions_dropdown -> combo-box

* Mix format

* Make logout link look good on dark mode

* Use proxy for gravatar

* Do not use Gravatar proxy in self-hosted

* Changelog

* Add Github Repo link to nav dropdown

* Make dialyzer happy

* Add proxy for Gravatar

* Update assets/css/app.css

Co-authored-by: hq1 <hq@mtod.org>

* Update lib/plausible_web/controllers/avatar_controller.ex

Co-authored-by: hq1 <hq@mtod.org>

* Fix alpine <> Liveview integration

---------

Co-authored-by: hq1 <hq@mtod.org>
2023-10-17 12:01:27 +03:00

35 lines
980 B
Elixir

defmodule PlausibleWeb.AvatarControllerTest do
use PlausibleWeb.ConnCase, async: true
import Mox
setup :verify_on_exit!
describe "GET /avatar/:hash" do
test "proxies the request to gravatar", %{conn: conn} do
expect(
Plausible.HTTPClient.Mock,
:get,
fn "https://www.gravatar.com/avatar/myhash?s=150&d=identicon" ->
{:ok,
%Finch.Response{
status: 200,
body: "avatar response body",
headers: [
{"content-type", "image/png"},
{"cache-control", "max-age=300"},
{"expires", "soon"}
]
}}
end
)
conn = get(conn, "/avatar/myhash")
assert response(conn, 200) =~ "avatar response body"
assert {"content-type", "image/png"} in conn.resp_headers
assert {"cache-control", "max-age=300"} in conn.resp_headers
assert {"expires", "soon"} in conn.resp_headers
end
end
end