feat(routes,email): persist system DNS routes with runtime hydration and add reusable email ops DNS helpers
This commit is contained in:
65
test/test.email-dns-records.node.ts
Normal file
65
test/test.email-dns-records.node.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||
import { buildEmailDnsRecords } from '../ts/email/index.js';
|
||||
|
||||
tap.test('buildEmailDnsRecords uses the configured mail hostname for MX and includes DKIM when provided', async () => {
|
||||
const records = buildEmailDnsRecords({
|
||||
domain: 'example.com',
|
||||
hostname: 'mail.example.com',
|
||||
selector: 'selector1',
|
||||
dkimValue: 'v=DKIM1; h=sha256; k=rsa; p=abc123',
|
||||
statuses: {
|
||||
mx: 'valid',
|
||||
spf: 'missing',
|
||||
dkim: 'valid',
|
||||
dmarc: 'unchecked',
|
||||
},
|
||||
});
|
||||
|
||||
expect(records).toEqual([
|
||||
{
|
||||
type: 'MX',
|
||||
name: 'example.com',
|
||||
value: '10 mail.example.com',
|
||||
status: 'valid',
|
||||
},
|
||||
{
|
||||
type: 'TXT',
|
||||
name: 'example.com',
|
||||
value: 'v=spf1 a mx ~all',
|
||||
status: 'missing',
|
||||
},
|
||||
{
|
||||
type: 'TXT',
|
||||
name: 'selector1._domainkey.example.com',
|
||||
value: 'v=DKIM1; h=sha256; k=rsa; p=abc123',
|
||||
status: 'valid',
|
||||
},
|
||||
{
|
||||
type: 'TXT',
|
||||
name: '_dmarc.example.com',
|
||||
value: 'v=DMARC1; p=none; rua=mailto:dmarc@example.com',
|
||||
status: 'unchecked',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
tap.test('buildEmailDnsRecords omits DKIM when no value is provided', async () => {
|
||||
const records = buildEmailDnsRecords({
|
||||
domain: 'example.net',
|
||||
hostname: 'smtp.example.net',
|
||||
mxPriority: 20,
|
||||
});
|
||||
|
||||
expect(records.map((record) => record.name)).toEqual([
|
||||
'example.net',
|
||||
'example.net',
|
||||
'_dmarc.example.net',
|
||||
]);
|
||||
expect(records[0].value).toEqual('20 smtp.example.net');
|
||||
});
|
||||
|
||||
tap.test('cleanup', async () => {
|
||||
await tap.stopForcefully();
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
Reference in New Issue
Block a user