Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix initialization error message #270

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
val clueVersion = "0.37.0"
val clueVersion = "0.38.1"
val fs2Version = "3.2.7"
val grackleVersion = "0.20.0"
val http4sVersion = "0.23.27"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ import clue.model.GraphQLRequest
import clue.model.StreamingMessage.*
import clue.model.StreamingMessage.FromClient.*
import clue.model.StreamingMessage.FromServer.*
import clue.model.json.*
import grackle.Operation
import grackle.Result.*
import io.circe.Json
import io.circe.JsonObject
import io.circe.syntax.*
import lucuma.graphql.routes.mkGraphqlError
import org.http4s.ParseResult
import org.http4s.headers.Authorization
Expand Down Expand Up @@ -259,7 +261,7 @@ object Connection {

// User has insufficient privileges to connect.
case None =>
reply(Some(FromServer.Error("<none>", NonEmptyList.one(GraphQLError("Not authorized."))))) *>
reply(Some(FromServer.ConnectionError(GraphQLError("Not authorized.").asJsonObject))) *>
handle(_.close)

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package lucuma.graphql.routes

import cats.effect.*
import cats.implicits.*
import clue.DisconnectedException
import clue.RemoteInitializationException
import fs2.Stream
import grackle.Result
import grackle.circe.CirceMapping
Expand Down Expand Up @@ -75,20 +75,20 @@ class AuthSuite extends BaseSuite:
test("[http] Correct credentials should work."):
testQuery(Some("bob"), Http)

test("[ws, one-off] Missing credentials should raise DisconnectedException."):
interceptIO[DisconnectedException](testQuery(None, Ws))
test("[ws, one-off] Missing credentials should raise RemoteInitializationException."):
interceptIO[RemoteInitializationException](testQuery(None, Ws))

test("[ws, one-off] Incorrect credentials should raise DisconnectedException."):
interceptIO[DisconnectedException](testQuery(Some("steve"), Ws))
test("[ws, one-off] Incorrect credentials should raise RemoteInitializationException."):
interceptIO[RemoteInitializationException](testQuery(Some("steve"), Ws))

test("[ws, one-off] Correct credentials should work."):
testQuery(Some("bob"), Ws)

test("[ws, subscription] Missing credentials should raise DisconnectedException."):
interceptIO[DisconnectedException](testSubscription(None))
test("[ws, subscription] Missing credentials should raise RemoteInitializationException."):
interceptIO[RemoteInitializationException](testSubscription(None))

test("[ws, subscription] Incorrect credentials should raise DisconnectedException."):
interceptIO[DisconnectedException](testSubscription(Some("steve")))
test("[ws, subscription] Incorrect credentials should raise RemoteInitializationException."):
interceptIO[RemoteInitializationException](testSubscription(Some("steve")))

test("[ws, subscription] Correct credentials should work."):
testSubscription(Some("bob"))
Loading