Wire the TUI Days field through to build-client-full
This commit is contained in:
@@ -1244,7 +1244,8 @@ class CursesApp:
|
|||||||
self, stdscr, cn: str, email: str, is_renewal: bool,
|
self, stdscr, cn: str, email: str, is_renewal: bool,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Form → generate → deliver. Returns False if user cancelled."""
|
"""Form → generate → deliver. Returns False if user cancelled."""
|
||||||
form = show_cert_form(stdscr, cn=cn, email=email, cn_readonly=is_renewal)
|
form = show_cert_form(stdscr, cn=cn, email=email, days=CERT_DAYS,
|
||||||
|
cn_readonly=is_renewal)
|
||||||
if not form.confirmed:
|
if not form.confirmed:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -1288,7 +1289,7 @@ class CursesApp:
|
|||||||
try:
|
try:
|
||||||
build_client_full(EASYRSA_DIR, EASYRSA_PKI_DIR,
|
build_client_full(EASYRSA_DIR, EASYRSA_PKI_DIR,
|
||||||
final_cn, form.password, CA_PASSPHRASE,
|
final_cn, form.password, CA_PASSPHRASE,
|
||||||
email=form.email)
|
email=form.email, days=form.days)
|
||||||
except EasyRSAError as exc:
|
except EasyRSAError as exc:
|
||||||
if revoked:
|
if revoked:
|
||||||
self._error(
|
self._error(
|
||||||
|
|||||||
@@ -90,3 +90,22 @@ def test_tui_skipped_revoke_build_failure_does_not_claim_revocation(monkeypatch)
|
|||||||
lambda self, stdscr, text: shown.append(text))
|
lambda self, stdscr, text: shown.append(text))
|
||||||
app._process_cert(_stdscr(), "y.kuts", "", is_renewal=True)
|
app._process_cert(_stdscr(), "y.kuts", "", is_renewal=True)
|
||||||
assert shown and "has been revoked" not in shown[0]
|
assert shown and "has been revoked" not in shown[0]
|
||||||
|
|
||||||
|
|
||||||
|
def test_tui_seeds_days_field_from_cert_days(monkeypatch):
|
||||||
|
import openvpncertupdate as m
|
||||||
|
_patch_workflow(monkeypatch, cert_file_present=True)
|
||||||
|
monkeypatch.setattr("openvpncertupdate.CERT_DAYS", "90")
|
||||||
|
CursesApp()._process_cert(_stdscr(), "y.kuts", "", is_renewal=True)
|
||||||
|
assert m.show_cert_form.call_args.kwargs["days"] == "90"
|
||||||
|
|
||||||
|
|
||||||
|
def test_tui_forwards_form_days_to_build_client_full(monkeypatch):
|
||||||
|
mocks = _patch_workflow(monkeypatch, cert_file_present=True)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
"openvpncertupdate.show_cert_form",
|
||||||
|
MagicMock(return_value=CertFormResult(
|
||||||
|
cn="y.kuts", email="", password="Testpass1234567890abcdefgh",
|
||||||
|
days="30", confirmed=True)))
|
||||||
|
CursesApp()._process_cert(_stdscr(), "y.kuts", "", is_renewal=True)
|
||||||
|
assert mocks["build_client_full"].call_args.kwargs["days"] == "30"
|
||||||
|
|||||||
Reference in New Issue
Block a user