Orange-OpenSource / hurl

Hurl, run and test HTTP requests with plain text.
https://hurl.dev
Apache License 2.0
12.95k stars 484 forks source link

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

Open fourjay opened 3 years ago

fourjay commented 3 years ago

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

fabricereix commented 3 years ago

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.

fourjay commented 3 years ago

Thanks Just some feedback....

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

tbolon commented 3 years ago

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

fabricereix commented 3 years ago

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.

riyadparvez commented 2 years ago

Is it possible to add support for .env files?

fabricereix commented 2 years ago

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

jcamiel commented 2 years ago

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

mangelozzi commented 11 months ago

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

jcamiel commented 11 months ago

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

fabricereix commented 11 months ago

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

jcamiel commented 10 months ago

See also #526