smocker-dev/smocker

Dynamic mock on Query params

Osku opened this issue · 2 comments

Osku commented

Hello

Can you provide a working sample of dynamic mock built on top of Query Params ?

I tried :

- request:
    method: GET
    path: /oauth/authorize
  dynamic_response:
    engine: go_template
    script: >
        headers:
          Location: "{{.Request.QueryParams.redirect_uri}}&code=ABCDE?state={{.Request.QueryParams.state}}"
        status: 302

It works almost.
I got a Location header set with [redirect_url_value]&code=ABCDE?state=[state_value]

How could I remove these "[" and "]" ?

Thanks in advance.

It is certainly not an issue.

Osku commented

I is juste OK with :

- request:
    method: GET
    path: /oauth/authorize
  dynamic_response:
    engine: go_template
    script: >
        headers:
          Location: "{{first .Request.QueryParams.redirect_uri}}&code=ABCDE?state={first {.Request.QueryParams.state}}"
        status: 302
Osku commented

Sorry for the noise.