fix: clear stale nordvpn disconnect state
This commit is contained in:
@@ -15,6 +15,8 @@ module.exports = {
|
||||
typeof buildWireguardConfig === "function" ? buildWireguardConfig : undefined,
|
||||
buildLookupResult:
|
||||
typeof buildLookupResult === "function" ? buildLookupResult : undefined,
|
||||
cleanupMacWireguardState:
|
||||
typeof cleanupMacWireguardState === "function" ? cleanupMacWireguardState : undefined,
|
||||
getMacTailscalePath:
|
||||
typeof getMacTailscalePath === "function" ? getMacTailscalePath : undefined,
|
||||
isMacTailscaleActive:
|
||||
@@ -108,6 +110,26 @@ test("buildMacTailscaleState records whether tailscale was active", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("cleanupMacWireguardState removes stale config and last-connection files", () => {
|
||||
const { cleanupMacWireguardState } = loadInternals();
|
||||
assert.equal(typeof cleanupMacWireguardState, "function");
|
||||
|
||||
const tmpDir = fs.mkdtempSync(path.join(fs.mkdtempSync("/tmp/nordvpn-client-test-"), "state-"));
|
||||
const configPath = path.join(tmpDir, "nordvpnctl.conf");
|
||||
const lastConnectionPath = path.join(tmpDir, "last-connection.json");
|
||||
fs.writeFileSync(configPath, "wireguard-config");
|
||||
fs.writeFileSync(lastConnectionPath, "{\"country\":\"Germany\"}");
|
||||
|
||||
const result = cleanupMacWireguardState({
|
||||
configPath,
|
||||
lastConnectionPath,
|
||||
});
|
||||
|
||||
assert.equal(result.cleaned, true);
|
||||
assert.equal(fs.existsSync(configPath), false);
|
||||
assert.equal(fs.existsSync(lastConnectionPath), false);
|
||||
});
|
||||
|
||||
test("isMacTailscaleActive treats Running backend as active", () => {
|
||||
const { isMacTailscaleActive } = loadInternals();
|
||||
assert.equal(typeof isMacTailscaleActive, "function");
|
||||
|
||||
Reference in New Issue
Block a user