sysinfo: async'ify
in the process, provision, dyndns, mail, dns also got further asyncified
This commit is contained in:
@@ -51,16 +51,15 @@ describe('Mail API', function () {
|
||||
const dns = require('../../dns.js');
|
||||
|
||||
// replace dns resolveTxt()
|
||||
resolve = dns.resolve;
|
||||
dns.resolve = function (hostname, type, options, callback) {
|
||||
resolve = dns.promises.resolve;
|
||||
dns.promises.resolve = async function (hostname, type/*, options*/) {
|
||||
expect(hostname).to.be.a('string');
|
||||
expect(callback).to.be.a('function');
|
||||
|
||||
if (!dnsAnswerQueue[hostname] || !(type in dnsAnswerQueue[hostname])) return callback(new Error('no mock answer'));
|
||||
if (!dnsAnswerQueue[hostname] || !(type in dnsAnswerQueue[hostname])) throw new Error('no mock answer');
|
||||
|
||||
if (dnsAnswerQueue[hostname][type] === null) return callback(new Error({ code: 'ENODATA'} ));
|
||||
if (dnsAnswerQueue[hostname][type] === null) throw new Error({ code: 'ENODATA'} );
|
||||
|
||||
callback(null, dnsAnswerQueue[hostname][type]);
|
||||
return dnsAnswerQueue[hostname][type];
|
||||
};
|
||||
|
||||
dkimDomain = `cloudron._domainkey.${dashboardDomain}`; // no suffix for provisioned domains
|
||||
@@ -81,7 +80,7 @@ describe('Mail API', function () {
|
||||
after(function (done) {
|
||||
const dns = require('../../dns.js');
|
||||
|
||||
dns.resolve = resolve;
|
||||
dns.promises.resolve = resolve;
|
||||
|
||||
done();
|
||||
});
|
||||
@@ -108,8 +107,6 @@ describe('Mail API', function () {
|
||||
.query({ access_token: owner.token });
|
||||
expect(response.statusCode).to.equal(200);
|
||||
|
||||
console.dir(response.body);
|
||||
|
||||
expect(response.body.dns.dkim).to.be.an('object');
|
||||
expect(response.body.dns.dkim.domain).to.eql(dkimDomain);
|
||||
expect(response.body.dns.dkim.type).to.eql('TXT');
|
||||
@@ -228,7 +225,7 @@ describe('Mail API', function () {
|
||||
|
||||
dnsAnswerQueue[spfDomain].TXT = [['v=spf1 a:example.com a:' + settings.mailFqdn() + ' ~all']];
|
||||
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}` + '/status')
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}/status`)
|
||||
.query({ access_token: owner.token });
|
||||
|
||||
expect(response.statusCode).to.equal(200);
|
||||
@@ -246,7 +243,7 @@ describe('Mail API', function () {
|
||||
|
||||
dnsAnswerQueue[dmarcDomain].TXT = [['v=DMARC1; p=reject; rua=mailto:rua@example.com; pct=100']];
|
||||
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}` + '/status')
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/mail/${dashboardDomain}/status`)
|
||||
.query({ access_token: owner.token });
|
||||
|
||||
expect(response.statusCode).to.equal(200);
|
||||
|
||||
Reference in New Issue
Block a user