feat: toggle all-certs view with A key (load_all_certs, Action.TOGGLE_ALL)

This commit is contained in:
Vlad Doloman
2026-06-24 02:36:32 +03:00
parent 629095e0d8
commit 1222fb46a4
3 changed files with 100 additions and 8 deletions

View File

@@ -1,7 +1,7 @@
import textwrap
import pytest
from datetime import datetime, timezone, timedelta
from openvpncertupdate import load_expiring_certs, CertInfo, _parse_index_line
from openvpncertupdate import load_all_certs, load_expiring_certs, CertInfo, _parse_index_line
def _fmt(dt: datetime) -> str:
@@ -57,3 +57,22 @@ def test_parse_4digit_year():
cn, dt = result
assert cn == "future"
assert dt.year == 2025
def test_load_all_certs_includes_all_valid(tmp_path):
now = datetime.now(tz=timezone.utc)
pki = make_pki(tmp_path, now)
certs = load_all_certs(pki)
cns = {c.cn for c in certs}
# All V-status entries included regardless of expiry window
assert cns == {"soon", "later", "past15", "past40"}
# Revoked entry excluded
assert "revoked" not in cns
def test_load_all_certs_sorted_ascending(tmp_path):
now = datetime.now(tz=timezone.utc)
pki = make_pki(tmp_path, now)
certs = load_all_certs(pki)
dates = [c.expires for c in certs]
assert dates == sorted(dates)