Skip to content

Commit

Permalink
verification: add test_verify_tz_aware
Browse files Browse the repository at this point in the history
Signed-off-by: William Woodruff <[email protected]>
  • Loading branch information
woodruffw committed Jan 22, 2024
1 parent d54093e commit 7951efe
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/x509/verification/test_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,27 @@ def test_store_rejects_empty_list(self):
def test_store_rejects_non_certificates(self):
with pytest.raises(TypeError):
Store(["not a cert"]) # type: ignore[list-item]


class TestServerVerifier:
def test_verify_tz_aware(self):
# expires 2018-11-16 01:15:03 GMT
leaf = _load_cert(
os.path.join("x509", "cryptography.io.pem"),
x509.load_pem_x509_certificate,
)

store = Store([leaf])

builder = PolicyBuilder().store(store)
# 00:15:03 in GMT+2, or 02:15:03 local time
builder = builder.time(
datetime.datetime.fromisoformat("2018-11-16T00:15:03+02:00")
)
verifier = builder.build_server_verifier(DNSName("cryptography.io"))

with pytest.raises(
x509.verification.VerificationError,
match="cert is not valid at validation time",
):
verifier.verify(leaf, [])

0 comments on commit 7951efe

Please sign in to comment.