Hub 2.26.2: why Proxy done can't reach a site; a site admin for added installs
Proxy done shows the reason behind "fetch failed" (the error's code: DNS, the certificate, the connection, a timeout) with what to check. A blank site admin email on New install takes the church's own from its other installs (Accounts' first), so an App or Website added later gets HUB_ADMIN_EMAIL and a first Owner. The "site is ready" email sends the Website and the App to their admin instead of a /setup they don't have. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -174,6 +174,45 @@ describe('jobs', () => {
|
||||
expect(ready.text).toContain('Start the setup: https://events.hope.co.za/setup');
|
||||
});
|
||||
|
||||
test('2.26.2: Proxy done says why a fetch failed, not just "fetch failed"', async () => {
|
||||
const { server } = await joinServer();
|
||||
await servers.setServerConfig(server.id, { TRUST_PROXY: 'loopback' });
|
||||
const { deployment } = await jobs.newInstall({ customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'events.hope.co.za' }, admin, NOW);
|
||||
const failing = cause => async () => { throw new TypeError('fetch failed', { cause }); };
|
||||
const dns = await jobs.proxyDone(deployment.id, NOW, failing(Object.assign(new Error('getaddrinfo ENOTFOUND events.hope.co.za'), { code: 'ENOTFOUND' })));
|
||||
expect(dns.live).toBe(false);
|
||||
expect(dns.problems[0]).toContain('fetch failed (ENOTFOUND: getaddrinfo ENOTFOUND events.hope.co.za)');
|
||||
expect(dns.problems[0]).toContain('in DNS');
|
||||
const cert = await jobs.proxyDone(deployment.id, NOW, failing(Object.assign(new Error('unable to verify the first certificate'), { code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' })));
|
||||
expect(cert.problems[0]).toContain('UNABLE_TO_VERIFY_LEAF_SIGNATURE');
|
||||
expect(cert.problems[0]).toContain('full chain');
|
||||
const slow = await jobs.proxyDone(deployment.id, NOW, async () => { throw new DOMException('The operation was aborted due to timeout', 'TimeoutError'); });
|
||||
expect(slow.problems[0]).toContain('no answer within 15 seconds');
|
||||
});
|
||||
|
||||
test('2.26.2: the Website\'s and App\'s ready email opens the admin (they have no setup)', async () => {
|
||||
const { server } = await joinServer();
|
||||
const d = await db.deployment.create({ data: { id: 'app-hope', serverId: server.id, customerId: 'cust-1', product: 'app', shortName: 'hope', domain: 'app.hope.co.za', webPort: 20100, apiPort: 20101, status: 'waiting_for_proxy', adminName: 'Jane', adminEmail: 'jane@hope.test' } });
|
||||
const ok = async url => ({ status: url.endsWith('/') ? 200 : 404, headers: new Headers({ 'x-powered-by': 'Express' }), json: async () => ({ version: null }) });
|
||||
expect(await jobs.proxyDone(d.id, NOW, ok)).toEqual({ live: true, problems: [] });
|
||||
const ready = mockMails.find(m => m.subject.includes('site is ready'));
|
||||
expect(ready.html).toContain('href="https://app.hope.co.za/admin"');
|
||||
expect(ready.text).toContain('jane@hope.test');
|
||||
expect(ready.text).not.toContain('/setup');
|
||||
});
|
||||
|
||||
test('2.26.2: a new install without a site admin takes the church\'s from its other installs', async () => {
|
||||
const { server } = await joinServer();
|
||||
await servers.setServerConfig(server.id, { TRUST_PROXY: 'loopback' });
|
||||
const { deployment: ev } = await jobs.newInstall({ customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'events.hope.co.za', adminName: 'Jane', adminEmail: 'jane@hope.test' }, admin, NOW);
|
||||
await db.deployment.update({ where: { id: ev.id }, data: { status: 'live' } });
|
||||
await db.release.create({ data: { id: 'ra10', product: 'accounts', version: '1.0.0', releasedAt: NOW } });
|
||||
const { deployment: acc } = await jobs.newInstall({ customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'accounts.hope.co.za', product: 'accounts' }, admin, NOW);
|
||||
expect(acc).toMatchObject({ adminName: 'Jane', adminEmail: 'jane@hope.test' });
|
||||
const job = await db.job.findFirst({ where: { deploymentId: acc.id, type: 'install' } });
|
||||
if (job) expect(JSON.stringify(job.args)).toContain('jane@hope.test');
|
||||
});
|
||||
|
||||
test('a failed install frees its ports again', async () => {
|
||||
const { server } = await joinServer();
|
||||
await servers.setServerConfig(server.id, { TRUST_PROXY: 'loopback' });
|
||||
|
||||
Reference in New Issue
Block a user