| 1 |
from copy import deepcopy |
| 2 |
|
| 3 |
import pytest |
| 4 |
from tests.support.asserts import assert_error |
| 5 |
|
| 6 |
|
| 7 |
@pytest.mark.parametrize( |
| 8 |
"headers", |
| 9 |
[ |
| 10 |
{"origin": "http://localhost"}, |
| 11 |
{"origin": "http://localhost:8000"}, |
| 12 |
{"origin": "http://127.0.0.1"}, |
| 13 |
{"origin": "http://127.0.0.1:8000"}, |
| 14 |
{"origin": "null"}, |
| 15 |
{"ORIGIN": "https://example.org"}, |
| 16 |
{"host": "example.org:4444"}, |
| 17 |
{"Host": "example.org"}, |
| 18 |
{"host": "localhost:80"}, |
| 19 |
{"host": "localhost"}, |
| 20 |
{"content-type": "application/x-www-form-urlencoded"}, |
| 21 |
{"content-type": "multipart/form-data"}, |
| 22 |
{"content-type": "text/plain"}, |
| 23 |
{"Content-TYPE": "APPLICATION/x-www-form-urlencoded"}, |
| 24 |
{"content-type": "MULTIPART/FORM-DATA"}, |
| 25 |
{"CONTENT-TYPE": "TEXT/PLAIN"}, |
| 26 |
{"content-type": "text/plain ; charset=utf-8"}, |
| 27 |
{"content-type": "text/plain;foo"}, |
| 28 |
{"content-type": "text/PLAIN ; foo;charset=utf8"}, |
| 29 |
], |
| 30 |
) |
| 31 |
def test_invalid(new_session, configuration, headers): |
| 32 |
response, _ = new_session( |
| 33 |
{"capabilities": {"alwaysMatch": dict(configuration["capabilities"])}}, |
| 34 |
headers=headers, |
| 35 |
) |
| 36 |
assert_error(response, "unknown error") |
| 37 |
|
| 38 |
|
| 39 |
@pytest.mark.parametrize( |
| 40 |
"argument", |
| 41 |
[ |
| 42 |
"--marionette", |
| 43 |
"--remote-debugging-port", |
| 44 |
"--remote-allow-hosts", |
| 45 |
"--remote-allow-origins", |
| 46 |
], |
| 47 |
) |
| 48 |
def test_forbidden_arguments(configuration, new_session, argument): |
| 49 |
capabilities = deepcopy(configuration["capabilities"]) |
| 50 |
capabilities["moz:firefoxOptions"]["args"] = [argument] |
| 51 |
|
| 52 |
response, _ = new_session({"capabilities": {"alwaysMatch": capabilities}}) |
| 53 |
assert_error(response, "invalid argument") |