Example #1
0
def test_validate_certificate_not_yet_valid(ca: CertificateAuthority) -> None:
    with on_time(time() + 24 * 3600, "UTC"):
        cert, _priv_key = ca._certificate_from_root("abc123")
    with pytest.raises(
        CertificateValidationError,
        match="Client certificate not yet valid",
    ):
        _validate_certificate(cert)
Example #2
0
def test_validate_certificate_expired(ca: CertificateAuthority) -> None:
    ca._days_valid = 1
    with on_time(1638174087, "UTC"):
        cert, _priv_key = ca._certificate_from_root("abc123")
    with pytest.raises(
        CertificateValidationError,
        match="Client certificate expired",
    ):
        _validate_certificate(cert)
Example #3
0
def fixture_untrusted_cert(tmp_path: Path) -> Certificate:
    ca2 = CertificateAuthority(tmp_path / "ca-2", "test-ca-2")
    ca2.initialize()
    cert, _priv_key = ca2._certificate_from_root("abc123")
    return cert
Example #4
0
def fixture_trusted_cert(ca: CertificateAuthority) -> Certificate:
    cert, _priv_key = ca._certificate_from_root("abc123")
    return cert