Fix lint errors
This commit is contained in:
parent
d0c1997d48
commit
4194559ea6
2 changed files with 18 additions and 7 deletions
|
@ -34,15 +34,22 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do
|
||||||
test "refuses invalid requests" do
|
test "refuses invalid requests" do
|
||||||
capture_log(fn ->
|
capture_log(fn ->
|
||||||
assert {:error, %Mint.WebSocket.UpgradeFailureError{status_code: 404}} = start_socket()
|
assert {:error, %Mint.WebSocket.UpgradeFailureError{status_code: 404}} = start_socket()
|
||||||
assert {:error, %Mint.WebSocket.UpgradeFailureError{status_code: 404}} = start_socket("?stream=ncjdk")
|
|
||||||
|
assert {:error, %Mint.WebSocket.UpgradeFailureError{status_code: 404}} =
|
||||||
|
start_socket("?stream=ncjdk")
|
||||||
|
|
||||||
Process.sleep(30)
|
Process.sleep(30)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "requires authentication and a valid token for protected streams" do
|
test "requires authentication and a valid token for protected streams" do
|
||||||
capture_log(fn ->
|
capture_log(fn ->
|
||||||
assert {:error, %Mint.WebSocket.UpgradeFailureError{status_code: 401}} = start_socket("?stream=user&access_token=aaaaaaaaaaaa")
|
assert {:error, %Mint.WebSocket.UpgradeFailureError{status_code: 401}} =
|
||||||
assert {:error, %Mint.WebSocket.UpgradeFailureError{status_code: 401}} = start_socket("?stream=user")
|
start_socket("?stream=user&access_token=aaaaaaaaaaaa")
|
||||||
|
|
||||||
|
assert {:error, %Mint.WebSocket.UpgradeFailureError{status_code: 401}} =
|
||||||
|
start_socket("?stream=user")
|
||||||
|
|
||||||
Process.sleep(30)
|
Process.sleep(30)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -102,7 +109,9 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do
|
||||||
assert {:ok, _} = start_socket("?stream=user&access_token=#{token.token}")
|
assert {:ok, _} = start_socket("?stream=user&access_token=#{token.token}")
|
||||||
|
|
||||||
capture_log(fn ->
|
capture_log(fn ->
|
||||||
assert {:error, %Mint.WebSocket.UpgradeFailureError{status_code: 401}} = start_socket("?stream=user")
|
assert {:error, %Mint.WebSocket.UpgradeFailureError{status_code: 401}} =
|
||||||
|
start_socket("?stream=user")
|
||||||
|
|
||||||
Process.sleep(30)
|
Process.sleep(30)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -111,7 +120,9 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do
|
||||||
assert {:ok, _} = start_socket("?stream=user:notification&access_token=#{token.token}")
|
assert {:ok, _} = start_socket("?stream=user:notification&access_token=#{token.token}")
|
||||||
|
|
||||||
capture_log(fn ->
|
capture_log(fn ->
|
||||||
assert {:error, %Mint.WebSocket.UpgradeFailureError{status_code: 401}} = start_socket("?stream=user:notification")
|
assert {:error, %Mint.WebSocket.UpgradeFailureError{status_code: 401}} =
|
||||||
|
start_socket("?stream=user:notification")
|
||||||
|
|
||||||
Process.sleep(30)
|
Process.sleep(30)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -188,8 +188,8 @@ defmodule Pleroma.Integration.WebsocketClient do
|
||||||
defp stream_frame(state, frame) do
|
defp stream_frame(state, frame) do
|
||||||
with {:ok, websocket, data} <- Mint.WebSocket.encode(state.websocket, frame),
|
with {:ok, websocket, data} <- Mint.WebSocket.encode(state.websocket, frame),
|
||||||
state = put_in(state.websocket, websocket),
|
state = put_in(state.websocket, websocket),
|
||||||
{:ok, conn} <- Mint.WebSocket.stream_request_body(state.conn, state.request_ref, data) do
|
{:ok, conn} <- Mint.WebSocket.stream_request_body(state.conn, state.request_ref, data) do
|
||||||
{:ok, put_in(state.conn, conn)}
|
{:ok, put_in(state.conn, conn)}
|
||||||
else
|
else
|
||||||
{:error, %Mint.WebSocket{} = websocket, reason} ->
|
{:error, %Mint.WebSocket{} = websocket, reason} ->
|
||||||
{:error, put_in(state.websocket, websocket), reason}
|
{:error, put_in(state.websocket, websocket), reason}
|
||||||
|
|
Loading…
Reference in a new issue