mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 00:32:11 +00:00
Bug 1880477 - [wdspec] Add tests for invalid arguments for all provideResponse parameters r=webdriver-reviewers,Sasha
Depends on D201969 Differential Revision: https://phabricator.services.mozilla.com/D201970
This commit is contained in:
parent
6d265c62b9
commit
aed1e8f6a3
@ -184,7 +184,7 @@ async def test_params_cookies_cookie_value_max_age_invalid_value(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [None, None, False, 42, {}, []])
|
||||
@pytest.mark.parametrize("value", [None, False, 42, {}, []])
|
||||
async def test_params_cookies_cookie_value_value_invalid_type(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
|
@ -1,11 +1,350 @@
|
||||
# META: timeout=long
|
||||
|
||||
import pytest
|
||||
import webdriver.bidi.error as error
|
||||
|
||||
from .. import PAGE_EMPTY_TEXT, RESPONSE_COMPLETED_EVENT
|
||||
from .. import (
|
||||
create_cookie_header,
|
||||
create_header,
|
||||
PAGE_EMPTY_TEXT,
|
||||
RESPONSE_COMPLETED_EVENT,
|
||||
)
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [False, 42, "foo", []])
|
||||
async def test_params_body_invalid_type(setup_blocked_request, bidi_session, value):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(request=request, body=value)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [{}, {"type": "string"}, {"value": "foo"}])
|
||||
async def test_params_body_invalid_value(setup_blocked_request, bidi_session, value):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(request=request, body=value)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [None, False, 42, {}, []])
|
||||
async def test_params_body_type_invalid_type(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request, body={"type": value, "value": "foo"}
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", ["", "foo"])
|
||||
async def test_params_body_type_invalid_value(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request, body={"type": value, "value": "foo"}
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [None, False, 42, {}, []])
|
||||
async def test_params_body_value_invalid_type(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request, body={"type": "string", "value": value}
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [False, 42, "foo", {}])
|
||||
async def test_params_cookies_invalid_type(setup_blocked_request, bidi_session, value):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(request=request, cookies=value)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [None, False, 42, "foo", []])
|
||||
async def test_params_cookies_cookie_invalid_type(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(request=request, cookies=[value])
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"value",
|
||||
[{}, {"name": "name"}, {"value": {"type": "string", "value": "foo"}}],
|
||||
ids=[
|
||||
"empty object",
|
||||
"missing value",
|
||||
"missing name",
|
||||
],
|
||||
)
|
||||
async def test_params_cookies_cookie_invalid_value(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
cookies=[value],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [None, False, 42, {}, []])
|
||||
async def test_params_cookies_cookie_name_invalid_type(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
cookies=[create_cookie_header(overrides={"name": value})],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [None, False, 42, "foo", []])
|
||||
async def test_params_cookies_cookie_value_invalid_type(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
cookies=[create_cookie_header(overrides={"value": value})],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [{}, {"type": "string"}, {"value": "foo"}])
|
||||
async def test_params_cookies_cookie_value_invalid_value(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
cookies=[create_cookie_header(overrides={"value": value})],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [None, False, 42, {}, []])
|
||||
async def test_params_cookies_cookie_value_type_invalid_type(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
cookies=[create_cookie_header(value_overrides={"type": value})],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", ["", "foo"])
|
||||
async def test_params_cookies_cookie_value_type_invalid_value(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
cookies=[create_cookie_header(value_overrides={"type": value})],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("property", ["domain", "expiry", "path", "sameSite"])
|
||||
@pytest.mark.parametrize("value", [False, 42, {}, []])
|
||||
async def test_params_cookies_cookie_value_string_properties_invalid_type(
|
||||
setup_blocked_request, bidi_session, property, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
cookies=[create_cookie_header(overrides={property: value})],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", ["", "foo"])
|
||||
async def test_params_cookies_cookie_value_same_site_invalid_value(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
cookies=[create_cookie_header(overrides={"sameSite": value})],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("property", ["httpOnly", "secure"])
|
||||
@pytest.mark.parametrize("value", [42, "foo", {}, []])
|
||||
async def test_params_cookies_cookie_value_bool_properties_invalid_type(
|
||||
setup_blocked_request, bidi_session, property, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
cookies=[create_cookie_header(overrides={property: value})],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [False, "foo", {}, []])
|
||||
async def test_params_cookies_cookie_value_max_age_invalid_type(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
cookies=[create_cookie_header(overrides={"maxAge": value})],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [4.3])
|
||||
async def test_params_cookies_cookie_value_max_age_invalid_value(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
cookies=[create_cookie_header(overrides={"maxAge": value})],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [None, False, 42, {}, []])
|
||||
async def test_params_cookies_cookie_value_value_invalid_type(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
cookies=[create_cookie_header(value_overrides={"value": value})],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [False, 42, "foo", {}])
|
||||
async def test_params_headers_invalid_type(setup_blocked_request, bidi_session, value):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(request=request, headers=value)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [None, False, 42, "foo", []])
|
||||
async def test_params_headers_header_invalid_type(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(request=request, headers=[value])
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [None, False, 42, {}, []])
|
||||
async def test_params_headers_header_name_invalid_type(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
headers=[create_header(overrides={"name": value})],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [None, False, 42, "foo", []])
|
||||
async def test_params_headers_header_value_invalid_type(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
headers=[create_header(overrides={"value": value})],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [{}, {"type": "string"}, {"value": "foo"}])
|
||||
async def test_params_headers_header_value_invalid_value(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
headers=[create_header(overrides={"value": value})],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [None, False, 42, {}, []])
|
||||
async def test_params_headers_header_value_type_invalid_type(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
headers=[create_header(value_overrides={"type": value})],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", ["", "foo"])
|
||||
async def test_params_headers_header_value_type_invalid_value(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
headers=[create_header(value_overrides={"type": value})],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [None, False, 42, {}, []])
|
||||
async def test_params_headers_header_value_value_invalid_type(
|
||||
setup_blocked_request, bidi_session, value
|
||||
):
|
||||
request = await setup_blocked_request("beforeRequestSent")
|
||||
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
await bidi_session.network.provide_response(
|
||||
request=request,
|
||||
headers=[create_header(value_overrides={"value": value})],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [None, False, 42, {}, []])
|
||||
async def test_params_request_invalid_type(bidi_session, value):
|
||||
with pytest.raises(error.InvalidArgumentException):
|
||||
|
Loading…
Reference in New Issue
Block a user