Update Harbor client and gateway functionality
This commit is contained in:
@@ -12,7 +12,7 @@ import { HarborError } from '../../dist/shared/errors.js';
|
||||
|
||||
const serverA = { id: 'a', label: 'Alpha', host: 'a.example', port: 1, protocol: 'vless' };
|
||||
const serverB = { id: 'b', label: 'Beta', host: 'b.example', port: 2, protocol: 'vless' };
|
||||
const rules = [{ type: 'domain_suffix', value: 'example', enabled: true }];
|
||||
const rules = [{ type: 'domain_suffix', value: 'example', enabled: true, outbound: 'direct' }];
|
||||
|
||||
const profile = (id, label, desiredServerId = 'a', servers = [serverA, serverB]) => ({
|
||||
id,
|
||||
@@ -148,6 +148,7 @@ test('apply validates the profile pair and publishes applied identity only after
|
||||
assert.equal(after.state.profiles.find(({ id }) => id === 'work').desiredServerId, 'a');
|
||||
assert.equal(after.state.appliedProfileId, 'work');
|
||||
assert.equal(after.state.appliedServerId, 'a');
|
||||
assert.deepEqual(after.state.appliedRouteRules, rules);
|
||||
assert.deepEqual(after.state.appliedServerSnapshot, serverA);
|
||||
assert.deepEqual(harness.events, ['config.write', 'runtime.start', 'state.update']);
|
||||
|
||||
@@ -197,11 +198,14 @@ test('activate only changes desired while stopped and transactionally switches w
|
||||
});
|
||||
|
||||
test('gateway-direct changes only local desired state and never claims a remote applied target', async () => {
|
||||
const harness = createHarness({ gatewayDirect: true });
|
||||
const state = initialState();
|
||||
state.appliedRouteRules = [];
|
||||
const harness = createHarness({ gatewayDirect: true, state });
|
||||
await harness.service.apply('work', 'b');
|
||||
const after = harness.snapshot();
|
||||
assert.equal(after.state.desiredProfileId, 'work');
|
||||
assert.equal(after.state.appliedProfileId, 'personal');
|
||||
assert.deepEqual(after.state.appliedRouteRules, []);
|
||||
assert.equal(harness.events.includes('config.write'), false);
|
||||
assert.equal(harness.events.includes('runtime.start'), false);
|
||||
});
|
||||
@@ -232,6 +236,15 @@ test('restart uses applied pair while running and desired pair while stopped', a
|
||||
assert.equal(stopped.snapshot().state.appliedProfileId, 'work');
|
||||
assert.equal(stopped.snapshot().state.appliedServerId, 'b');
|
||||
assert.match(stopped.snapshot().config, /"selectedServerId":"b"/);
|
||||
assert.deepEqual(stopped.snapshot().state.appliedRouteRules, rules);
|
||||
});
|
||||
|
||||
test('restart in gateway-direct keeps user rules omitted from applied truth', async () => {
|
||||
const state = initialState();
|
||||
state.appliedRouteRules = [];
|
||||
const harness = createHarness({ gatewayDirect: true, state });
|
||||
await harness.service.restart();
|
||||
assert.deepEqual(harness.snapshot().state.appliedRouteRules, []);
|
||||
});
|
||||
|
||||
test('running restart preserves a pending desired profile while restoring the applied pair', async () => {
|
||||
|
||||
Reference in New Issue
Block a user