show email alongside CN in TUI main menu cert list
CertInfo.email was already populated from index.txt but never rendered; add it as a fixed-width column next to CN in the cert list rows (blank when unknown). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -938,7 +938,7 @@ def show_main_screen(
|
||||
cert = certs[i]
|
||||
box = "[X]" if cert.cn in checked else "[ ]"
|
||||
lbl = _expiry_label(cert)
|
||||
line = f" {box} {lbl:<18} {cert.cn}"
|
||||
line = f" {box} {lbl:<18} {cert.cn:<20} {cert.email}"
|
||||
try:
|
||||
stdscr.addstr(row_y, 0, line.ljust(sw - 1)[:sw - 1], sel_attr)
|
||||
except curses.error:
|
||||
|
||||
@@ -28,12 +28,13 @@ from openvpncertupdate import (
|
||||
# Helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _cert(cn: str, days_left: int) -> CertInfo:
|
||||
def _cert(cn: str, days_left: int, email: str = "") -> CertInfo:
|
||||
"""Build a minimal CertInfo; expires value is a plausible UTC datetime."""
|
||||
return CertInfo(
|
||||
cn=cn,
|
||||
expires=datetime(2030, 1, 1, tzinfo=timezone.utc),
|
||||
days_left=days_left,
|
||||
email=email,
|
||||
)
|
||||
|
||||
|
||||
@@ -121,6 +122,28 @@ def test_cursor_row_has_reverse_attribute():
|
||||
assert alice_calls and not (alice_calls[0].args[3] & _curses.A_REVERSE)
|
||||
|
||||
|
||||
def test_cert_row_shows_email():
|
||||
certs = [_cert("alice", 10, email="alice@example.com"), _cert("bob", 3)]
|
||||
stdscr = _make_stdscr()
|
||||
stdscr.getch.side_effect = [ord("q")]
|
||||
with patch("openvpncertupdate.init_colors"):
|
||||
show_main_screen(stdscr, certs)
|
||||
alice_calls = [c for c in stdscr.addstr.call_args_list if "alice" in str(c.args[2])]
|
||||
assert alice_calls
|
||||
assert "alice@example.com" in alice_calls[0].args[2]
|
||||
|
||||
|
||||
def test_cert_row_blank_when_no_email():
|
||||
certs = [_cert("bob", 3)] # email defaults to ""
|
||||
stdscr = _make_stdscr()
|
||||
stdscr.getch.side_effect = [ord("q")]
|
||||
with patch("openvpncertupdate.init_colors"):
|
||||
show_main_screen(stdscr, certs)
|
||||
bob_calls = [c for c in stdscr.addstr.call_args_list if "bob" in str(c.args[2])]
|
||||
assert bob_calls
|
||||
assert "(none)" not in bob_calls[0].args[2]
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Enter on cert → RENEW_SELECTED
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user