Update WebSocket error responses (#1524)

This commit is contained in:
Alexandre de Souza 2022-11-11 12:00:47 -03:00 committed by GitHub
parent 4bf292ec43
commit e30213bc83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 11 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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