hurl icon indicating copy to clipboard operation
hurl copied to clipboard

Feature Request: support for shell interaction ( a pipe or "system() command)

Open fourjay opened this issue 3 years ago • 11 comments

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

fourjay avatar Oct 11 '21 16:10 fourjay

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.

fabricereix avatar Oct 11 '21 18:10 fabricereix

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 :-)

fourjay avatar Oct 11 '21 20:10 fourjay

Why not using environment variables ? Having hurl auto-injecting variables prefixed with a constant suffix (HURL_xxx) ?

tbolon avatar Oct 12 '21 14:10 tbolon

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.

fabricereix avatar Oct 16 '21 19:10 fabricereix

Is it possible to add support for .env files?

riyadparvez avatar Jan 25 '22 21:01 riyadparvez

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 avatar Jan 26 '22 07:01 fabricereix

@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?

jcamiel avatar Jan 26 '22 10:01 jcamiel

--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.

mangelozzi avatar Nov 01 '23 08:11 mangelozzi

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

jcamiel avatar Nov 01 '23 09:11 jcamiel

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)?

fabricereix avatar Nov 01 '23 09:11 fabricereix

See also #526

jcamiel avatar Dec 21 '23 15:12 jcamiel