Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create [Options] section to use command line option per request #612

Closed
jcamiel opened this issue Jun 10, 2022 · 5 comments · Fixed by #624
Closed

Create [Options] section to use command line option per request #612

jcamiel opened this issue Jun 10, 2022 · 5 comments · Fixed by #624
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@jcamiel
Copy link
Collaborator

jcamiel commented Jun 10, 2022

In 1.6.1, Hurl has command line options that affect a whole file (i.e each entry of a test).

For instance, --insecure allows to by-pass certificate verification on all entries of a file.

We could add an [Options] section that will allow to set option per request.

For instance:

GET https://trusty.net
[Options]
insecure: true

HTTP/* 200


GET https://not-trusty.net

HTTP/* 200

Will by-pass certificate verification on https://trusty.net and will verify certificate on https://not-trusty.net.

We could expose all the relevant options (excluding those which are not, like --color).

The supported options could be:

GET https://example.org
[Options]
cacert: tmp/certificates/my-cert.cer
compressed: true
connect-timeout: 60
cookie: tmp/cookie-in.txt
cookie-jar: tmp/cookie-out.txt
file-root: /users/bob/tmp
location: true
include: true
insecure: true
ignore-asserts: true
max-redirs: 20
max-time: 30
proxy: localhost:8888
verbose: true

HTTP/* 200

Options that can already be defined per-request should not be included. For instance --user add basic authentifciation to each request.
As there is a [BasicAuth] section wich allows set basic authentification on a request, we don't need to support user in [Options].

Options excluded because there are not relevant per-request:

@jcamiel jcamiel added the enhancement New feature or request label Jun 10, 2022
@fabricereix
Copy link
Collaborator

This feature is very useful.
It could also set explicitly variables in a Hurl file (#533)

[Options]
variable: name=toto

@jcamiel jcamiel self-assigned this Jun 18, 2022
@jcamiel jcamiel linked a pull request Jun 19, 2022 that will close this issue
@jcamiel jcamiel added this to the 1.7.0 milestone Aug 7, 2022
@fabricereix fabricereix linked a pull request Sep 13, 2022 that will close this issue
@fabricereix fabricereix removed a link to a pull request Sep 13, 2022
@fourjay
Copy link

fourjay commented Sep 15, 2022

This is listed as added to the 1.7 release (yay)
But when trying it out I get

| [Options]
| the section is not valid. Valid values are Captures or Asserts

I'm using the release file for x86-64-linux
hurl-1.7.0-x86_64-linux.tar.gz

@jcamiel
Copy link
Collaborator Author

jcamiel commented Sep 15, 2022

Hi @fourjay can you provide your Hurl file ?
We're updating the docs on https://hurl.dev for the 1.7.0. But, just for your information, the [Options] sections are relative to a request, for instance:

GET https://foo.com
[Options]
insecure: true
variable: host=toot.com
HTTP/*

# Another request without options
GET http//bar.com

For the moment, you can not use the [Options] sections at the file level without any request. We're going to add it soon. So this Hurl file is not valid:

# Options for the whole file
[Options]
variable: host:sample.com

GET https://{{host}}
HTTP/*

But it'll be soon !

@fourjay
Copy link

fourjay commented Sep 15, 2022

Placement was the issue :-)
I'd placed the [Options]`` section after the HTTP/1.1```
It works when I put the [Options] directly after the GET request
Thank you!

FWIW, I use hurl for broad service testing, across our many unrelated web services.
The option to use insecure: true on a case by case basis is very helpful.
I know this use case is not the primary driver for the project, but, at least from my view, hurl is a very good match :-)

@jcamiel
Copy link
Collaborator Author

jcamiel commented Sep 15, 2022

Thanks for the feedback, always happy to hear how Hurl is used in the wild!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants