diff options
Diffstat (limited to 'tst')
-rw-r--r-- | tst/test_check.py | 6 | ||||
-rw-r--r-- | tst/test_listen.py | 12 |
2 files changed, 10 insertions, 8 deletions
diff --git a/tst/test_check.py b/tst/test_check.py index b07259f..aeb4a9e 100644 --- a/tst/test_check.py +++ b/tst/test_check.py @@ -60,13 +60,13 @@ async def test_check(domain, ca_name, not_after, after, trust_ca): summary = await get_cert_summary((domain, port), after, ca if trust_ca else None) if not trust_ca: - assert summary[0] is None + assert summary[1] is None assert 'self-signed certificate' in summary[5] elif not_after == SECONDS_AGO: - assert summary[0] is None + assert summary[1] is None assert 'certificate has expired' in summary[5] elif not printable(ca_name): - assert summary[0] is None + assert summary[1] is None assert 'control character' in summary[5] elif not_after > after: assert summary is None diff --git a/tst/test_listen.py b/tst/test_listen.py index bab9072..61929c8 100644 --- a/tst/test_listen.py +++ b/tst/test_listen.py @@ -6,7 +6,7 @@ from asyncio import open_unix_connection, start_unix_server from contextlib import asynccontextmanager, contextmanager from copy import deepcopy -from datetime import datetime +from datetime import datetime, timezone from email.parser import BytesHeaderParser from functools import partial from http import HTTPMethod @@ -19,7 +19,7 @@ from xml.etree.ElementTree import (XML, XMLParser, indent, from hypothesis import HealthCheck, given, settings from hypothesis.strategies import (booleans, composite, data, - datetimes, from_type, integers, + datetimes, from_type, integers, just, sampled_from, sets, text, uuids) from hypothesis.provisional import domains, urls from pytest import raises @@ -30,6 +30,7 @@ from scadere.listen import (handle, is_subdomain, path, parse_summary, ATOM_NAMESPACES = {'': 'http://www.w3.org/2005/Atom'} XHTML_NAMESPACES = {'': 'http://www.w3.org/1999/xhtml'} +UTC_DATETIMES = datetimes(timezones=just(timezone.utc)) def ports(): @@ -84,8 +85,8 @@ def test_xml_unsupported_type(tag, child): def certificates(draw): """Return a Hypothesis strategy for certificate summaries.""" valid = draw(booleans()) - not_before = draw(datetimes()).isoformat() if valid else 'N/A' - not_after = draw(datetimes()).isoformat() + not_before = draw(UTC_DATETIMES).isoformat() + not_after = draw(UTC_DATETIMES).isoformat() if valid else 'N/A' hostname = draw(domains()) port = draw(ports()) number = draw(serials()) if valid else draw(uuids(version=4)).int @@ -210,7 +211,8 @@ def unique_netlocs(summaries): @given(urls().filter(is_base_url).filter(has_usual_path), sets(certificates(), min_size=1).map(unique_netlocs), text().filter(printable)) -@settings(suppress_health_check=[HealthCheck.too_slow]) +@settings(suppress_health_check=(HealthCheck.filter_too_much, + HealthCheck.too_slow)) async def test_content(base_url, certs, title): base_path = urlsplit(base_url).path with tmp_cert_file(certs) as cert_file: |