```{{{jwt org_jwks_endpoint=request.requestLine.ba...
# help
d
Copy code
{{{jwt org_jwks_endpoint=request.requestLine.baseUrl+"test"}}}
Is it possible to append strings to url parameter used in jwt ?
l
Hi, there is a
join
helper that might work for you. You can find the implementation of that helper here - https://github.com/jknack/handlebars.java/blob/master/handlebars/src/main/java/com/github/jknack/handlebars/helper/StringHelpers.java#L144
Copy code
/**
   * Joins an array, iterator or an iterable with a string. For example:
   *
   * <pre>
   * {{join value " // " [prefix=""] [suffix=""]}}
   * </pre>
   *
   * <p>If value is the list ['a', 'b', 'c'], the output will be the string "a // b // c". Or:
   *
   * <pre>
   * {{join "a" "b" "c" " // " [prefix=""] [suffix=""]}}
   * Join the "a", "b", "c", the output will be the string "a // b // c".
   * </pre>
   */
tq 1
d
Copy code
{{join request.requestLine.baseUrl '/0014H00003ARnWpQAL/0014H00003ARnWpQAL.jwks' }}
@Lee Turner I tried this but in the output I am getting only url in the output and do not see the path attached
/0014H00003ARnWpQAL/0014H00003ARnWpQAL.jwks
l
I think that is because you are not providing the string to join them with. In your case this would be an empty string. For example:
Copy code
{{join request.requestLine.baseUrl '/0014H00003ARnWpQAL/0014H00003ARnWpQAL.jwks' ''}}
Should generate:
Copy code
<http://localhost:8080/0014H00003ARnWpQAL/0014H00003ARnWpQAL.jwks>
Or you could get a little more fancy and provide the path separator as the string to join and separate out the different components of the url:
Copy code
{{join request.requestLine.baseUrl '0014H00003ARnWpQAL' '0014H00003ARnWpQAL.jwks' '/'}}
Should generate the same result
d
I will try, Thanks
@Lee Turner I have some of the jwt claims in json and array for e.g.
Copy code
"organisation_competent_authority_claims": {
    "authority_id": "PAYUKGBR",
    "registration_id": "110000",
    "status": "Active",
    "authorisations": [
      {
        "member_state": "GB",
        "roles": [
          "COPRequester",
          "COPResponder"
        ]
      }
    ]
  }
Copy code
"software_roles": [
    "COPRequester"
  ]
Should I use
val
helper to assign or do we have any other option ?
l
I haven't tried that myself so not sure of the best way to handle that. I would try the
val
helper first i think
d
ok
@Lee Turner array worked. Which data type can I use it for json ?
Copy code
organisation_competent_authority_claims=(jsonPath '{\"outer\":{\"inner\":\"Stuff\"}}' '$.outer.inner')
@Lee Turner Value retrieved is empty string. Am I missing something here ?
l
I think the reason is because the
jsonPath
helper needs a JSON object instead of a string to be passed in. This seems to work for me -
{{jsonPath (parseJson '{"outer":{"inner":"Stuff"}}') '$.outer.inner'}}
d
oh
Thanks, I will check
Will it work only for string output not for json ?
for e.g.
{"outer":{"inner":{"authority_id":"PAYUKGBR"}}}
l
Sorry, I am not sure what you mean. Will what work ?
d
If I want json`{"authority_id":"PAYUKGBR"}` from the
inner
key
{{jsonPath (parseJson '{"outer":{"inner":"Stuff"}}') '$.outer.inner'}
👆This returns
Stuff
{{jsonPath (parseJson '{"outer":{"inner":{"authority_id":"PAYUKGBR"}}}') '$.outer.inner'}
👆This is not returning
{"authority_id":"PAYUKGBR"}
l
Not sure what the problem is there. I have just copied your example and it works for me:
Copy code
{
  "request": {
    "method": "GET",
    "urlPath": "/endpoint"
  },
  "response": {
    "status": 200,
    "body": "{{jsonPath (parseJson '{\"outer\":{\"inner\":{\"authority_id\":\"PAYUKGBR\"}}}') '$.outer.inner'}}",
    "transformers": [
      "response-template"
    ]
  }
}
When I make a request to the stub it returns :
Copy code
{
  "authority_id": "PAYUKGBR"
}
Other than in your example you are missing an
}
off the end of your handlebars expression
d
I will try again
Works for mock response but not for jwt custom claims. I am able to assign string and array for jwt custom claims. If I try to assign json, I do not see the claim in the jwt payload.
l
Ah, that makes sense. I think the types in the jwt plugin are limited
d
oh