Add test to verify DNS records of cloudron
This commit is contained in:
parent
72691abf50
commit
096b30026b
35
cloudron.js
35
cloudron.js
@ -5,6 +5,7 @@
|
||||
var assert = require('assert'),
|
||||
common = require('./common.js'),
|
||||
debug = require('debug')('e2e:cloudron'),
|
||||
dns = require('dns'),
|
||||
querystring = require('querystring'),
|
||||
request = require('superagent-sync'),
|
||||
sleep = require('sleep').sleep,
|
||||
@ -253,3 +254,37 @@ Cloudron.prototype.reboot = function () {
|
||||
common.verifyResponse2(res, 'Box could not be rebooted');
|
||||
this.waitForBox();
|
||||
};
|
||||
|
||||
Cloudron.prototype.checkSPF = function (callback) {
|
||||
dns.resolveTxt(this._box.domain, function (error, records) {
|
||||
if (error) return callback(error);
|
||||
if (records.length !== 1) return callback(new Error('Got ' + records.length + ' TXT records. Expecting 1'));
|
||||
|
||||
if (records[0].search(new RegExp('^v=spf1 ip4:' + this._box.ip + ' ~all$')) !== 0) return callback(new Error('Bad SPF record. ' + records[0]));
|
||||
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
Cloudron.prototype.checkDKIM = function (callback) {
|
||||
dns.resolveTxt('mail._domainkey.' + this._box.domain, function (error, records) {
|
||||
if (error) return callback(error);
|
||||
if (records.length !== 1) return callback(new Error('Got ' + records.length + ' TXT records. Expecting 1'));
|
||||
|
||||
if (records[0].search(/^"v=DKIM1; t=s; p=.*"$/) !== 0) return callback(new Error('Bad DKIM record. ' + records[0]));
|
||||
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
Cloudron.prototype.checkDMARC = function (callback) {
|
||||
dns.resolveTxt('_dmarc.' + this._box.domain, function (error, records) {
|
||||
if (error) return callback(error);
|
||||
if (records.length !== 1) return callback(new Error('Got ' + records.length + ' TXT records. Expecting 1'));
|
||||
|
||||
if (records[0].search(/^"v=DMARC1; p=none; pct=100; rua=mailto:.*; ruf=.*"$/) !== 0) return callback(new Error('Bad DMARC record. ' + records[0]));
|
||||
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
'use strict';
|
||||
|
||||
var AppStore = require('../appstore.js'),
|
||||
async = require('async'),
|
||||
Cloudron = require('../cloudron.js'),
|
||||
common = require('../common.js'),
|
||||
request = require('superagent-sync'),
|
||||
@ -59,6 +60,14 @@ describe('Appstore new user flow', function () {
|
||||
cloudron = new Cloudron(box);
|
||||
});
|
||||
|
||||
it('has setup DNS records correctly', function (done) {
|
||||
async.series([
|
||||
cloudron.checkSPF,
|
||||
cloudron.checkDKIM,
|
||||
cloudron.CheckDMARC
|
||||
], done);
|
||||
});
|
||||
|
||||
it('can activate the box', function () {
|
||||
cloudron.activate(owner);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user