-
Notifications
You must be signed in to change notification settings - Fork 526
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
Add an integration test for --header option #3504
Comments
@jcamiel I'll take this one. Might as well😆 |
@jcamiel Hello! I just started working on this. Just want to give some feedback on the documentation for integration test: The docs didn't mention that we need a release build before running the test script. I had to dig around a bit to figure that out. Here's what I did:
Not a huge deal, but newbies like me might get lost there 😆 |
Hi @theoforger There is no newbie here every feedback is good, the documentation should be crystal clear; if not it should be updated! In fact, you don't need to make a release to run the integration test. You can just build Hurl in debug and modify your $ cargo build
$ export PATH=target/debug:$PATH (In the CI/CD it's the release build that is ran but generally bug that happens in release and not in debug are extremely rare) I will update the doc to better explain. Another thing to note, you can just run the integration tests that run on 8000, the other tests will be run on CI/CD $ cd integration/hurl/
$ python3 server.py Other port are for specific tests (like ssl, unix_socket etc) |
@jcamiel Thanks! This helped a lot 🙏 Another question: We had a conversation on how |
Yes it's a good idea, |
What I do generally is try to see if there are "uncovered" lines of code : in red you can see which part of the code in not run by an integration test (for instance this line is, for the moment red but will be green after your PR https://orange-opensource.github.io/hurl/coverage/packages/hurl/src/http/headers_helper.rs.html#71). The current coverage is ~90% so it's rather difficult to fill those red lines! |
@jcamiel So I just discovered an edge case: If we have the same header in both the hurl file and from For example: Scenario 1
$ hurl --header "Some-Header: some-value" file.hurl Scenario 2
$ hurl --header "Some-Header:" file.hurl In both cases, the requests would contain the header I wonder what's the expected behavior here? I can totally see someone using this setup when they want to set a header globally but exclude it for certain requests. |
Interesting! I'm not in front of my computer so I can't check what we've implemented. Disregard of the current behavior, I would expect this call
$ hurl --header "Some-Header: some-value" test.hurl To be equivalent to this command $ hurl --header "Some-Header:" --header "Some-Header: some-value" test.hurl And also to be equivalent to this Hurl file:
(~the order) That is: producing 2 requests headers. I vaguely remember having some edge code for empty headers but I have to check the code. I will check what we've coded tomorrow! @fabricereix any idea on @theoforger question? |
So I've tested curl and read the libcurl doc CURLOPT_HTTPHEADER There are two types of headers (in my comprehension):
When a user header is set empty with curl When a "libcurl" header is set to empty with curl We need to be consistent with curl and add try to delegate the logic to libcurl. So in scenario 1:
$ hurl --header "Some-Header: some-value" file.hurl will result in a single request header "Some-Header: some-value" In scenario 2:
$ hurl --header "Some-Header:" file.hurl will also result in a single request header "Some-Header: some-value" It's coherent with curl so everything is OK. What we've not tested in our integration test is some variation with "libcurl" header For instance, this file:
Will remove the Host header from the request headers. We can also do this (now!), with this command: $ hurl --header "Host:" test.hurl So far so good for me! |
I'm not sure about being consistent with curl for this one.
It looks more to an empty string to me. |
Ok @fabricereix to be discussed. @theoforger this will not change anything with the PR See #3536 |
Add an integration test for --header with this file:
integration/hurl/tests_ok/add_header.hurl
and the script file
integration/hurl/tests_ok/add_header.sh
The Flask file
integration/hurl/tests_ok/add_header.py
should have 3 endpointadd_header_0
,add_header_1
,add_header_2
that test request headers do contain the right headers.The text was updated successfully, but these errors were encountered: