Hub 2.3.0: install Accounts (first product, or added next to a church's others)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 14:34:18 +02:00
co-authored by Claude Opus 5.5
parent be3945b8be
commit 78857bc0e4
12 changed files with 141 additions and 22 deletions
+45
View File
@@ -286,6 +286,51 @@ describe('reusing a short name (found in the VM test)', () => {
});
});
describe('Accounts from the Hub (2.3.0)', () => {
const poll = (server) => jobs.poll(server, { agentApiVersion: 1, agentVersion: '1.1.0', mode: 'church', runningJobId: null }, NOW);
beforeEach(async () => {
await db.release.create({ data: { id: 'ra1', product: 'accounts', version: '1.0.0', notes: '- First release', releasedAt: NOW } });
});
test("a church's first product can be Accounts: an install job with its CCA- licence", async () => {
const { server } = await joinServer();
await servers.setServerConfig(server.id, { TRUST_PROXY: 'loopback' });
const { deployment } = await jobs.newInstall({ product: 'accounts', customerId: 'cust-1', serverId: server.id, shortName: 'grace', domain: 'accounts.grace.co.za', adminEmail: 'jane@grace.test' }, admin, NOW);
expect(deployment).toMatchObject({ product: 'accounts', status: 'installing' });
const [job] = (await poll(server)).jobs;
expect(job).toMatchObject({ type: 'install', args: { products: ['accounts'], versions: { accounts: 'accounts@1.0.0' }, domains: { accounts: 'accounts.grace.co.za' } } });
expect(agent.agentJobSchema.safeParse(job).success).toBe(true);
const config = signing.openConfig(job.config, keys.x.privateKeyPem);
expect(config.install.accounts.HUB_LICENCE_KEY).toMatch(/^CCA-/);
});
test("next to the church's Events: an add-product job; finishing it waits for the proxy as an install does", async () => {
const { server } = await joinServer();
await servers.setServerConfig(server.id, { TRUST_PROXY: 'loopback' });
const events = await jobs.newInstall({ customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'events.hope.co.za' }, admin, NOW);
await db.deployment.update({ where: { id: events.deployment.id }, data: { status: 'live' } });
await db.job.updateMany({ where: { deploymentId: events.deployment.id }, data: { status: 'succeeded' } });
const { deployment } = await jobs.newInstall({ product: 'accounts', customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'accounts.hope.co.za' }, admin, NOW);
const [job] = (await poll(server)).jobs;
expect(job).toMatchObject({ type: 'add-product', args: { church: 'hope', product: 'accounts', version: 'accounts@1.0.0', domain: 'accounts.hope.co.za', ports: { web: 20002, api: 20003 } } });
expect(agent.agentJobSchema.safeParse(job).success).toBe(true);
expect(signing.openConfig(job.config, keys.x.privateKeyPem).install.accounts).toBeTruthy();
await jobs.receiveReport(server, signedReport(job, 'succeeded', { result: { versions: { accounts: 'accounts@1.0.0' } } }), NOW);
expect(await db.deployment.findUnique({ where: { id: deployment.id } })).toMatchObject({ status: 'waiting_for_proxy', version: '1.0.0' });
});
test("refused: another server, a product the Hub can't install yet, or while the first is installing", async () => {
const { server } = await joinServer();
const other = (await joinServer('church', 'church-2')).server;
await servers.setServerConfig(server.id, { TRUST_PROXY: 'loopback' });
await servers.setServerConfig(other.id, { TRUST_PROXY: 'loopback' });
await jobs.newInstall({ customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'events.hope.co.za' }, admin, NOW);
await expect(jobs.newInstall({ product: 'accounts', customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'accounts.hope.co.za' }, admin, NOW)).rejects.toMatchObject({ code: 'BUSY' });
await expect(jobs.newInstall({ product: 'accounts', customerId: 'cust-1', serverId: other.id, shortName: 'hope', domain: 'accounts.hope.co.za' }, admin, NOW)).rejects.toMatchObject({ code: 'OTHER_SERVER' });
await expect(jobs.newInstall({ product: 'website', customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'www.hope.co.za' }, admin, NOW)).rejects.toMatchObject({ code: 'BAD_REQUEST' });
});
});
describe('settings for servers (found in the VM test)', () => {
test('install defaults, the port range and the central IP are saved', async () => {
const { setSettings } = require('../src/utils/settings');