MaibornWolff / alt-core-js

Acceptance & Load testing framework
https://www.npmjs.com/package/@maibornwolff/alt-core-js
MIT License
7 stars 1 forks source link

Support specifying query parameters #34

Closed johannesloher closed 5 years ago

johannesloher commented 5 years ago

Currently, in REST actions, query parameters can only be specified by setting them as part of endpoint. This doesn't look very nice and is also not very flexible: It does not work well with overriding in scenarios.

This issue suggest to add the possibility to configure query parameters for REST actions by providing an additional optional field queryParams. If present, the members of this field get expanded to query parameters, like the following example describes:

type: REST
service: my-service
endpoint: /api/users/search
method: GET
queryParams:
  userName: "Cliff Diver"

Performing this action will result in an HTTP call to

<base-url>/api/users/search?userName=Cliff%20Diver

It should be possible to use variables in queryParams:

# search-user.yaml

type: REST
service: my-service
endpoint: /api/users/search
method: GET
queryParams:
  userName: "dummy username"
# s1-search-user-scenario.yaml

description: "User search scenario"
variables:
  userNameToSearchFor: "Cliff Diver"
actions:
  - name: search-user
    queryParams:
      userName: {{userNameToSearchFor}}

Nesting in queryParams does not really make sense, because the values will be encoded as strings. I think it might still be viable to simply encode as JSON strings, if nesting is used:

type: REST
service: my-service
endpoint: /api/users/search
method: GET
queryParams:
  user:
    name: "Cliff Diver"

will result in an HTTP call to

<base-url>/api/users/search?user=%7B%22name%22%3A%20%22Cliff%20Diver%22%7D
johannesloher commented 5 years ago

Fixed by #43