Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #8581: add extra subdomains for cookie tests #13272

Merged
merged 2 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tools/serve/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from six.moves import urllib
import uuid
from collections import defaultdict, OrderedDict
from itertools import chain, product
from multiprocessing import Process, Event

from localpaths import repo_root
Expand Down Expand Up @@ -720,6 +721,9 @@ def build_config(override_path=None, **kwargs):

return rv

def _make_subdomains_product(s, depth=2):
return set(u".".join(x) for x in chain(*(product(s, repeat=i) for i in range(1, depth+1))))

_subdomains = {u"www",
u"www1",
u"www2",
Expand All @@ -728,6 +732,10 @@ def build_config(override_path=None, **kwargs):

_not_subdomains = {u"nonexistent"}

_subdomains = _make_subdomains_product(_subdomains)

_not_subdomains = _make_subdomains_product(_not_subdomains)


class ConfigBuilder(config.ConfigBuilder):
"""serve config
Expand Down
11 changes: 10 additions & 1 deletion tools/serve/test_serve.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import pickle
import platform
import os

import pytest

Expand Down Expand Up @@ -75,3 +76,11 @@ def test_pickle():
# Ensure that the config object can be pickled
with ConfigBuilder() as c:
pickle.dumps(c)


def test_config_json_length():
# we serialize the config as JSON for pytestrunner and put it in an env
# variable, which on Windows must have a length <= 0x7FFF (int16)
with ConfigBuilder() as c:
data = json.dumps(c.as_dict())
assert len(data) <= 0x7FFF
11 changes: 11 additions & 0 deletions tools/wptserve/tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import logging
import pickle

Expand Down Expand Up @@ -43,6 +44,16 @@ def test_logger_preserved():
assert c.logger is logger


def test_as_dict():
with config.ConfigBuilder() as c:
assert c.as_dict() is not None


def test_as_dict_is_json():
with config.ConfigBuilder() as c:
assert json.dumps(c.as_dict()) is not None


def test_init_basic_prop():
with config.ConfigBuilder(browser_host="foo.bar") as c:
assert c.browser_host == "foo.bar"
Expand Down
4 changes: 3 additions & 1 deletion tools/wptserve/wptserve/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def json_types(obj):
return {key: json_types(value) for key, value in iteritems(obj)}
if (isinstance(obj, string_types) or
isinstance(obj, integer_types) or
isinstance(obj, float)):
isinstance(obj, float) or
isinstance(obj, bool) or
obj is None):
return obj
if isinstance(obj, list) or hasattr(obj, "__iter__"):
return [json_types(value) for value in obj]
Expand Down