You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Request header values are reused between tests when the headers for one stage have been modified by the test function.
Expected behaviour
Request headers should be reinitialized with correct values for each stage.
Details
I'm trying to add a default Host header to tests using the following code in my test funtion:
def test_default(ruleset, test, destaddr, port, protocol):
runner = testrunner.TestRunner()
try:
for stage in test.stages:
print("\n[+] stage.input.headers:", id(stage.input.headers), "{}".format(stage.input.headers))
if 'Host' not in stage.input.headers:
stage.input.headers = {'Host': 'example.com'} | stage.input.headers
print("[+] stage.input.headers:", id(stage.input.headers), "{}".format(stage.input.headers))
runner.run_stage(stage, None)
This works fine for the first test, but all the remaining tests fail, seemingly because they will reuse the exact same headers as the first test. I.e. Content-Length, Content-Type etc are not recalculated because they are already set before the test function is invoked.
There's no headers specified in the test declaration:
Notice that the id of the headers dictionary before adding the Host header is the same in all stages, and that the content length is not recalculated after the first stage has run.
Adding a host header to the tests input sections, works as expected:
Observed behaviour
Request header values are reused between tests when the headers for one stage have been modified by the test function.
Expected behaviour
Request headers should be reinitialized with correct values for each stage.
Details
I'm trying to add a default Host header to tests using the following code in my test funtion:
This works fine for the first test, but all the remaining tests fail, seemingly because they will reuse the exact same headers as the first test. I.e.
Content-Length
,Content-Type
etc are not recalculated because they are already set before the test function is invoked.There's no headers specified in the test declaration:
Running the above tests give the following:
Notice that the
id
of the headers dictionary before adding the Host header is the same in all stages, and that the content length is not recalculated after the first stage has run.Adding a host header to the tests input sections, works as expected:
In this case the headers dictionary for each stage has a different id, and the contents are calculated correctly.
The text was updated successfully, but these errors were encountered: