pyresttest
pyresttest copied to clipboard
Passing in variables mentioned nowhere in documentation
I was struggling for a while to work out how i could pass variables from outside my yaml, in to pyresttest, almost concluding it could not be done as it is mentioned nowhere in any of your documentation.
It took running pyresttest --help in CLI to find you could do this:
pyresttest [URL] [file] --vars='{"key": "value"}'
This lets you use $key in your yaml to pass in your value, allowing you to use the same file for lots of different test cases.
Adding this as an issue in the hopes no one else will lose a day to this.
Hey there i was able to do this exactly as you said but when i tried to use this inside a bash script it can't be done. Here is the bash:
printf "input user:"
read USER
printf "input pass"
read -s PASS
vars="'{\"USERNAME\": \"$USER\", \"PASSWORD\": \"$PASS\"}'"
pyresttest url test.yaml --vars $vars
and the yaml file:
- body: {template: 'username=$USERNAME&password=$PASSWORD'}
If i do pyresttest url test.yaml --vars '{"USERNAME": "user", "PASSWORD": "pass"}'
on cmd it works perfectly
I don't know what am i doing wrong here