about summary refs log tree commit diff
path: root/tst/test_listen.py
diff options
context:
space:
mode:
Diffstat (limited to 'tst/test_listen.py')
-rw-r--r--tst/test_listen.py30
1 files changed, 13 insertions, 17 deletions
diff --git a/tst/test_listen.py b/tst/test_listen.py
index 55a69e0..ee95c3c 100644
--- a/tst/test_listen.py
+++ b/tst/test_listen.py
@@ -37,7 +37,8 @@ from hypothesis.provisional import domains, urls
 from pytest import raises
 
 from scadere.check import base64_from_str, printable
-from scadere.listen import handle, is_subdomain, path, with_trailing_slash, xml
+from scadere.listen import (handle, is_subdomain, path,
+                            str_from_base64, with_trailing_slash, xml)
 
 ATOM_NAMESPACES = {'': 'http://www.w3.org/2005/Atom'}
 XHTML_NAMESPACES = {'': 'http://www.w3.org/1999/xhtml'}
@@ -58,18 +59,13 @@ def base64s():
     return text().filter(printable).map(base64_from_str)
 
 
-@given(domains(), ports(), base64s(), serials())
-def test_path_with_cert(hostname, port, issuer, serial):
-    r = path(hostname, port, issuer, serial).split('/')
+@given(domains(), ports(), serials(), text())
+def test_path(hostname, port, number, string):
+    r = path(hostname, port, number, string).split('/')
     assert r[0] == hostname
     assert int(r[1]) == port
-    assert r[2] == issuer
-    assert int(r[3]) == serial
-
-
-@given(domains(), ports(), base64s())
-def test_path_without_cert(hostname, port, error):
-    assert path(hostname, port, error, 'N/A') == f'{hostname}/{port}'
+    assert int(r[3]) == number
+    assert str_from_base64(r[2]) == string
 
 
 @given(domains(), lists(domains()))
@@ -87,7 +83,7 @@ def test_is_subdomain(subject, objects):
 
 def xml_unsupported_type(child):
     """Check if child is of a type supported by the XML constructor."""
-    return not isinstance(child, (tuple, str, datetime))
+    return not isinstance(child, (tuple, str, int, datetime))
 
 
 @given(text(), from_type(type).flatmap(from_type).filter(xml_unsupported_type))
@@ -100,13 +96,13 @@ 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()
-    not_after = draw(datetimes()).isoformat() if valid else 'N/A'
+    not_before = draw(datetimes()).isoformat() if valid else 'N/A'
+    not_after = draw(datetimes()).isoformat()
     hostname = draw(domains())
     port = draw(ports())
-    serial = draw(serials()) if valid else 'N/A'
-    issuer = draw(base64s())
-    return f'{not_before} {not_after} {hostname} {port} {serial} {issuer}'
+    number = draw(serials())
+    string = draw(base64s())
+    return f'{not_before} {not_after} {hostname} {port} {number} {string}'
 
 
 @contextmanager