mastodon_websocket_test.exs: Test for Sec-WebSocket-Protocol header
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Sun, 7 Jul 2019 06:58:24 +0000 (08:58 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Sun, 7 Jul 2019 06:58:24 +0000 (08:58 +0200)
test/integration/mastodon_websocket_test.exs

index a604713d800ec83407049116282c78a49ad733b3..3975cdcd694b3a39bc14ebce532b89faaa021b55 100644 (file)
@@ -107,5 +107,12 @@ defmodule Pleroma.Integration.MastodonWebsocketTest 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