Lint
This commit is contained in:
parent
3522852c61
commit
f459c1260b
|
@ -32,7 +32,8 @@ def init(%{qs: qs} = req, state) do
|
||||||
req
|
req
|
||||||
end
|
end
|
||||||
|
|
||||||
{:cowboy_websocket, req, %{user: user, topic: topic, oauth_token: oauth_token, count: 0, timer: nil},
|
{:cowboy_websocket, req,
|
||||||
|
%{user: user, topic: topic, oauth_token: oauth_token, count: 0, timer: nil},
|
||||||
%{idle_timeout: @timeout}}
|
%{idle_timeout: @timeout}}
|
||||||
else
|
else
|
||||||
{:error, :bad_topic} ->
|
{:error, :bad_topic} ->
|
||||||
|
|
|
@ -41,7 +41,9 @@ test "refuses invalid requests" do
|
||||||
|
|
||||||
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, %WebSockex.RequestError{code: 401}} = start_socket("?stream=user&access_token=aaaaaaaaaaaa")
|
assert {:error, %WebSockex.RequestError{code: 401}} =
|
||||||
|
start_socket("?stream=user&access_token=aaaaaaaaaaaa")
|
||||||
|
|
||||||
assert {:error, %WebSockex.RequestError{code: 401}} = start_socket("?stream=user")
|
assert {:error, %WebSockex.RequestError{code: 401}} = start_socket("?stream=user")
|
||||||
Process.sleep(30)
|
Process.sleep(30)
|
||||||
end)
|
end)
|
||||||
|
@ -111,7 +113,9 @@ test "accepts the 'user:notification' stream", %{token: token} = _state 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, %WebSockex.RequestError{code: 401}} = start_socket("?stream=user:notification")
|
assert {:error, %WebSockex.RequestError{code: 401}} =
|
||||||
|
start_socket("?stream=user:notification")
|
||||||
|
|
||||||
Process.sleep(30)
|
Process.sleep(30)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@ def start_link(sender, url, headers \\ []) do
|
||||||
WebSockex.start_link(
|
WebSockex.start_link(
|
||||||
url,
|
url,
|
||||||
__MODULE__,
|
__MODULE__,
|
||||||
%{ sender: sender },
|
%{sender: sender},
|
||||||
extra_headers: headers
|
extra_headers: headers
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue