mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-06 11:35:54 +08:00
Update WebSocket error responses (#1524)
This commit is contained in:
parent
4bf292ec43
commit
e30213bc83
4 changed files with 13 additions and 11 deletions
|
@ -27,16 +27,16 @@ defmodule Livebook.WebSocket.ClientTest do
|
|||
|
||||
assert response.status == 403
|
||||
|
||||
assert %{type: {:error, %{details: "Invalid Token"}}} =
|
||||
LivebookProto.Response.decode(response.body)
|
||||
assert %{type: {:error, %{details: error}}} = LivebookProto.Response.decode(response.body)
|
||||
assert error =~ "the given token is invalid"
|
||||
|
||||
assert {:ok, conn, ref} = Client.connect(url)
|
||||
assert {:error, _conn, response} = Client.receive(conn, ref)
|
||||
|
||||
assert response.status == 401
|
||||
|
||||
assert %{type: {:error, %{details: "Token not found"}}} =
|
||||
LivebookProto.Response.decode(response.body)
|
||||
assert %{type: {:error, %{details: error}}} = LivebookProto.Response.decode(response.body)
|
||||
assert error =~ "could not get the token from the connection"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,15 +31,15 @@ defmodule Livebook.WebSocket.ServerTest do
|
|||
|
||||
assert response.status == 403
|
||||
|
||||
assert %{type: {:error, %{details: "Invalid Token"}}} =
|
||||
LivebookProto.Response.decode(response.body)
|
||||
assert %{type: {:error, %{details: error}}} = LivebookProto.Response.decode(response.body)
|
||||
assert error =~ "the given token is invalid"
|
||||
|
||||
assert {:error, response} = Server.connect(pid, url)
|
||||
|
||||
assert response.status == 401
|
||||
|
||||
assert %{type: {:error, %{details: "Token not found"}}} =
|
||||
LivebookProto.Response.decode(response.body)
|
||||
assert %{type: {:error, %{details: error}}} = LivebookProto.Response.decode(response.body)
|
||||
assert error =~ "could not get the token from the connection"
|
||||
|
||||
assert Server.disconnect(pid) == :ok
|
||||
end
|
||||
|
|
|
@ -16,10 +16,12 @@ defmodule Livebook.WebSocketTest do
|
|||
test "rejects the web socket connection with invalid credentials", %{url: url} do
|
||||
headers = [{"X-Auth-Token", "foo"}]
|
||||
|
||||
assert {:error, connection, %{details: "Invalid Token"}} = WebSocket.connect(url, headers)
|
||||
assert {:error, connection, %{details: error}} = WebSocket.connect(url, headers)
|
||||
assert error =~ "the given token is invalid"
|
||||
assert WebSocket.disconnect(connection) == :ok
|
||||
|
||||
assert {:error, connection, %{details: "Token not found"}} = WebSocket.connect(url)
|
||||
assert {:error, connection, %{details: error}} = WebSocket.connect(url)
|
||||
assert error =~ "could not get the token from the connection"
|
||||
assert WebSocket.disconnect(connection) == :ok
|
||||
end
|
||||
end
|
||||
|
|
|
@ -81,7 +81,7 @@ defmodule LivebookWeb.Hub.New.EnterpriseComponentTest do
|
|||
|> element("#connect")
|
||||
|> render_click()
|
||||
|
||||
assert render(view) =~ "Invalid Token"
|
||||
assert render(view) =~ "the given token is invalid"
|
||||
refute render(view) =~ "enterprise[hub_name]"
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue