check A records

This commit is contained in:
Girish Ramakrishnan 2015-09-29 17:32:21 -07:00
parent fd78e7b590
commit e0926d1f92
2 changed files with 14 additions and 0 deletions

View File

@ -255,6 +255,18 @@ Cloudron.prototype.reboot = function () {
this.waitForBox();
};
Cloudron.prototype.checkA = function (callback) {
var that = this;
dns.resolve4(this._box.domain, function (error, records) {
if (error) return callback(error);
if (records.length !== 1) return callback(new Error('Got ' + JSON.stringify(records) + ' A records. Expecting 1 length array'));
if (records[0][0] !== that._box.ip) return callback(new Error('Bad A record. ' + records[0][0]));
callback();
});
};
Cloudron.prototype.checkSPF = function (callback) {
var that = this;
dns.resolveTxt(this._box.domain, function (error, records) {

View File

@ -62,6 +62,7 @@ describe('Appstore new user flow', function () {
it('has setup DNS records correctly', function (done) {
async.series([
cloudron.checkA.bind(cloudron),
cloudron.checkSPF.bind(cloudron),
cloudron.checkDKIM.bind(cloudron),
cloudron.checkDMARC.bind(cloudron)
@ -106,6 +107,7 @@ describe('Appstore new user flow', function () {
}
async.series([
expectError(cloudron.checkA.bind(cloudron)),
expectError(cloudron.checkSPF.bind(cloudron)),
expectError(cloudron.checkDKIM.bind(cloudron)),
expectError(cloudron.checkDMARC.bind(cloudron))