summaryrefslogtreecommitdiff
path: root/test/web/streamer
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2019-10-06 09:30:49 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2019-10-06 09:30:49 +0300
commitf459aabdfafa990b33610438650f882ccac072d2 (patch)
treee5bfcb4f8fc7c2dd06e08f90b3a841c4f9ad759a /test/web/streamer
parent6ffa2b5f661c2db424334c6fb5de6f4d1bfeb745 (diff)
parent9e34919dcdbeedf8eb623dc86b05f63ef44d8859 (diff)
downloadpleroma-f459aabdfafa990b33610438650f882ccac072d2.tar.gz
pleroma-f459aabdfafa990b33610438650f882ccac072d2.zip
Merge remote-tracking branch 'remotes/upstream/develop' into 1260-rate-limited-auth-actions
# Conflicts: # CHANGELOG.md
Diffstat (limited to 'test/web/streamer')
-rw-r--r--test/web/streamer/streamer_test.exs74
1 files changed, 56 insertions, 18 deletions
diff --git a/test/web/streamer/streamer_test.exs b/test/web/streamer/streamer_test.exs
index b8fcd41fa..d33eb1e42 100644
--- a/test/web/streamer/streamer_test.exs
+++ b/test/web/streamer/streamer_test.exs
@@ -233,30 +233,68 @@ defmodule Pleroma.Web.StreamerTest do
end
end
- test "it doesn't send to blocked users" do
- user = insert(:user)
- blocked_user = insert(:user)
- {:ok, user} = User.block(user, blocked_user)
+ describe "blocks" do
+ test "it doesn't send messages involving blocked users" do
+ user = insert(:user)
+ blocked_user = insert(:user)
+ {:ok, user} = User.block(user, blocked_user)
- task =
- Task.async(fn ->
- refute_receive {:text, _}, 1_000
- end)
+ task =
+ Task.async(fn ->
+ refute_receive {:text, _}, 1_000
+ end)
- fake_socket = %StreamerSocket{
- transport_pid: task.pid,
- user: user
- }
+ fake_socket = %StreamerSocket{
+ transport_pid: task.pid,
+ user: user
+ }
- {:ok, activity} = CommonAPI.post(blocked_user, %{"status" => "Test"})
+ {:ok, activity} = CommonAPI.post(blocked_user, %{"status" => "Test"})
- topics = %{
- "public" => [fake_socket]
- }
+ topics = %{
+ "public" => [fake_socket]
+ }
- Worker.push_to_socket(topics, "public", activity)
+ Worker.push_to_socket(topics, "public", activity)
- Task.await(task)
+ Task.await(task)
+ end
+
+ test "it doesn't send messages transitively involving blocked users" do
+ blocker = insert(:user)
+ blockee = insert(:user)
+ friend = insert(:user)
+
+ task =
+ Task.async(fn ->
+ refute_receive {:text, _}, 1_000
+ end)
+
+ fake_socket = %StreamerSocket{
+ transport_pid: task.pid,
+ user: blocker
+ }
+
+ topics = %{
+ "public" => [fake_socket]
+ }
+
+ {:ok, blocker} = User.block(blocker, blockee)
+
+ {:ok, activity_one} = CommonAPI.post(friend, %{"status" => "hey! @#{blockee.nickname}"})
+
+ Worker.push_to_socket(topics, "public", activity_one)
+
+ {:ok, activity_two} = CommonAPI.post(blockee, %{"status" => "hey! @#{friend.nickname}"})
+
+ Worker.push_to_socket(topics, "public", activity_two)
+
+ {:ok, activity_three} = CommonAPI.post(blockee, %{"status" => "hey! @#{blocker.nickname}"})
+
+ Worker.push_to_socket(topics, "public", activity_three)
+
+ Task.await(task)
+ end
end
test "it doesn't send unwanted DMs to list" do