Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fauno committed Nov 5, 2024
1 parent 36450d6 commit b62f010
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dns/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ test('basic dns resolve', async t => {
const response = await dnsClient.query(`_dnslink.${site.domain}`, 'TXT')
t.true(hasAnswer(response, 'ipns'), 'returned dns query has an ipns entry')
t.true(hasAnswer(response, 'hyper'), 'returned dns query has a hyper entry')
t.is(response.answers.filter(ans => ![DNS.Packet.Type.NS, DNS.Packet.TYPE.TXT].includes(ans.type)).length, 0, 'should not include any non-TXT and non-NS entries')
t.is(response.answers.filter(ans => ans.type !== DNS.Packet.TYPE.TXT && ans.type !== DNS.Packet.TYPE.NS).length, 0, 'should not include any non-TXT and non-NS entries')
})

test('dns should not resolve unknown domains', async t => {
const dnsServer = (await mockDnsServer())[1]
const port = dnsServer.addresses().udp?.port as number
const dnsClient = makeDnsClient(port)
const response = await dnsClient.query('_dnslink.unknown.com', 'TXT')
t.is(response.answers.length, 0, 'should not have any answers for unknown domains')
t.is(response.answers.filter(ans => ans.type === DNS.Packet.TYPE.TXT).length, 0, 'should not have any TXT answers for unknown domains')
})
2 changes: 2 additions & 0 deletions dns/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export async function initDnsServer (port: number, store: SiteConfigStore, logge
const [{ name }] = request.questions
logger?.info(`[dns] ${rinfo.address}:${rinfo.port} asked for ${name}`)

// It will always answer with a NS record so new domains can be
// set up and checked.
response.answers.push({
name,
type: dns2.Packet.TYPE.NS,
Expand Down

0 comments on commit b62f010

Please sign in to comment.