Keep verified Gateway active through transient discovery failures
This commit is contained in:
@@ -78,7 +78,7 @@ test('Gateway presence is authenticated by the shared subscription secret', asyn
|
||||
}), false);
|
||||
});
|
||||
|
||||
test('host route freshness and Gateway failures drive a safe automatic fallback', () => {
|
||||
test('verified Gateway stays active through transient discovery failures', () => {
|
||||
const now = Date.now();
|
||||
const statePath = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'harbor-route-')), 'network.json');
|
||||
fs.writeFileSync(statePath, JSON.stringify({
|
||||
@@ -106,14 +106,23 @@ test('host route freshness and Gateway failures drive a safe automatic fallback'
|
||||
state = nextGatewayAutoState(state, { network });
|
||||
assert.equal(state.mode, 'gateway-direct');
|
||||
state = nextGatewayAutoState(state, { network });
|
||||
assert.equal(state.mode, 'local-vpn');
|
||||
assert.equal(state.mode, 'gateway-direct');
|
||||
assert.equal(state.gatewayId, 'gateway-1');
|
||||
assert.equal(state.failures, 3);
|
||||
|
||||
state = nextGatewayAutoState(state, {
|
||||
network: null,
|
||||
error: 'host snapshot stale',
|
||||
});
|
||||
assert.equal(state.mode, 'gateway-direct');
|
||||
assert.equal(state.gatewayId, 'gateway-1');
|
||||
assert.equal(state.lastError, 'host snapshot stale');
|
||||
assert.equal(applyGatewayPreference(state, false).mode, 'local-vpn');
|
||||
|
||||
const newNetwork = { ...network, mac: '11:22:33:44:55:66' };
|
||||
state = nextGatewayAutoState(nextGatewayAutoState(createGatewayAutoState(), {
|
||||
network,
|
||||
verifiedGateway: { gatewayId: 'gateway-1' },
|
||||
}), { network: newNetwork });
|
||||
state = nextGatewayAutoState(state, { network: newNetwork });
|
||||
assert.equal(state.mode, 'local-vpn');
|
||||
assert.equal(state.gatewayId, '');
|
||||
|
||||
assert.equal(readHostNetworkState(statePath, { now: now + 16_000 }), null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user