kalix-jvm-sdk
kalix-jvm-sdk copied to clipboard
Provide more convenient methods to tweak Metadata
A user reported that he was trying to write a test for an Action that was using JWT.
The action method implementation checks for a given field in in the JWT claims.
Currently, the way to do it is to build a Metadata object manually and pass it to the call.
For example:
val metadata = Metadata.EMPTY.add("_kalix-jwt-claim-sub", "...")
and then passing it to the testkit method, eg:
val testKit = FibonacciActionTestKit(new FibonacciAction(_))
val resultStream = testKit.nextNumbers(Number(5), metadata)
What is odd with this, is that users need to know the key to add to the Metadata and that should be implementation detail.
When consuming JWT claims from the Metadata, users have a nice discoverable API, for example:
metadata.jwtClaims().subject()
We should consider adding similar APIs to tweak the metadata.
Btw for completeness, this exists already for CloudEvent
but not for JwtClaims
.