venom icon indicating copy to clipboard operation
venom copied to clipboard

exec: add a 'stdin' attribute

Open cdevienne opened this issue 1 year ago • 0 comments

If set, the value is written to the script stdin. This avoid the need to use 'echo' in the script, which makes thing clearer.

It is also particularly useful in the following case (probably other issues with variable substitution):

name: simple_test
vars:
  payload: {"s": "\n"}
testcases:
- name: simple_test
  steps:
  - type: exec
    script: echo {{.payload | toJSON}} | jq .
    assertions:
    - result.code MustEqual 0

This will fail because the \n is not properly escaped.

Using the new stdin attribute solves the issue:

name: simple_test
vars:
  payload: {"s": "\n"}
testcases:
- name: simple_test
  steps:
  - type: exec
    stdin: {{.payload | toJSON}}
    script: jq .
    assertions:
    - result.code MustEqual 0

cdevienne avatar Feb 19 '24 18:02 cdevienne