2024-06-02 13:34:19 +00:00
|
|
|
import { expect, tap } from '@push.rocks/tapbundle';
|
2016-11-15 20:39:21 +00:00
|
|
|
|
2024-06-02 13:34:19 +00:00
|
|
|
import * as smartdns from '../ts_client/index.js';
|
2016-11-15 20:39:21 +00:00
|
|
|
|
2018-05-13 13:51:04 +00:00
|
|
|
let testDnsly: smartdns.Smartdns;
|
2016-11-15 20:39:21 +00:00
|
|
|
|
2017-07-18 13:45:06 +00:00
|
|
|
tap.test('should create an instance of Dnsly', async () => {
|
2020-02-15 16:41:37 +00:00
|
|
|
testDnsly = new smartdns.Smartdns({});
|
2022-07-27 06:59:29 +00:00
|
|
|
expect(testDnsly).toBeInstanceOf(smartdns.Smartdns);
|
2018-05-13 13:51:04 +00:00
|
|
|
});
|
2016-11-15 20:39:21 +00:00
|
|
|
|
2017-07-18 13:45:06 +00:00
|
|
|
tap.test('should get an A DNS Record', async () => {
|
2023-04-08 09:30:48 +00:00
|
|
|
return expect(await testDnsly.getRecordsA('dnsly_a.bleu.de')).toEqual([
|
2018-05-13 13:51:04 +00:00
|
|
|
{
|
|
|
|
name: 'dnsly_a.bleu.de',
|
|
|
|
value: '127.0.0.1',
|
2020-02-15 16:41:37 +00:00
|
|
|
dnsSecEnabled: false,
|
2020-08-05 15:37:51 +00:00
|
|
|
type: 'A',
|
|
|
|
},
|
2018-05-13 13:51:04 +00:00
|
|
|
]);
|
|
|
|
});
|
2017-01-26 23:11:13 +00:00
|
|
|
|
2017-07-18 13:45:06 +00:00
|
|
|
tap.test('should get an AAAA Record', async () => {
|
2023-04-08 09:30:48 +00:00
|
|
|
return expect(await testDnsly.getRecordsAAAA('dnsly_aaaa.bleu.de')).toEqual([
|
2018-05-13 13:51:04 +00:00
|
|
|
{
|
|
|
|
name: 'dnsly_aaaa.bleu.de',
|
|
|
|
value: '::1',
|
2020-02-15 16:41:37 +00:00
|
|
|
dnsSecEnabled: false,
|
2020-08-05 15:37:51 +00:00
|
|
|
type: 'AAAA',
|
|
|
|
},
|
2018-05-13 13:51:04 +00:00
|
|
|
]);
|
|
|
|
});
|
2016-11-15 20:39:21 +00:00
|
|
|
|
2017-07-18 13:45:06 +00:00
|
|
|
tap.test('should get a txt record', async () => {
|
2023-04-08 09:30:48 +00:00
|
|
|
return expect(await testDnsly.getRecordsTxt('dnsly_txt.bleu.de')).toEqual([
|
2018-05-13 13:51:04 +00:00
|
|
|
{
|
|
|
|
name: 'dnsly_txt.bleu.de',
|
|
|
|
value: 'sometext_txt',
|
2020-02-15 16:41:37 +00:00
|
|
|
type: 'TXT',
|
2020-08-05 15:37:51 +00:00
|
|
|
dnsSecEnabled: false,
|
|
|
|
},
|
2018-05-13 13:51:04 +00:00
|
|
|
]);
|
|
|
|
});
|
2016-11-15 21:40:40 +00:00
|
|
|
|
2017-07-18 13:45:06 +00:00
|
|
|
tap.test('should, get a mx record for a domain', async () => {
|
2023-04-08 09:30:48 +00:00
|
|
|
const res = await testDnsly.getRecords('bleu.de', 'MX');
|
2018-05-13 13:51:04 +00:00
|
|
|
console.log(res);
|
|
|
|
});
|
2017-01-26 23:11:13 +00:00
|
|
|
|
2017-07-18 13:45:06 +00:00
|
|
|
tap.test('should check until DNS is available', async () => {
|
2023-03-23 00:41:35 +00:00
|
|
|
return expect(
|
|
|
|
await testDnsly.checkUntilAvailable('dnsly_txt.bleu.de', 'TXT', 'sometext_txt')
|
|
|
|
).toBeTrue();
|
2018-05-13 13:51:04 +00:00
|
|
|
});
|
2017-01-26 23:11:13 +00:00
|
|
|
|
2017-07-18 13:45:06 +00:00
|
|
|
tap.test('should check until DNS is available an return false if it fails', async () => {
|
2023-03-23 00:41:35 +00:00
|
|
|
return expect(
|
|
|
|
await testDnsly.checkUntilAvailable('dnsly_txt.bleu.de', 'TXT', 'sometext_txt2')
|
|
|
|
).toBeFalse();
|
2018-05-13 13:51:04 +00:00
|
|
|
});
|
2017-01-26 23:37:32 +00:00
|
|
|
|
2017-07-18 13:45:06 +00:00
|
|
|
tap.test('should check until DNS is available an return false if it fails', async () => {
|
2023-03-23 00:41:35 +00:00
|
|
|
return expect(
|
|
|
|
await testDnsly.checkUntilAvailable('dnsly_txtNotThere.bleu.de', 'TXT', 'sometext_txt2')
|
|
|
|
).toBeFalse();
|
2018-05-13 13:51:04 +00:00
|
|
|
});
|
2017-07-18 13:45:06 +00:00
|
|
|
|
2018-05-13 13:51:04 +00:00
|
|
|
tap.test('should get name server for hostname', async () => {
|
2023-04-08 09:30:48 +00:00
|
|
|
let result = await testDnsly.getNameServers('bleu.de');
|
2018-05-13 13:51:04 +00:00
|
|
|
console.log(result);
|
|
|
|
});
|
|
|
|
|
2020-02-15 16:41:37 +00:00
|
|
|
tap.test('should detect dns sec', async () => {
|
2023-04-08 09:30:48 +00:00
|
|
|
const result = await testDnsly.getRecordsA('lossless.com');
|
2020-02-15 16:41:37 +00:00
|
|
|
console.log(result[0]);
|
2022-07-27 06:59:29 +00:00
|
|
|
expect(result[0].dnsSecEnabled).toBeTrue();
|
2020-02-15 16:46:04 +00:00
|
|
|
});
|
2020-02-15 16:41:37 +00:00
|
|
|
|
2018-05-13 13:51:04 +00:00
|
|
|
tap.start();
|