hurl
hurl copied to clipboard
Feature Request: support for shell interaction ( a pipe or "system() command)
It'd be useful for me, but I believe more general useful, to have some ability to read data from an OS shell command into a variable.
My major use case would be reading secrets from a password manager. But this seems more generally useful
For the time-being, we can set variables from the environment with the option --variable
.
For example, the secret variable will be set as follows:
$ hurl --variable "secret=$SECRET" test.hurl
We are not sure about adding a system() command. That could make the Hurl file less portable and readable between platforms and might also create securities vulnérabilities.
Thanks Just some feedback....
- invoking via variables is awkward. Automated tests require another wrapper.
- It shifts the security issue to the user
- CLI variables are inherently visible to others, which creates it's own security issue.
I suppose a web based password service captures from an external service would allow the credentials to be managed in the test file, but this seems awkward as well, as each test that needs credentials would need to be prefaced by an additional capture call outside of the testing domain.
It seems a shame, as the rest of the approach is so clean :-)
Why not using environment variables ? Having hurl auto-injecting variables prefixed with a constant suffix (HURL_xxx) ?
We thought about about using {{env.MYVAR}}
within a Hurl file to access the environment variable MYVAR
,
but we had not thought about the way around using the environment variable HURL_myvar
to set the variable myvar
in Hurl.
It seems indeed better this way.
Is it possible to add support for .env files?
You can already define variables in a properties file and pass it to Hurl with --variable-file
https://hurl.dev/docs/man-page.html#variables-file
@fabricereix We already have user asking for .env support (https://www.reddit.com/r/rust/comments/ksy5ul/hurl_100_a_command_line_tool_to_run_and_test_http/gil94nb/?utm_source=reddit&utm_medium=web2x&context=3) maybe we could add some support for it?
--variable-file
You can already define variables in a properties file and pass it to Hurl with
--variable-file
https://hurl.dev/docs/man-page.html#variables-file
Would you please update the link, I can't find the documentation on this.
Hi @mangelozzi
You can find information here https://hurl.dev/docs/templates.html#variables-file-option and https://hurl.dev/docs/manual.html#variables-file
The convention over configuration might be a good reason to support .env files. Besides, it does not have too much impact for Hurl (just the cli), I was just a bit septical about this "standard". Really, which major tools support it (besides nodejs)?
See also #526