kalix-jvm-sdk icon indicating copy to clipboard operation
kalix-jvm-sdk copied to clipboard

Provide more convenient methods to tweak Metadata

Open octonato opened this issue 1 year ago • 1 comments

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.

octonato avatar Oct 10 '23 14:10 octonato

Btw for completeness, this exists already for CloudEvent but not for JwtClaims.

efgpinto avatar Nov 02 '23 11:11 efgpinto