Bug 1595811 [wpt PR 20213] - WebKitWebDriver: pass list of domains where WPT certificate is valid (#19233), a=testonly
authorCarlos Alberto Lopez Perez <clopez@igalia.com>
Mon, 25 Nov 2019 19:15:30 +0000
changeset 504499 479bffe0c3699ed8f6c520b6923ed7d753ea362d
parent 504498 c6a1e2cdb4ba24ddf6fa5c639883e4462c6a426d
child 504500 4c68e0b28698d3b1c8f8bf6454c17ef90e62b4ab
push id36862
push useraciure@mozilla.com
push dateFri, 29 Nov 2019 21:26:53 +0000
treeherdermozilla-central@b4b10ae558b9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1595811, 20213, 19233
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1595811 [wpt PR 20213] - WebKitWebDriver: pass list of domains where WPT certificate is valid (#19233), a=testonly Automatic update from web-platform-tests WebKitWebDriver: pass list of domains where WPT certificate is valid (#20213) * WebKitWebDriver can be informed of a list of domains where a specific certificate should be valid. See https://trac.webkit.org/r233035 * Use that feature to configure the custom certificate for WPT tests in all domains and subdomains that will be used for testing. * Enable it on all the current 3 WebKitWebDriver based product browsers: webkit, webkitgtk_minibrowser and epiphany * Add also an unit test to check that the dictionary gets built as expected. Related issue: #19233 -- wpt-commits: 513f82848f14ce777702a819f91c9f41c132af91 wpt-pr: 20213
testing/web-platform/tests/tools/wptrunner/tox.ini
testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/base.py
testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/epiphany.py
testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/webkit.py
testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/webkitgtk_minibrowser.py
testing/web-platform/tests/tools/wptrunner/wptrunner/tests/browsers/test_webkitgtk.py
--- a/testing/web-platform/tests/tools/wptrunner/tox.ini
+++ b/testing/web-platform/tests/tools/wptrunner/tox.ini
@@ -1,13 +1,13 @@
 [pytest]
 xfail_strict=true
 
 [tox]
-envlist = py27-{base,chrome,edge,firefox,ie,opera,safari,sauce,servo},py36-base
+envlist = py27-{base,chrome,edge,firefox,ie,opera,safari,sauce,servo,webkit,webkitgtk_minibrowser,epiphany},py36-base
 skip_missing_interpreters = true
 
 [testenv]
 deps =
      pytest>=2.9
      pytest-cov
      pytest-xdist
      mock
@@ -15,15 +15,18 @@ deps =
      chrome: -r{toxinidir}/requirements_chrome.txt
      edge: -r{toxinidir}/requirements_edge.txt
      firefox: -r{toxinidir}/requirements_firefox.txt
      ie: -r{toxinidir}/requirements_ie.txt
      opera: -r{toxinidir}/requirements_opera.txt
      safari: -r{toxinidir}/requirements_safari.txt
      sauce: -r{toxinidir}/requirements_sauce.txt
      servo: -r{toxinidir}/requirements_servo.txt
+     webkit: -r{toxinidir}/requirements_webkit.txt
+     webkitgtk_minibrowser: -r{toxinidir}/requirements_webkit.txt
+     epiphany: -r{toxinidir}/requirements_epiphany.txt
 
 commands = pytest {posargs}
 
 setenv = CURRENT_TOX_ENV = {envname}
 
 passenv =
   TASKCLUSTER_ROOT_URL
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/base.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/base.py
@@ -69,16 +69,24 @@ def maybe_add_args(required_args, curren
             if not any(item.startswith(required_arg_prefix) for item in current_args):
                 current_args.append(required_arg)
         else:
             if required_arg not in current_args:
                 current_args.append(required_arg)
     return current_args
 
 
+def certificate_domain_list(list_of_domains, certificate_file):
+    """Build a list of domains where certificate_file should be used"""
+    cert_list = []
+    for domain in list_of_domains:
+        cert_list.append({"host": domain, "certificateFile": certificate_file})
+    return cert_list
+
+
 def get_free_port():
     """Get a random unbound port"""
     while True:
         s = socket.socket()
         try:
             s.bind(("127.0.0.1", 0))
         except socket.error:
             continue
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/epiphany.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/epiphany.py
@@ -1,9 +1,9 @@
-from .base import get_timeout_multiplier, maybe_add_args   # noqa: F401
+from .base import get_timeout_multiplier, maybe_add_args, certificate_domain_list  # noqa: F401
 from .webkit import WebKitBrowser
 from ..executors import executor_kwargs as base_executor_kwargs
 from ..executors.executorwebdriver import (WebDriverTestharnessExecutor,  # noqa: F401
                                            WebDriverRefTestExecutor)  # noqa: F401
 from ..executors.executorwebkit import WebKitDriverWdspecExecutor  # noqa: F401
 
 __wptrunner__ = {"product": "epiphany",
                  "check_args": "check_args",
@@ -39,19 +39,17 @@ def capabilities(server_config, **kwargs
 
     return {
         "browserName": "Epiphany",
         "browserVersion": "3.31.4",  # First version to support automation
         "platformName": "ANY",
         "webkitgtk:browserOptions": {
             "binary": kwargs["binary"],
             "args": args,
-            "certificates": [
-                {"host": server_config["browser_host"],
-                 "certificateFile": kwargs["host_cert_path"]}]}}
+            "certificates": certificate_domain_list(server_config.domains_set, kwargs["host_cert_path"])}}
 
 
 def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
                     **kwargs):
     executor_kwargs = base_executor_kwargs(test_type, server_config,
                                            cache_manager, run_info_data, **kwargs)
     executor_kwargs["close_after_done"] = True
     executor_kwargs["capabilities"] = capabilities(server_config, **kwargs)
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/webkit.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/webkit.py
@@ -1,10 +1,10 @@
 from .base import Browser, ExecutorBrowser, require_arg
-from .base import get_timeout_multiplier   # noqa: F401
+from .base import get_timeout_multiplier, certificate_domain_list  # noqa: F401
 from ..executors import executor_kwargs as base_executor_kwargs
 from ..executors.executorwebdriver import (WebDriverTestharnessExecutor,  # noqa: F401
                                            WebDriverRefTestExecutor)  # noqa: F401
 from ..executors.executorwebkit import WebKitDriverWdspecExecutor  # noqa: F401
 from ..webdriver_server import WebKitDriverServer
 
 
 __wptrunner__ = {"product": "webkit",
@@ -42,19 +42,17 @@ def capabilities_for_port(server_config,
 
         return {
             "browserName": "MiniBrowser",
             "browserVersion": "2.20",
             "platformName": "ANY",
             browser_options_key: {
                 "binary": kwargs["binary"],
                 "args": kwargs.get("binary_args", []),
-                "certificates": [
-                    {"host": server_config["browser_host"],
-                     "certificateFile": kwargs["host_cert_path"]}]}}
+                "certificates": certificate_domain_list(server_config.domains_set, kwargs["host_cert_path"])}}
 
     return {}
 
 
 def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
                     **kwargs):
     executor_kwargs = base_executor_kwargs(test_type, server_config,
                                            cache_manager, run_info_data, **kwargs)
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/webkitgtk_minibrowser.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/webkitgtk_minibrowser.py
@@ -1,9 +1,9 @@
-from .base import get_timeout_multiplier, maybe_add_args   # noqa: F401
+from .base import get_timeout_multiplier, maybe_add_args, certificate_domain_list  # noqa: F401
 from .webkit import WebKitBrowser
 from ..executors import executor_kwargs as base_executor_kwargs
 from ..executors.executorwebdriver import (WebDriverTestharnessExecutor,  # noqa: F401
                                            WebDriverRefTestExecutor)  # noqa: F401
 from ..executors.executorwebkit import WebKitDriverWdspecExecutor  # noqa: F401
 
 __wptrunner__ = {"product": "webkitgtk_minibrowser",
                  "check_args": "check_args",
@@ -43,19 +43,17 @@ def capabilities(server_config, **kwargs
                             "--enable-webaudio=true"]
     args = kwargs.get("binary_args", [])
     args = maybe_add_args(browser_required_args, args)
     return {
         "browserName": "MiniBrowser",
         "webkitgtk:browserOptions": {
             "binary": kwargs["binary"],
             "args": args,
-            "certificates": [
-                {"host": server_config["browser_host"],
-                 "certificateFile": kwargs["host_cert_path"]}]}}
+            "certificates": certificate_domain_list(server_config.domains_set, kwargs["host_cert_path"])}}
 
 
 def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
                     **kwargs):
     executor_kwargs = base_executor_kwargs(test_type, server_config,
                                            cache_manager, run_info_data, **kwargs)
     executor_kwargs["close_after_done"] = True
     executor_kwargs["capabilities"] = capabilities(server_config, **kwargs)
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/tests/browsers/test_webkitgtk.py
@@ -0,0 +1,57 @@
+from os.path import join, dirname
+
+import pytest
+
+from wptserve.config import ConfigBuilder
+from ..base import active_products
+from wptrunner import environment, products
+
+test_paths = {"/": {"tests_path": join(dirname(__file__), "..", "..", "..", "..", "..")}}  # repo root
+environment.do_delayed_imports(None, test_paths)
+
+
+@active_products("product")
+def test_webkitgtk_certificate_domain_list(product):
+
+    def domain_is_inside_certificate_list_cert(domain_to_find, webkitgtk_certificate_list, cert_file):
+        for domain in webkitgtk_certificate_list:
+            if domain["host"] == domain_to_find and domain["certificateFile"] == cert_file:
+                return True
+        return False
+
+    if product not in ["epiphany", "webkit", "webkitgtk_minibrowser"]:
+        pytest.skip("%s doesn't support certificate_domain_list" % product)
+
+    (check_args,
+     target_browser_cls, get_browser_kwargs,
+     executor_classes, get_executor_kwargs,
+     env_options, get_env_extras, run_info_extras) = products.load_product({}, product)
+
+    cert_file = "/home/user/wpt/tools/certs/cacert.pem"
+    valid_domains_test = ["a.example.org", "b.example.org", "example.org",
+                          "a.example.net", "b.example.net", "example.net"]
+    invalid_domains_test = ["x.example.org", "y.example.org", "example.it",
+                            "x.example.net", "y.example.net", "z.example.net"]
+    kwargs = {}
+    kwargs["timeout_multiplier"] = 1
+    kwargs["debug_info"] = None
+    kwargs["host_cert_path"] = cert_file
+    kwargs["webkit_port"] = "gtk"
+    kwargs["binary"] = None
+    kwargs["webdriver_binary"] = None
+    with ConfigBuilder(browser_host="example.net",
+                       alternate_hosts={"alt": "example.org"},
+                       subdomains={"a", "b"},
+                       not_subdomains={"x", "y"}) as env_config:
+
+        executor_args = get_executor_kwargs(None, env_config, None, None, **kwargs)
+        assert('capabilities' in executor_args)
+        assert('webkitgtk:browserOptions' in executor_args['capabilities'])
+        assert('certificates' in executor_args['capabilities']['webkitgtk:browserOptions'])
+        cert_list = executor_args['capabilities']['webkitgtk:browserOptions']['certificates']
+        for valid_domain in valid_domains_test:
+            assert(domain_is_inside_certificate_list_cert(valid_domain, cert_list, cert_file))
+            assert(not domain_is_inside_certificate_list_cert(valid_domain, cert_list, cert_file + ".backup_non_existent"))
+        for invalid_domain in invalid_domains_test:
+            assert(not domain_is_inside_certificate_list_cert(invalid_domain, cert_list, cert_file))
+            assert(not domain_is_inside_certificate_list_cert(invalid_domain, cert_list, cert_file + ".backup_non_existent"))