From a4aabd1d33770d6199a8cb7bc87f639668617bc9 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Fri, 4 Sep 2026 16:08:06 +0200 Subject: fix(packaging): re-running setup no longer re-prompts for firewall access Every run of customInstall showed the "Allow MeshBay through Windows Firewall?" question and, on Yes, a fresh UAC prompt -- an upgrade or repair install would ask again even with all four rules already in place. customInstall now checks first: firewall.ps1 check, unelevated (Get-NetFirewallRule needs no admin, only New/Remove do), exits 0 if every rule already exists. Only a nonzero result reaches the MessageBox and the elevated add. A second run of setup on an already-configured machine now asks nothing. Verified unelevated: check exits 1 and logs which rules are missing on a machine with none of them (the fresh-install case); electron-builder compiles the nsExec::Exec / Pop $0 / ${If} wiring. Node suite 837 pass / 25 skip. Co-Authored-By: Claude Sonnet 5 --- packages/meshbay-node/tests/test_packaging_win.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'packages/meshbay-node/tests/test_packaging_win.py') diff --git a/packages/meshbay-node/tests/test_packaging_win.py b/packages/meshbay-node/tests/test_packaging_win.py index ba3568c..20a2505 100644 --- a/packages/meshbay-node/tests/test_packaging_win.py +++ b/packages/meshbay-node/tests/test_packaging_win.py @@ -199,6 +199,24 @@ def test_the_installer_offers_one_elevated_firewall_step_instead_of_two_dialogs( assert 'firewall.ps1" add' in install +def test_reinstalling_with_the_rules_already_in_place_asks_nothing(): + """ + Get-NetFirewallRule needs no admin, only New/Remove do — so customInstall + checks first, unelevated, and only reaches the MessageBox (and therefore + the UAC prompt) when something is actually missing. Without this, running + setup a second time — an upgrade, a repair install — would re-ask the + question and re-trigger UAC even though nothing needs to change. + """ + nsh = NSH.read_text(encoding="utf-8") + install = _macro_body(nsh, "customInstall") + + check_line = 'firewall.ps1" check' + assert check_line in install + # The check must run, and be evaluated, before the MessageBox — not after. + assert install.index(check_line) < install.index("MessageBox MB_YESNO") + assert "Pop $0" in install and "${If} $0 != 0" in install + + def test_the_uninstaller_offers_to_remove_the_firewall_rules_default_no(): """Opt-in on the way out too, and defaulting to No: a stale allow-rule for a deleted exe is inert, so this should not nag.""" -- cgit v1.2.3