X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fintegration%2Fmastodon_websocket_test.exs;h=3975cdcd694b3a39bc14ebce532b89faaa021b55;hb=1179a135333aa59e7fa4f5b908e1db8257b994f5;hp=0c513b6e75feab22454ee2df23a5afbef7d37dae;hpb=063baca5e4f3a100c0d45dffb14e4968599ef43b;p=akkoma diff --git a/test/integration/mastodon_websocket_test.exs b/test/integration/mastodon_websocket_test.exs index 0c513b6e7..3975cdcd6 100644 --- a/test/integration/mastodon_websocket_test.exs +++ b/test/integration/mastodon_websocket_test.exs @@ -7,9 +7,9 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do import Pleroma.Factory + alias Pleroma.Integration.WebsocketClient alias Pleroma.Web.CommonAPI alias Pleroma.Web.OAuth - alias Pleroma.Integration.WebsocketClient alias Pleroma.Web.Streamer @path Pleroma.Web.Endpoint.url() @@ -97,5 +97,22 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do test "accepts valid tokens", state do assert {:ok, _} = start_socket("?stream=user&access_token=#{state.token.token}") end + + test "accepts the 'user' stream", %{token: token} = _state do + assert {:ok, _} = start_socket("?stream=user&access_token=#{token.token}") + assert {:error, {403, "Forbidden"}} = start_socket("?stream=user") + end + + test "accepts the 'user:notification' stream", %{token: token} = _state do + assert {:ok, _} = start_socket("?stream=user:notification&access_token=#{token.token}") + assert {:error, {403, "Forbidden"}} = start_socket("?stream=user:notification") + end + + test "accepts valid token on Sec-WebSocket-Protocol header", %{token: token} do + assert {:ok, _} = start_socket("?stream=user", [{"Sec-WebSocket-Protocol", token.token}]) + + assert {:error, {403, "Forbidden"}} = + start_socket("?stream=user", [{"Sec-WebSocket-Protocol", "I am a friend"}]) + end end end