14
0
2024-11-13 14:29:31 +00:00
committed by Git OBS Bridge
5 changed files with 140 additions and 4 deletions

View File

@@ -0,0 +1,128 @@
From 5dd5ff95b7b104667eb4f39367eb4f4c00fcedd5 Mon Sep 17 00:00:00 2001
From: Matthias Valvekens <matthias@mvalvekens.be>
Date: Tue, 12 Nov 2024 21:27:35 +0100
Subject: [PATCH] Freeze time for tests using PKITS certs
---
tests/test_certificate_validator.py | 2 ++
tests/test_policy_proc.py | 9 +++++++--
tests/test_validate.py | 4 ++++
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/tests/test_certificate_validator.py b/tests/test_certificate_validator.py
index 692bdda..2c2845c 100644
--- a/tests/test_certificate_validator.py
+++ b/tests/test_certificate_validator.py
@@ -4,6 +4,7 @@
import pytest
from asn1crypto.util import timezone
+from freezegun import freeze_time
from pyhanko_certvalidator import (
CertificateValidator,
@@ -94,6 +95,7 @@ async def test_basic_certificate_validator_tls_whitelist():
await validator.async_validate_usage({'crl_sign'})
+@freeze_time('2022-05-01')
@pytest.mark.asyncio
async def test_certvalidator_with_params():
cert = load_nist_cert('ValidPolicyMappingTest12EE.crt')
diff --git a/tests/test_policy_proc.py b/tests/test_policy_proc.py
index f95f4bb..8765677 100644
--- a/tests/test_policy_proc.py
+++ b/tests/test_policy_proc.py
@@ -1,7 +1,6 @@
-import os
-
import pytest
from asn1crypto import x509
+from freezegun import freeze_time
from pyhanko_certvalidator.authority import (
CertTrustAnchor,
@@ -49,6 +48,7 @@ def test_extract_permitted_subtrees():
assert tree.tree_base.value == expected_name
+@freeze_time('2022-05-01')
@pytest.mark.asyncio
async def test_validate_with_derived():
crt = load_nist_cert('nameConstraintsDN1CACert.crt')
@@ -64,6 +64,7 @@ async def test_validate_with_derived():
await async_validate_path(context, path)
+@freeze_time('2022-05-01')
@pytest.mark.asyncio
async def test_validate_with_merged_permitted_subtrees():
crt = load_nist_cert('nameConstraintsDN1CACert.crt')
@@ -93,6 +94,7 @@ async def test_validate_with_merged_permitted_subtrees():
await async_validate_path(context, path, parameters=extra_params)
+@freeze_time('2022-05-01')
@pytest.mark.asyncio
async def test_validate_with_merged_excluded_subtrees():
crt = load_nist_cert('nameConstraintsDN3CACert.crt')
@@ -122,6 +124,7 @@ async def test_validate_with_merged_excluded_subtrees():
await async_validate_path(context, path, parameters=extra_params)
+@freeze_time('2022-05-01')
@pytest.mark.asyncio
async def test_validate_with_certless_root():
crt = load_nist_cert('nameConstraintsDN1CACert.crt')
@@ -154,6 +157,7 @@ async def test_validate_with_certless_root():
await async_validate_path(context, path, parameters=extra_params)
+@freeze_time('2022-05-01')
@pytest.mark.asyncio
async def test_validate_with_certless_root_failure():
crt = load_nist_cert('nameConstraintsDN1CACert.crt')
@@ -186,6 +190,7 @@ async def test_validate_with_certless_root_failure():
await async_validate_path(context, path, parameters=extra_params)
+@freeze_time('2022-05-01')
@pytest.mark.asyncio
async def test_validate_empty_path_certless_root():
crt = load_nist_cert('nameConstraintsDN1CACert.crt')
diff --git a/tests/test_validate.py b/tests/test_validate.py
index 77d9f4d..f739cac 100644
--- a/tests/test_validate.py
+++ b/tests/test_validate.py
@@ -9,6 +9,7 @@
import pytest
from asn1crypto import crl, ocsp, x509
from asn1crypto.util import timezone
+from freezegun import freeze_time
from pyhanko_certvalidator import PKIXValidationParams
from pyhanko_certvalidator.authority import Authority, CertTrustAnchor
@@ -617,6 +618,7 @@ def read_pkits_test_params():
return [PKITSTestCase.from_json(obj) for obj in cases]
+@freeze_time('2022-05-01')
@pytest.mark.parametrize(
'test_case', read_pkits_test_params(), ids=lambda case: str(case.test_info)
)
@@ -711,6 +713,7 @@ def read_pkits_user_notice_test_params():
return [PKITSUserNoticeTestCase.from_json(obj) for obj in cases]
+@freeze_time('2022-05-01')
@pytest.mark.parametrize(
'test_case',
read_pkits_user_notice_test_params(),
@@ -741,6 +744,7 @@ def test_nist_pkits_user_notice(test_case: PKITSUserNoticeTestCase):
assert qual_obj['qualifier']['explicit_text'].native == test_case.notice
+@freeze_time('2022-05-01')
def test_408020_cps_pointer_qualifier_test20():
cert = load_nist_cert('CPSPointerQualifierTest20EE.crt')
ca_certs = [load_nist_cert('TrustAnchorRootCertificate.crt')]

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7861efb4259126327d9590703fe4f4316647d3725c32bd49ea67f0810abded1c
size 567222

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a63f70ee391066e23a457a7ea8c8e0ccff82f31ac947da0300378ddbe99c2cfd
size 567603

View File

@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Nov 13 06:13:51 UTC 2024 - Bernhard M. Demo2 Wiedemann <opensusedemo+test2@lsmod.de>
- Add 5dd5ff95b7b104667eb4f39367eb4f4c00fcedd5.patch to fix future tests (boo#1102840)
- Upgrade to version 0.26.4
* make tests pass in future (boo#1102840)
-------------------------------------------------------------------
Tue Sep 17 01:28:31 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>

View File

@@ -17,12 +17,13 @@
Name: python-pyhanko-certvalidator
Version: 0.26.3
Version: 0.26.4
Release: 0
Summary: Validates X509 certificates and paths
License: MIT
URL: https://github.com/MatthiasValvekens/certvalidator
Source: https://github.com/MatthiasValvekens/certvalidator/archive/refs/tags/v%{version}.tar.gz#/pyhanko-certvalidator-%{version}.tar.gz
Patch0: https://github.com/MatthiasValvekens/certvalidator/commit/5dd5ff95b7b104667eb4f39367eb4f4c00fcedd5.patch
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools >= 67.4}
BuildRequires: %{python_module wheel}