Remove Komodo backend in favor of native hosts
This commit is contained in:
@@ -5,46 +5,33 @@ let fixture: Fixture;
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
fixture = await newFixture([]);
|
||||
vi.stubEnv('KOMODO_ADDRESS', '');
|
||||
vi.stubEnv('KOMODO_API_KEY', '');
|
||||
vi.stubEnv('KOMODO_API_SECRET', '');
|
||||
vi.stubEnv('KOMODO_TARGET_SERVER', '');
|
||||
vi.stubEnv('RCON_PASSWORD', '');
|
||||
vi.stubEnv('RCON_PASSWORD', 'fixture-rcon-secret');
|
||||
});
|
||||
afterEach(async () => { await fixture.cleanup(); vi.unstubAllEnvs(); vi.restoreAllMocks(); });
|
||||
afterEach(async () => { await fixture.cleanup(); vi.unstubAllEnvs(); });
|
||||
|
||||
it('directs a fresh controller to native hosts and verified libraries without probing Komodo', async () => {
|
||||
const probe = vi.spyOn(await import('../../src/lib/server/integrations/netProbe.js'), 'tcpProbe');
|
||||
it('directs a fresh controller to host enrollment and verified game files', async () => {
|
||||
const { GET } = await import('../../src/routes/api/system-status/+server.js');
|
||||
const response = await GET({ url: new URL('http://localhost/api/system-status') });
|
||||
const response = await GET();
|
||||
const body = await response.json();
|
||||
expect(response.headers.get('cache-control')).toBe('no-store');
|
||||
expect(body.checks.find((check: { id: string }) => check.id === 'hosts').state).toBe('unconfigured');
|
||||
expect(body.checks.find((check: { id: string }) => check.id === 'game-files').state).toBe('attention');
|
||||
expect(body.checks.some((check: { id: string }) => check.id === 'komodo')).toBe(false);
|
||||
expect(body.checks.map((check: { id: string }) => check.id)).toEqual(['hosts', 'runtime', 'game-files', 'rcon', 'keys', 'first-server']);
|
||||
expect(body.checks[0]).toMatchObject({ state: 'unconfigured', href: '/hosts' });
|
||||
expect(body.checks[2].state).toBe('attention');
|
||||
expect(body.readyServers).toBe(0);
|
||||
expect(probe).not.toHaveBeenCalled();
|
||||
expect(JSON.stringify(body)).not.toContain('fixture-rcon-secret');
|
||||
});
|
||||
|
||||
it('never exposes credentials or claims that network reachability validates them', async () => {
|
||||
vi.stubEnv('KOMODO_ADDRESS', 'https://komodo.example.test');
|
||||
vi.stubEnv('KOMODO_API_KEY', 'fixture-private-key');
|
||||
vi.stubEnv('KOMODO_API_SECRET', 'fixture-private-secret');
|
||||
vi.stubEnv('RCON_PASSWORD', 'fixture-rcon-secret');
|
||||
vi.spyOn(await import('../../src/lib/server/integrations/netProbe.js'), 'tcpProbe').mockResolvedValue({ label: 'Komodo', host: 'komodo.example.test', port: 443, resolvedIp: '192.0.2.1', outcome: 'connected', elapsedMs: 1 });
|
||||
it('reports an enrolled but disconnected host as needing attention without issuing commands', async () => {
|
||||
const { createHost, createEnrollment, enrollHost } = await import('../../src/lib/server/hosts/index.js');
|
||||
const { db } = await import('../../src/lib/server/db/index.js');
|
||||
const host = createHost({ name: 'Game host' });
|
||||
const enrolled = enrollHost(createEnrollment(host.id).token, { protocolVersion: 1 });
|
||||
db().prepare('UPDATE ec_hosts SET last_heartbeat=? WHERE id=?').run('2000-01-01T00:00:00Z', host.id);
|
||||
const { GET } = await import('../../src/routes/api/system-status/+server.js');
|
||||
const text = await (await GET({ url: new URL('http://localhost/api/system-status?probe=1') })).text();
|
||||
for (const secret of ['fixture-private-key', 'fixture-private-secret', 'fixture-rcon-secret']) expect(text).not.toContain(secret);
|
||||
const connection = JSON.parse(text).checks.find((check: { id: string }) => check.id === 'komodo');
|
||||
expect(connection.state).toBe('ready');
|
||||
expect(connection.detail).toContain('does not validate API credentials');
|
||||
});
|
||||
|
||||
it('reports a configured unreachable host as needing attention', async () => {
|
||||
vi.stubEnv('KOMODO_ADDRESS', 'http://komodo.example.test:9120');
|
||||
vi.stubEnv('KOMODO_API_KEY', 'key'); vi.stubEnv('KOMODO_API_SECRET', 'secret');
|
||||
vi.spyOn(await import('../../src/lib/server/integrations/netProbe.js'), 'tcpProbe').mockResolvedValue({ label: 'Komodo', host: 'komodo.example.test', port: 9120, resolvedIp: null, outcome: 'dns-fail', elapsedMs: 1 });
|
||||
const { GET } = await import('../../src/routes/api/system-status/+server.js');
|
||||
const body = await (await GET({ url: new URL('http://localhost/api/system-status?probe=1') })).json();
|
||||
expect(body.checks.find((check: { id: string }) => check.id === 'komodo').state).toBe('attention');
|
||||
const response = await GET();
|
||||
const text = await response.text();
|
||||
const body = JSON.parse(text);
|
||||
expect(body.checks[0]).toMatchObject({ state: 'attention', detail: expect.stringContaining('0 connected') });
|
||||
expect(text).not.toContain(enrolled.credential);
|
||||
expect(db().prepare('SELECT id FROM ec_host_operations').all()).toEqual([]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user