Skip to content

Conversation

majk-p
Copy link
Member

@majk-p majk-p commented May 20, 2024

Resolves #486

We might need to wait for #487 with merging, as we did some build fixes there

@@ -26,6 +27,12 @@ trait CirceJsonDecoders {
implicit def jsonDecoder[A](implicit decoder: Decoder[A]): JsonDecoder[A] =
(data: String) => io.circe.parser.decode[A](data).leftMap(error => JsonDecoder.Error(error.getMessage, cause = Some(error)))

implicit val optionScopeDecoder: Decoder[Option[Scope]] =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is out of scope of this PR, as it would be a breaking change, but this should be a Set[Scope], rather than Option[Scope]. According to the RFC:

The value of the scope parameter is expressed as a list of space-
delimited, case-sensitive strings.
(...)
If the value contains multiple space-delimited
strings, their order does not matter, and each string adds an
additional access range to the requested scope.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of scope, hehe.

@@ -60,7 +60,7 @@ trait ClientCredentialsAccessTokenResponseDeserializationSpec extends AnyFlatSpe
)
}

"Token with empty scope" should "not be deserialized" in {
"Token with empty scope" should "be deserialized with None scope" in {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this also served as a test for an invalid scope. How about adding another case with invalid scope, e.g. "déjà vu"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

@majk-p majk-p force-pushed the empty-string-scope-as-none branch from 44d46f3 to 1a79774 Compare May 21, 2024 17:01
@majk-p majk-p merged commit ff37bb8 into main May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optional scope not working as expected
2 participants