Merge branch 'mastodon-websocket-fix' into 'develop'

Fix Mastodon WebSocket authentication

See merge request pleroma/pleroma!4206
This commit is contained in:
lain 2024-11-13 08:22:44 +00:00 committed by Haelwenn (lanodan) Monnier
commit 53c2d2cd87
No known key found for this signature in database
6 changed files with 26 additions and 3 deletions

View file

@ -268,6 +268,17 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do
end)
end
test "accepts valid token on Sec-WebSocket-Protocol header", %{token: token} do
assert {:ok, _} = start_socket("?stream=user", [{"Sec-WebSocket-Protocol", token.token}])
capture_log(fn ->
assert {:error, %WebSockex.RequestError{code: 401}} =
start_socket("?stream=user", [{"Sec-WebSocket-Protocol", "I am a friend"}])
Process.sleep(30)
end)
end
test "accepts valid token on client-sent event", %{token: token} do
assert {:ok, pid} = start_socket()