test: require review fix assertions
- test: require review fix assertions - test: cover zone repair and imported dns records - test: wait for dns and tighten assertions - fix(api): drop the record id of a rolled back record creation - test(audit): run every api route through the real handlers in an audit matrix - test(api): run the authorization matrix through the real zone handlers - test: repair duplicate apex soa through ui
This commit is contained in:
1 parent
a884219512
commit
9251c85fd8
14 files changed
+1631
-123
No files matched your search
+53
-3
@@ -7,7 +7,7 @@ import { zp, up } from '../harness/api';
|
||||
import { parseTable, USAGE_TEXT } from '../harness/cli';
|
||||
import { waitForZone, waitForZoneGone } from '../harness/dig';
|
||||
import { runnerAddress, SESSION_COOKIE } from '../harness/env';
|
||||
import { bulkDeleteBody, expectCheckErrorRowsCarryRaw, expectZoneCreateWarnings, importApplyBody, REVIEW_FIXES, UNKNOWN_API_OPERATION, ZONE_CREATE_DELEGATIONS_IN } from '../harness/decisions';
|
||||
import { bulkDeleteBody, expectCheckErrorRowsCarryRaw, expectZoneCreateWarnings, importApplyBody, UNKNOWN_API_OPERATION, ZONE_CREATE_DELEGATIONS_IN } from '../harness/decisions';
|
||||
import { READ_OPERATIONS } from '../harness/ledger';
|
||||
import type { AuditRow, RecordRow } from '../harness/mysql';
|
||||
import { newZoneSerial, uiValue, utcDay } from '../harness/records';
|
||||
@@ -207,7 +207,7 @@ test.describe('core flow', () => {
|
||||
const change = await begin(world, zone);
|
||||
const mark = await world.db.auditMaxId();
|
||||
const deleted = await adminUi.deleteRecord({ name: rec.name === '' ? '@' : rec.name, type: rec.type, value: uiValue(rec.type, rec.data) });
|
||||
expect([200, 204]).toContain(deleted.status);
|
||||
expect(deleted.status).toBe(200);
|
||||
if (deleted.status === 200) expect(deleted.json).toMatchObject({ warnings: expect.any(Array) });
|
||||
await threeWayGone(world, adminUi, zone, rec, change, what);
|
||||
expect(await world.db.recordById(before.id)).toBeUndefined();
|
||||
@@ -558,6 +558,56 @@ test.describe('core flow', () => {
|
||||
await servedZone(world, zoneC);
|
||||
});
|
||||
|
||||
test('noncanonical zones and selected SOA rows can be repaired through the UI', async ({ world }) => {
|
||||
test.setTimeout(180_000);
|
||||
const api = adminApi;
|
||||
const zone = world.zoneName('repair-');
|
||||
expect((await api.post('/zones', { name: zone, ns: `ns1.${zone}`, mbox: `hostmaster@${zone}`, extra_ns: [], refresh: 3600, retry: 600, expire: 604800, minttl: 300, ttl: 3600 })).status).toBe(201);
|
||||
const ui = adminUi;
|
||||
await waitForZone(world.g, zone, { recorder: world.recorder });
|
||||
const baseline = await world.db.records(zone);
|
||||
for (const [name, storedZone, code, ip] of [
|
||||
['nodot', zone.slice(0, -1), 'zone_not_fqdn', '192.0.2.71'],
|
||||
['upper', zone.toUpperCase(), 'zone_case', '192.0.2.72'],
|
||||
]) {
|
||||
const id = await world.db.insertRaw({ zone: storedZone, name, ttl: 300, content: JSON.stringify({ ip }), record_type: 'A' });
|
||||
await ui.openZone(zone);
|
||||
expect((await ui.problems()).some((p) => p.code === code)).toBe(true);
|
||||
await ui.editRecord({ name, type: 'A' }, { name, type: 'A', ttl: '300', fields: { ip } }, { expectStatus: 200 });
|
||||
expect((await world.db.recordById(id))?.zone).toBe(zone);
|
||||
await threeWay(world, ui, zone, { name, type: 'A', ttl: 300, data: { ip } }, null, code);
|
||||
}
|
||||
const soa = baseline.find((row) => row.record_type === 'SOA')!;
|
||||
const duplicateContent = JSON.stringify({ ...JSON.parse(soa.content!), ns: 'duplicate.example.net.' });
|
||||
const duplicateId = await world.db.insertRaw({ zone, name: '', ttl: soa.ttl, content: duplicateContent, record_type: 'SOA' });
|
||||
await ui.openZone(zone);
|
||||
expect((await ui.problems()).some((p) => p.code === 'soa_multiple')).toBe(true);
|
||||
await ui.deleteRecord({ name: '@', type: 'SOA', value: duplicateContent }, { expectStatus: 200 });
|
||||
expect(await world.db.recordById(duplicateId)).toBeUndefined();
|
||||
expect(await world.db.recordById(soa.id)).toBeDefined();
|
||||
await ui.expectRow({ name: '@', type: 'SOA' });
|
||||
await servedZone(world, zone);
|
||||
const subId = await world.db.insertRaw({ zone, name: 'sub', ttl: soa.ttl, content: soa.content, record_type: 'SOA' });
|
||||
await ui.openZone(zone);
|
||||
expect((await ui.problems()).some((p) => p.code === 'soa_not_apex')).toBe(true);
|
||||
expect((await ui.problems()).some((p) => p.code === 'soa_multiple')).toBe(true);
|
||||
await ui.deleteRecord({ name: '@', type: 'SOA' }, { expectStatus: 200 });
|
||||
expect(await world.db.recordById(soa.id)).toBeUndefined();
|
||||
const row = await ui.row({ name: 'sub', type: 'SOA' });
|
||||
await row.getByRole('button', { name: /^Edit / }).click();
|
||||
await expect(ui.page.locator('#soa-dialog')).toBeVisible();
|
||||
for (const [key, value] of Object.entries({ ns: `ns1.${zone}`, mbox: `hostmaster.${zone}`, ttl: '3600', refresh: '3600', retry: '600', expire: '604800', minttl: '300' })) await ui.page.fill(`#soa-${key}`, value);
|
||||
const response = ui.page.waitForResponse((r) => r.request().method() === 'PUT' && new URL(r.url()).pathname.endsWith('/soa'));
|
||||
await ui.page.locator('#soa-form button[type=submit]').click();
|
||||
expect((await response).status()).toBe(200);
|
||||
await ui.settle();
|
||||
expect((await world.db.recordById(subId))?.name).toBe('');
|
||||
await ui.expectRow({ name: '@', type: 'SOA' });
|
||||
expect((await api.get(`${zp(zone)}/check`)).json.problems.filter((p: { severity: string }) => p.severity === 'error')).toEqual([]);
|
||||
for (const original of baseline.filter((r) => r.id !== soa.id)) expect(await world.db.recordById(original.id)).toEqual(original);
|
||||
await servedZone(world, zone);
|
||||
});
|
||||
|
||||
test('7. users and delegation: roles, zone visibility, revocation, promotion, deletion and the last active admin', async ({ world }) => {
|
||||
test.setTimeout(600_000);
|
||||
zoneB = `${world.unique('second-')}.core.test.`;
|
||||
@@ -990,7 +1040,7 @@ test.describe('core flow', () => {
|
||||
const zc = findAudit(await auditSince(world, cmark), 'zone_create', 201);
|
||||
const removed = JSON.stringify(parsedJson(ZONE_CREATE_DELEGATIONS_IN === 'before' ? zc.before_value : [zc.before_value, zc.after_value]));
|
||||
expect(removed, 'the creation audit row lists the removed delegations').toContain(user2.username);
|
||||
if (REVIEW_FIXES) expect(JSON.stringify(parsedJson(zc.after_value)), 'removed delegations are not in after').not.toContain(`"username":"${user2.username}"`);
|
||||
expect(JSON.stringify(parsedJson(zc.after_value)), 'removed delegations are not in after').not.toContain(`"username":"${user2.username}"`);
|
||||
await waitForZone(world.g, zoneD, { recorder: world.recorder });
|
||||
await servedZone(world, zoneD);
|
||||
});
|
||||
|
||||
@@ -60,7 +60,7 @@ test('a long operator session preserves state and audit invariants through mixed
|
||||
await threeWay(world, ui, zone, replacement, change, operation);
|
||||
model.set(current.name, replacement);
|
||||
} else {
|
||||
expect([200, 204]).toContain((await ui.deleteRecord(match)).status);
|
||||
expect((await ui.deleteRecord(match)).status).toBe(200);
|
||||
await threeWayGone(world, ui, zone, current, change, operation);
|
||||
model.delete(current.name);
|
||||
}
|
||||
|
||||
+15
-3
@@ -4,9 +4,11 @@
|
||||
import { test, expect } from '../harness/fixtures';
|
||||
import { up, zp } from '../harness/api';
|
||||
import { importApplyBody } from '../harness/decisions';
|
||||
import { waitForZone } from '../harness/dig';
|
||||
import { parseRR, waitForZone } from '../harness/dig';
|
||||
import { COREDNS_HOST } from '../harness/env';
|
||||
import { run } from '../harness/proc';
|
||||
import { address, addAddress, createZone, restartWithSessions, zoneInput } from '../harness/personas';
|
||||
import { begin, storedRow, threeWay } from '../harness/verify';
|
||||
import { begin, servedZone, threeWay } from '../harness/verify';
|
||||
|
||||
test.use({ group: 'power' });
|
||||
|
||||
@@ -75,7 +77,16 @@ test('a power user operates a large installation, with restart and edit conflict
|
||||
await waitForZone(world.g, imports, { recorder: world.recorder });
|
||||
await threeWay(world, first, imports, { ...address('load-0', ip), type: 'A' }, importChange, 'large import');
|
||||
expect(await world.db.records(imports)).toHaveLength(1202);
|
||||
await storedRow(world, imports, { ...address('load-1199', ip), type: 'A' });
|
||||
const imported = (await world.db.records(imports)).filter((row) => row.name.startsWith('load-'));
|
||||
expect(imported).toHaveLength(1200);
|
||||
const queries = imported.map((row) => `${row.name}.${imports} A`).join('\n') + '\n';
|
||||
const batch = await run('dig', [`@${COREDNS_HOST}`, '-p', String(world.g.dnsPort), '+norecurse', '+nocookie', '+time=3', '+tries=2', '+noall', '+answer', '-f', '-'], { input: queries, timeoutMs: 120_000 });
|
||||
expect(batch.code, batch.stderr).toBe(0);
|
||||
const answers = batch.stdout.split('\n').filter((line) => line.trim() && !line.startsWith(';')).map(parseRR);
|
||||
expect(answers.map((rr) => `${rr.name} ${rr.ttl} ${rr.type} ${rr.data}`).sort()).toEqual(
|
||||
imported.map((row) => `${row.name}.${imports} 300 A ${ip}`).sort(),
|
||||
);
|
||||
for (const row of imported) expect(row).toMatchObject({ zone: imports, ttl: 300, record_type: 'A', content: JSON.stringify({ ip }) });
|
||||
expect((await api.get(`${zp(imports)}/check`)).json.problems).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -100,4 +111,5 @@ test('a power user imports the supported types in one transaction', async ({ wor
|
||||
expect((await ui.importPreview(zone, entries.map(([n, t, v]) => `${n} 300 IN ${t} ${v}\n`).join(''), 'merge')).status).toBe(200);
|
||||
expect((await ui.importApply()).status).toBe(200);
|
||||
expect((await world.db.records(zone)).map((row) => row.record_type).sort()).toEqual(['A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'NS', 'SOA', 'SRV', 'TXT']);
|
||||
await servedZone(world, zone);
|
||||
});
|
||||
Reference in new issue
Block a user