projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix notifications mark as read API
[akkoma]
/
test
/
integration
/
mastodon_websocket_test.exs
diff --git
a/test/integration/mastodon_websocket_test.exs
b/test/integration/mastodon_websocket_test.exs
index 63bf73412f9bf1b03c299ca1e0fc48c7c6ca31d3..ea17e9feb7baafe4990f47894b0808d7df55b2d0 100644
(file)
--- a/
test/integration/mastodon_websocket_test.exs
+++ b/
test/integration/mastodon_websocket_test.exs
@@
-1,5
+1,5
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-20
18
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-20
20
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Integration.MastodonWebsocketTest do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Integration.MastodonWebsocketTest do
@@
-11,7
+11,8
@@
defmodule Pleroma.Integration.MastodonWebsocketTest do
alias Pleroma.Integration.WebsocketClient
alias Pleroma.Web.CommonAPI
alias Pleroma.Web.OAuth
alias Pleroma.Integration.WebsocketClient
alias Pleroma.Web.CommonAPI
alias Pleroma.Web.OAuth
- alias Pleroma.Web.Streamer
+
+ @moduletag needs_streamer: true, capture_log: true
@path Pleroma.Web.Endpoint.url()
|> URI.parse()
@path Pleroma.Web.Endpoint.url()
|> URI.parse()
@@
-19,16
+20,6
@@
defmodule Pleroma.Integration.MastodonWebsocketTest do
|> Map.put(:path, "/api/v1/streaming")
|> URI.to_string()
|> Map.put(:path, "/api/v1/streaming")
|> URI.to_string()
- setup do
- GenServer.start(Streamer, %{}, name: Streamer)
-
- on_exit(fn ->
- if pid = Process.whereis(Streamer) do
- Process.exit(pid, :kill)
- end
- end)
- end
-
def start_socket(qs \\ nil, headers \\ []) do
path =
case qs do
def start_socket(qs \\ nil, headers \\ []) do
path =
case qs do
@@
-41,15
+32,17
@@
defmodule Pleroma.Integration.MastodonWebsocketTest do
test "refuses invalid requests" do
capture_log(fn ->
test "refuses invalid requests" do
capture_log(fn ->
- assert {:error, {40
0
, _}} = start_socket()
+ assert {:error, {40
4
, _}} = start_socket()
assert {:error, {404, _}} = start_socket("?stream=ncjdk")
assert {:error, {404, _}} = start_socket("?stream=ncjdk")
+ Process.sleep(30)
end)
end
test "requires authentication and a valid token for protected streams" do
capture_log(fn ->
end)
end
test "requires authentication and a valid token for protected streams" do
capture_log(fn ->
- assert {:error, {403, _}} = start_socket("?stream=user&access_token=aaaaaaaaaaaa")
- assert {:error, {403, _}} = start_socket("?stream=user")
+ assert {:error, {401, _}} = start_socket("?stream=user&access_token=aaaaaaaaaaaa")
+ assert {:error, {401, _}} = start_socket("?stream=user")
+ Process.sleep(30)
end)
end
end)
end
@@
-62,7
+55,7
@@
defmodule Pleroma.Integration.MastodonWebsocketTest do
test "receives well formatted events" do
user = insert(:user)
{:ok, _} = start_socket("?stream=public")
test "receives well formatted events" do
user = insert(:user)
{:ok, _} = start_socket("?stream=public")
- {:ok, activity} = CommonAPI.post(user, %{
"status" =>
"nice echo chamber"})
+ {:ok, activity} = CommonAPI.post(user, %{
status:
"nice echo chamber"})
assert_receive {:text, raw_json}, 1_000
assert {:ok, json} = Jason.decode(raw_json)
assert_receive {:text, raw_json}, 1_000
assert {:ok, json} = Jason.decode(raw_json)
@@
-72,7
+65,7
@@
defmodule Pleroma.Integration.MastodonWebsocketTest do
assert {:ok, json} = Jason.decode(json["payload"])
view_json =
assert {:ok, json} = Jason.decode(json["payload"])
view_json =
- Pleroma.Web.MastodonAPI.StatusView.render("s
tatus
.json", activity: activity, for: nil)
+ Pleroma.Web.MastodonAPI.StatusView.render("s
how
.json", activity: activity, for: nil)
|> Jason.encode!()
|> Jason.decode!()
|> Jason.encode!()
|> Jason.decode!()
@@
-107,7
+100,8
@@
defmodule Pleroma.Integration.MastodonWebsocketTest do
assert {:ok, _} = start_socket("?stream=user&access_token=#{token.token}")
assert capture_log(fn ->
assert {:ok, _} = start_socket("?stream=user&access_token=#{token.token}")
assert capture_log(fn ->
- assert {:error, {403, "Forbidden"}} = start_socket("?stream=user")
+ assert {:error, {401, _}} = start_socket("?stream=user")
+ Process.sleep(30)
end) =~ ":badarg"
end
end) =~ ":badarg"
end
@@
-115,7
+109,8
@@
defmodule Pleroma.Integration.MastodonWebsocketTest do
assert {:ok, _} = start_socket("?stream=user:notification&access_token=#{token.token}")
assert capture_log(fn ->
assert {:ok, _} = start_socket("?stream=user:notification&access_token=#{token.token}")
assert capture_log(fn ->
- assert {:error, {403, "Forbidden"}} = start_socket("?stream=user:notification")
+ assert {:error, {401, _}} = start_socket("?stream=user:notification")
+ Process.sleep(30)
end) =~ ":badarg"
end
end) =~ ":badarg"
end
@@
-123,8
+118,10
@@
defmodule Pleroma.Integration.MastodonWebsocketTest do
assert {:ok, _} = start_socket("?stream=user", [{"Sec-WebSocket-Protocol", token.token}])
assert capture_log(fn ->
assert {:ok, _} = start_socket("?stream=user", [{"Sec-WebSocket-Protocol", token.token}])
assert capture_log(fn ->
- assert {:error, {40
3, "Forbidden"
}} =
+ assert {:error, {40
1, _
}} =
start_socket("?stream=user", [{"Sec-WebSocket-Protocol", "I am a friend"}])
start_socket("?stream=user", [{"Sec-WebSocket-Protocol", "I am a friend"}])
+
+ Process.sleep(30)
end) =~ ":badarg"
end
end
end) =~ ":badarg"
end
end