feat(appstore): add service volumes and published ports
This commit is contained in:
@@ -7,6 +7,7 @@ class FakeDatabase {
|
||||
public settings = new Map<string, string>();
|
||||
public secretSettings = new Map<string, string>();
|
||||
public domains: IDomain[] = [];
|
||||
public services: IService[] = [];
|
||||
public certificates = new Map<string, ISslCertificate>();
|
||||
private nextDomainId = 1;
|
||||
|
||||
@@ -42,6 +43,10 @@ class FakeDatabase {
|
||||
return this.domains.filter((entry) => entry.dnsProvider === provider);
|
||||
}
|
||||
|
||||
getAllServices(): IService[] {
|
||||
return this.services;
|
||||
}
|
||||
|
||||
getSSLCertificate(domain: string): ISslCertificate | null {
|
||||
return this.certificates.get(domain) ?? null;
|
||||
}
|
||||
@@ -241,6 +246,82 @@ Deno.test('ExternalGatewayManager deletes service routes through dcrouter gatewa
|
||||
assertEquals((capturedDeleteRequest.ownership as any).hostname, 'hello.example.com');
|
||||
});
|
||||
|
||||
Deno.test('ExternalGatewayManager removes stale gateway routes during reconciliation', async () => {
|
||||
const oneboxRef = makeOneboxRef();
|
||||
oneboxRef.database.settings.set('serverIP', '203.0.113.10');
|
||||
oneboxRef.database.services.push({
|
||||
id: 1,
|
||||
name: 'active',
|
||||
image: 'nginx:latest',
|
||||
envVars: {},
|
||||
port: 3000,
|
||||
domain: 'active.example.com',
|
||||
status: 'running',
|
||||
createdAt: 1,
|
||||
updatedAt: 1,
|
||||
});
|
||||
|
||||
const deletes: Record<string, unknown>[] = [];
|
||||
const manager = new ExternalGatewayManager(oneboxRef as any);
|
||||
(manager as any).fireDcRouterRequest = async (method: string, requestData: Record<string, unknown>) => {
|
||||
if (method === 'getGatewayClientContext') {
|
||||
return { context: { role: 'gatewayClient', gatewayClient: { type: 'onebox', id: 'onebox-token' } } };
|
||||
}
|
||||
if (method === 'syncGatewayClientRoute') {
|
||||
if (requestData.delete) {
|
||||
deletes.push(requestData);
|
||||
return { success: true, action: 'deleted' };
|
||||
}
|
||||
return { success: true, action: 'updated', routeId: 'active-route' };
|
||||
}
|
||||
if (method === 'exportCertificate') {
|
||||
return { success: false };
|
||||
}
|
||||
if (method === 'getGatewayClientDnsRecords') {
|
||||
return {
|
||||
records: [
|
||||
{
|
||||
id: 'active-record',
|
||||
domainId: 'domain-1',
|
||||
name: 'active',
|
||||
type: 'A',
|
||||
value: '203.0.113.10',
|
||||
ttl: 300,
|
||||
source: 'route',
|
||||
status: 'active',
|
||||
gatewayClientType: 'onebox',
|
||||
gatewayClientId: 'onebox-token',
|
||||
appId: 'active',
|
||||
hostname: 'active.example.com',
|
||||
routeId: 'active-route',
|
||||
},
|
||||
{
|
||||
id: 'stale-record',
|
||||
domainId: 'domain-1',
|
||||
name: 'stale',
|
||||
type: 'A',
|
||||
value: '203.0.113.10',
|
||||
ttl: 300,
|
||||
source: 'route',
|
||||
status: 'active',
|
||||
gatewayClientType: 'onebox',
|
||||
gatewayClientId: 'onebox-token',
|
||||
appId: 'stale',
|
||||
hostname: 'stale.example.com',
|
||||
routeId: 'stale-route',
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
throw new Error(`Unexpected method: ${method}`);
|
||||
};
|
||||
|
||||
await manager.syncServiceRoutes();
|
||||
|
||||
assertEquals(deletes.length, 1);
|
||||
assertEquals((deletes[0].ownership as any).hostname, 'stale.example.com');
|
||||
});
|
||||
|
||||
Deno.test('ExternalGatewayManager imports exported dcrouter certificates into Onebox', async () => {
|
||||
const oneboxRef = makeOneboxRef();
|
||||
const manager = new ExternalGatewayManager(oneboxRef as any);
|
||||
|
||||
Reference in New Issue
Block a user