From 050227f11898f402f5888d53e6460b704bcd0a8b Mon Sep 17 00:00:00 2001 From: tusooa Date: Sat, 1 Apr 2023 08:39:38 -0400 Subject: [PATCH] Add test to cover error: bad_topic --- test/pleroma/integration/mastodon_websocket_test.exs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/pleroma/integration/mastodon_websocket_test.exs b/test/pleroma/integration/mastodon_websocket_test.exs index 8129645ec..0e8413749 100644 --- a/test/pleroma/integration/mastodon_websocket_test.exs +++ b/test/pleroma/integration/mastodon_websocket_test.exs @@ -180,6 +180,18 @@ test "won't double subscribe" do refute_receive {:text, _}, 1_000 end + test "rejects invalid streams" do + {:ok, pid} = start_socket() + WebsocketClient.send_text(pid, %{type: "subscribe", stream: "nonsense"} |> Jason.encode!()) + assert_receive {:text, raw_json}, 1_000 + + assert {:ok, + %{ + "event" => "pleroma:respond", + "payload" => %{"type" => "subscribe", "result" => "error", "error" => "bad_topic"} + }} = decode_json(raw_json) + end + test "can unsubscribe" do user = insert(:user) {:ok, pid} = start_socket()