From 92d512f0d29d682268813c8974477856d71fc2d7 Mon Sep 17 00:00:00 2001 From: Vlad Doloman Date: Wed, 8 Jul 2026 16:43:29 +0300 Subject: [PATCH] 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 --- openvpncertupdate.py | 2 +- tests/test_main_screen.py | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/openvpncertupdate.py b/openvpncertupdate.py index 592f801..9a3935a 100644 --- a/openvpncertupdate.py +++ b/openvpncertupdate.py @@ -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: diff --git a/tests/test_main_screen.py b/tests/test_main_screen.py index 0530463..82af72b 100644 --- a/tests/test_main_screen.py +++ b/tests/test_main_screen.py @@ -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 # ---------------------------------------------------------------------------