summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/mozilla/tests/webdriver/classic/new_session/invalid.py
blob: dc7a0caee9acb952fb63706113eae97cd7af1009 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from copy import deepcopy

import pytest
from tests.support.asserts import assert_error


@pytest.mark.parametrize(
    "headers",
    [
        {"origin": "http://localhost"},
        {"origin": "http://localhost:8000"},
        {"origin": "http://127.0.0.1"},
        {"origin": "http://127.0.0.1:8000"},
        {"origin": "null"},
        {"ORIGIN": "https://example.org"},
        {"host": "example.org:4444"},
        {"Host": "example.org"},
        {"host": "localhost:80"},
        {"host": "localhost"},
        {"content-type": "application/x-www-form-urlencoded"},
        {"content-type": "multipart/form-data"},
        {"content-type": "text/plain"},
        {"Content-TYPE": "APPLICATION/x-www-form-urlencoded"},
        {"content-type": "MULTIPART/FORM-DATA"},
        {"CONTENT-TYPE": "TEXT/PLAIN"},
        {"content-type": "text/plain ; charset=utf-8"},
        {"content-type": "text/plain;foo"},
        {"content-type": "text/PLAIN  ;  foo;charset=utf8"},
    ],
)
def test_invalid(new_session, configuration, headers):
    response, _ = new_session(
        {"capabilities": {"alwaysMatch": dict(configuration["capabilities"])}},
        headers=headers,
    )
    assert_error(response, "unknown error")


@pytest.mark.parametrize(
    "argument",
    [
        "--marionette",
        "--remote-debugging-port",
        "--remote-allow-hosts",
        "--remote-allow-origins",
    ],
)
def test_forbidden_arguments(configuration, new_session, argument):
    capabilities = deepcopy(configuration["capabilities"])
    capabilities["moz:firefoxOptions"]["args"] = [argument]

    response, _ = new_session({"capabilities": {"alwaysMatch": capabilities}})
    assert_error(response, "invalid argument")