[wdspec] network.setExtraHeaders invalid.py: incorrect tests for header name and value
Categories
(Remote Protocol :: WebDriver BiDi, enhancement, P3)
Tracking
(Not tracked)
People
(Reporter: jdescottes, Assigned: matthewlchin1, Mentored, NeedInfo)
Details
(Keywords: good-first-bug, Whiteboard: [webdriver:backlog][lang=python])
In webdriver/tests/bidi/network/set_extra_headers/invalid.py, four tests build headers with a plain string as value, instead of a network.BytesValue object ({ type, value }):
test_params_headers_header_name_invalid_typetest_params_headers_header_name_invalid_valuetest_params_headers_header_value_invalid_typetest_params_headers_header_value_invalid_value
Because the header value is never a valid network.BytesValue, the command always fails with invalid argument, before the name or value rules are checked. The tests pass for the wrong reason. A browser that does not validate header names or values would still pass them.
We should wrap the values with NetworkStringValue(...) from webdriver.bidi.modules.network.
| Reporter | ||
Comment 1•28 days ago
|
||
I can mentor if someone wants to setup their environment and fix this, this should be quite easy.
| Assignee | ||
Comment 2•26 days ago
|
||
Hello, I'm Matt, I'd like to take this bug if it's still available.
This would be my first bug here, so I'd really appreciate any guidance on the approach. My rough plan is to wrap the header values in NetworkStringValue(...) in the four affected tests so they reach the name and value validation. A couple of things I'm unsure about:
- For the header_value_invalid_type test, what should the invalid cases look like once the wrapper is in place?
- Should this go through Phabricator in mozilla-central, or upstream to web-platform-tests first?
Thanks, and I'm happy to adjust the approach based on your feedback.
| Reporter | ||
Comment 3•26 days ago
|
||
Hi Matt and welcome!
You can upload patches to Phabricator, they will be upstreamed automatically to wpt afterwards.
First, quick update from the summary: only three of the four tests have a real issue here.
These three tests use a plain string as the header value. The command fails on the value type, before the name or value rules are checked:
- test_params_headers_header_name_invalid_type
- test_params_headers_header_name_invalid_value
- test_params_headers_header_value_invalid_value
test_params_headers_header_value_invalid_type is "fine" but it should use get_invalid_cases("dict") instead of get_invalid_cases("string")
For the others, I was looking at another test (webdriver/tests/bidi/network/continue_request/invalid.py), and we can probably follow the same strategy here and reuse the create_header helper. It always builds a valid header, and each test overrides only the field it checks:
- name tests: create_header(overrides={"name": value})
- test_params_headers_header_value_invalid_type: create_header(overrides={"value": value}) with get_invalid_cases("dict")
- test_params_headers_header_value_invalid_value: create_header(value_overrides={"value": value})
We could also update VALID_HEADERS to become [create_header()].
Assigning the bug to you.
| Reporter | ||
Comment 4•19 days ago
|
||
Hi Matt!
Just wanted to check back in case you needed any assistance to setup your environment.
Feel free to reach out on https://chat.mozilla.org
Description
•