diff --git a/src/dns/cloudflare.js b/src/dns/cloudflare.js index 90c52fda1..b6b2d2e06 100644 --- a/src/dns/cloudflare.js +++ b/src/dns/cloudflare.js @@ -7,7 +7,7 @@ exports = module.exports = { get, del, wait, - verifyDnsConfig + verifyDomainConfig }; const assert = require('assert'), @@ -53,29 +53,29 @@ function translateRequestError(result, callback) { callback(new BoxError(BoxError.EXTERNAL_ERROR, util.format('%s %j', result.statusCode, result.body))); } -function createRequest(method, url, dnsConfig) { +function createRequest(method, url, domainConfig) { assert.strictEqual(typeof method, 'string'); assert.strictEqual(typeof url, 'string'); - assert.strictEqual(typeof dnsConfig, 'object'); + assert.strictEqual(typeof domainConfig, 'object'); let request = superagent(method, url) .timeout(30 * 1000); - if (dnsConfig.tokenType === 'GlobalApiKey') { - request.set('X-Auth-Key', dnsConfig.token).set('X-Auth-Email', dnsConfig.email); + if (domainConfig.tokenType === 'GlobalApiKey') { + request.set('X-Auth-Key', domainConfig.token).set('X-Auth-Email', domainConfig.email); } else { - request.set('Authorization', 'Bearer ' + dnsConfig.token); + request.set('Authorization', 'Bearer ' + domainConfig.token); } return request; } -function getZoneByName(dnsConfig, zoneName, callback) { - assert.strictEqual(typeof dnsConfig, 'object'); +function getZoneByName(domainConfig, zoneName, callback) { + assert.strictEqual(typeof domainConfig, 'object'); assert.strictEqual(typeof zoneName, 'string'); assert.strictEqual(typeof callback, 'function'); - createRequest('GET', CLOUDFLARE_ENDPOINT + '/zones?name=' + zoneName + '&status=active', dnsConfig) + createRequest('GET', CLOUDFLARE_ENDPOINT + '/zones?name=' + zoneName + '&status=active', domainConfig) .end(function (error, result) { if (error && !error.response) return callback(error); if (result.statusCode !== 200 || result.body.success !== true) return translateRequestError(result, callback); @@ -86,14 +86,14 @@ function getZoneByName(dnsConfig, zoneName, callback) { } // gets records filtered by zone, type and fqdn -function getDnsRecords(dnsConfig, zoneId, fqdn, type, callback) { - assert.strictEqual(typeof dnsConfig, 'object'); +function getDnsRecords(domainConfig, zoneId, fqdn, type, callback) { + assert.strictEqual(typeof domainConfig, 'object'); assert.strictEqual(typeof zoneId, 'string'); assert.strictEqual(typeof fqdn, 'string'); assert.strictEqual(typeof type, 'string'); assert.strictEqual(typeof callback, 'function'); - createRequest('GET', CLOUDFLARE_ENDPOINT + '/zones/' + zoneId + '/dns_records', dnsConfig) + createRequest('GET', CLOUDFLARE_ENDPOINT + '/zones/' + zoneId + '/dns_records', domainConfig) .query({ type: type, name: fqdn }) .end(function (error, result) { if (error && !error.response) return callback(error); @@ -112,18 +112,18 @@ function upsert(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, fqdn = dns.fqdn(location, domainObject); debug('upsert: %s for zone %s of type %s with values %j', fqdn, zoneName, type, values); - getZoneByName(dnsConfig, zoneName, function(error, result) { + getZoneByName(domainConfig, zoneName, function(error, result) { if (error) return callback(error); let zoneId = result.id; - getDnsRecords(dnsConfig, zoneId, fqdn, type, function (error, dnsRecords) { + getDnsRecords(domainConfig, zoneId, fqdn, type, function (error, dnsRecords) { if (error) return callback(error); let i = 0; // // used to track available records to update instead of create @@ -148,7 +148,7 @@ function upsert(domainObject, location, type, values, callback) { if (i >= dnsRecords.length) { // create a new record debug(`upsert: Adding new record fqdn: ${fqdn}, zoneName: ${zoneName} proxied: false`); - createRequest('POST', CLOUDFLARE_ENDPOINT + '/zones/' + zoneId + '/dns_records', dnsConfig) + createRequest('POST', CLOUDFLARE_ENDPOINT + '/zones/' + zoneId + '/dns_records', domainConfig) .send(data) .end(function (error, result) { if (error && !error.response) return iteratorCallback(error); @@ -161,7 +161,7 @@ function upsert(domainObject, location, type, values, callback) { debug(`upsert: Updating existing record fqdn: ${fqdn}, zoneName: ${zoneName} proxied: ${data.proxied}`); - createRequest('PUT', CLOUDFLARE_ENDPOINT + '/zones/' + zoneId + '/dns_records/' + dnsRecords[i].id, dnsConfig) + createRequest('PUT', CLOUDFLARE_ENDPOINT + '/zones/' + zoneId + '/dns_records/' + dnsRecords[i].id, domainConfig) .send(data) .end(function (error, result) { ++i; // increment, as we have consumed the record @@ -183,14 +183,14 @@ function get(domainObject, location, type, callback) { assert.strictEqual(typeof type, 'string'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, fqdn = dns.fqdn(location, domainObject); - getZoneByName(dnsConfig, zoneName, function(error, zone) { + getZoneByName(domainConfig, zoneName, function(error, zone) { if (error) return callback(error); - getDnsRecords(dnsConfig, zone.id, fqdn, type, function (error, result) { + getDnsRecords(domainConfig, zone.id, fqdn, type, function (error, result) { if (error) return callback(error); var tmp = result.map(function (record) { return record.content; }); @@ -208,26 +208,26 @@ function del(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, fqdn = dns.fqdn(location, domainObject); - getZoneByName(dnsConfig, zoneName, function(error, zone) { + getZoneByName(domainConfig, zoneName, function(error, zone) { if (error) return callback(error); - getDnsRecords(dnsConfig, zone.id, fqdn, type, function(error, result) { + getDnsRecords(domainConfig, zone.id, fqdn, type, function(error, result) { if (error) return callback(error); if (result.length === 0) return callback(null); - var zoneId = result[0].zone_id; + const zoneId = result[0].zone_id; - var tmp = result.filter(function (record) { return values.some(function (value) { return value === record.content; }); }); + const tmp = result.filter(function (record) { return values.some(function (value) { return value === record.content; }); }); debug('del: %j', tmp); if (tmp.length === 0) return callback(null); async.eachSeries(tmp, function (record, callback) { - createRequest('DELETE', CLOUDFLARE_ENDPOINT + '/zones/'+ zoneId + '/dns_records/' + record.id, dnsConfig) + createRequest('DELETE', CLOUDFLARE_ENDPOINT + '/zones/'+ zoneId + '/dns_records/' + record.id, domainConfig) .end(function (error, result) { if (error && !error.response) return callback(error); if (result.statusCode !== 200 || result.body.success !== true) return translateRequestError(result, callback); @@ -253,18 +253,18 @@ function wait(domainObject, location, type, value, options, callback) { assert(options && typeof options === 'object'); // { interval: 5000, times: 50000 } assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, fqdn = dns.fqdn(location, domainObject); debug('wait: %s for zone %s of type %s', fqdn, zoneName, type); - getZoneByName(dnsConfig, zoneName, function(error, result) { + getZoneByName(domainConfig, zoneName, function(error, result) { if (error) return callback(error); let zoneId = result.id; - getDnsRecords(dnsConfig, zoneId, fqdn, type, function (error, dnsRecords) { + getDnsRecords(domainConfig, zoneId, fqdn, type, function (error, dnsRecords) { if (error) return callback(error); if (dnsRecords.length === 0) return callback(new BoxError(BoxError.NOT_FOUND, 'Domain not found')); @@ -277,27 +277,27 @@ function wait(domainObject, location, type, value, options, callback) { }); } -function verifyDnsConfig(domainObject, callback) { +function verifyDomainConfig(domainObject, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName; // token can be api token or global api key - if (!dnsConfig.token || typeof dnsConfig.token !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'token must be a non-empty string', { field: 'token' })); - if (dnsConfig.tokenType !== 'GlobalApiKey' && dnsConfig.tokenType !== 'ApiToken') return callback(new BoxError(BoxError.BAD_FIELD, 'tokenType is required', { field: 'tokenType' })); + if (!domainConfig.token || typeof domainConfig.token !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'token must be a non-empty string', { field: 'token' })); + if (domainConfig.tokenType !== 'GlobalApiKey' && domainConfig.tokenType !== 'ApiToken') return callback(new BoxError(BoxError.BAD_FIELD, 'tokenType is required', { field: 'tokenType' })); - if (dnsConfig.tokenType === 'GlobalApiKey') { - if (typeof dnsConfig.email !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'email must be a non-empty string', { field: 'email' })); + if (domainConfig.tokenType === 'GlobalApiKey') { + if (typeof domainConfig.email !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'email must be a non-empty string', { field: 'email' })); } const ip = '127.0.0.1'; - var credentials = { - token: dnsConfig.token, - tokenType: dnsConfig.tokenType, - email: dnsConfig.email || null + const credentials = { + token: domainConfig.token, + tokenType: domainConfig.tokenType, + email: domainConfig.email || null }; if (process.env.BOX_ENV === 'test') return callback(null, credentials); // this shouldn't be here @@ -306,11 +306,11 @@ function verifyDnsConfig(domainObject, callback) { if (error && error.code === 'ENOTFOUND') return callback(new BoxError(BoxError.BAD_FIELD, 'Unable to resolve nameservers for this domain', { field: 'nameservers' })); if (error || !nameservers) return callback(new BoxError(BoxError.BAD_FIELD, error ? error.message : 'Unable to get nameservers', { field: 'nameservers' })); - getZoneByName(dnsConfig, zoneName, function(error, zone) { + getZoneByName(domainConfig, zoneName, function(error, zone) { if (error) return callback(error); if (!_.isEqual(zone.name_servers.sort(), nameservers.sort())) { - debug('verifyDnsConfig: %j and %j do not match', nameservers, zone.name_servers); + debug('verifyDomainConfig: %j and %j do not match', nameservers, zone.name_servers); return callback(new BoxError(BoxError.BAD_FIELD, 'Domain nameservers are not set to Cloudflare', { field: 'nameservers' })); } @@ -319,12 +319,12 @@ function verifyDnsConfig(domainObject, callback) { upsert(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record added'); + debug('verifyDomainConfig: Test A record added'); del(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record removed again'); + debug('verifyDomainConfig: Test A record removed again'); callback(null, credentials); }); diff --git a/src/dns/digitalocean.js b/src/dns/digitalocean.js index e6c6799f2..5838bf220 100644 --- a/src/dns/digitalocean.js +++ b/src/dns/digitalocean.js @@ -7,7 +7,7 @@ exports = module.exports = { get, del, wait, - verifyDnsConfig + verifyDomainConfig }; const assert = require('assert'), @@ -36,22 +36,22 @@ function injectPrivateFields(newConfig, currentConfig) { if (newConfig.token === constants.SECRET_PLACEHOLDER) newConfig.token = currentConfig.token; } -function getInternal(dnsConfig, zoneName, name, type, callback) { - assert.strictEqual(typeof dnsConfig, 'object'); +function getInternal(domainConfig, zoneName, name, type, callback) { + assert.strictEqual(typeof domainConfig, 'object'); assert.strictEqual(typeof zoneName, 'string'); assert.strictEqual(typeof name, 'string'); assert.strictEqual(typeof type, 'string'); assert.strictEqual(typeof callback, 'function'); - var nextPage = null, matchingRecords = []; + let nextPage = null, matchingRecords = []; debug(`getInternal: getting dns records of ${zoneName} with ${name} and type ${type}`); async.doWhilst(function (iteratorDone) { - var url = nextPage ? nextPage : DIGITALOCEAN_ENDPOINT + '/v2/domains/' + zoneName + '/records'; + const url = nextPage ? nextPage : DIGITALOCEAN_ENDPOINT + '/v2/domains/' + zoneName + '/records'; superagent.get(url) - .set('Authorization', 'Bearer ' + dnsConfig.token) + .set('Authorization', 'Bearer ' + domainConfig.token) .timeout(30 * 1000) .retry(5) .end(function (error, result) { @@ -84,13 +84,13 @@ function upsert(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || '@'; debug('upsert: %s for zone %s of type %s with values %j', name, zoneName, type, values); - getInternal(dnsConfig, zoneName, name, type, function (error, result) { + getInternal(domainConfig, zoneName, name, type, function (error, result) { if (error) return callback(error); // used to track available records to update instead of create @@ -114,7 +114,7 @@ function upsert(domainObject, location, type, values, callback) { if (i >= result.length) { superagent.post(DIGITALOCEAN_ENDPOINT + '/v2/domains/' + zoneName + '/records') - .set('Authorization', 'Bearer ' + dnsConfig.token) + .set('Authorization', 'Bearer ' + domainConfig.token) .send(data) .timeout(30 * 1000) .retry(5) @@ -130,7 +130,7 @@ function upsert(domainObject, location, type, values, callback) { }); } else { superagent.put(DIGITALOCEAN_ENDPOINT + '/v2/domains/' + zoneName + '/records/' + result[i].id) - .set('Authorization', 'Bearer ' + dnsConfig.token) + .set('Authorization', 'Bearer ' + domainConfig.token) .send(data) .timeout(30 * 1000) .retry(5) @@ -164,11 +164,11 @@ function get(domainObject, location, type, callback) { assert.strictEqual(typeof type, 'string'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || '@'; - getInternal(dnsConfig, zoneName, name, type, function (error, result) { + getInternal(domainConfig, zoneName, name, type, function (error, result) { if (error) return callback(error); // We only return the value string @@ -187,11 +187,11 @@ function del(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || '@'; - getInternal(dnsConfig, zoneName, name, type, function (error, result) { + getInternal(domainConfig, zoneName, name, type, function (error, result) { if (error) return callback(error); if (result.length === 0) return callback(null); @@ -205,7 +205,7 @@ function del(domainObject, location, type, values, callback) { // FIXME we only handle the first one currently superagent.del(DIGITALOCEAN_ENDPOINT + '/v2/domains/' + zoneName + '/records/' + tmp[0].id) - .set('Authorization', 'Bearer ' + dnsConfig.token) + .set('Authorization', 'Bearer ' + domainConfig.token) .timeout(30 * 1000) .retry(5) .end(function (error, result) { @@ -234,19 +234,19 @@ function wait(domainObject, location, type, value, options, callback) { waitForDns(fqdn, domainObject.zoneName, type, value, options, callback); } -function verifyDnsConfig(domainObject, callback) { +function verifyDomainConfig(domainObject, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName; - if (!dnsConfig.token || typeof dnsConfig.token !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'token must be a non-empty string', { field: 'token' })); + if (!domainConfig.token || typeof domainConfig.token !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'token must be a non-empty string', { field: 'token' })); const ip = '127.0.0.1'; var credentials = { - token: dnsConfig.token + token: domainConfig.token }; if (process.env.BOX_ENV === 'test') return callback(null, credentials); // this shouldn't be here @@ -256,7 +256,7 @@ function verifyDnsConfig(domainObject, callback) { if (error || !nameservers) return callback(new BoxError(BoxError.BAD_FIELD, error ? error.message : 'Unable to get nameservers', { field: 'nameservers' })); if (nameservers.map(function (n) { return n.toLowerCase(); }).indexOf('ns1.digitalocean.com') === -1) { - debug('verifyDnsConfig: %j does not contains DO NS', nameservers); + debug('verifyDomainConfig: %j does not contains DO NS', nameservers); return callback(new BoxError(BoxError.BAD_FIELD, 'Domain nameservers are not set to DigitalOcean', { field: 'nameservers' })); } @@ -265,12 +265,12 @@ function verifyDnsConfig(domainObject, callback) { upsert(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record added'); + debug('verifyDomainConfig: Test A record added'); del(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record removed again'); + debug('verifyDomainConfig: Test A record removed again'); callback(null, credentials); }); diff --git a/src/dns/gandi.js b/src/dns/gandi.js index 2912e2cf6..4f0d60e09 100644 --- a/src/dns/gandi.js +++ b/src/dns/gandi.js @@ -7,7 +7,7 @@ exports = module.exports = { get, del, wait, - verifyDnsConfig + verifyDomainConfig }; const assert = require('assert'), @@ -41,7 +41,7 @@ function upsert(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || '@'; @@ -53,7 +53,7 @@ function upsert(domainObject, location, type, values, callback) { }; superagent.put(`${GANDI_API}/domains/${zoneName}/records/${name}/${type}`) - .set('X-Api-Key', dnsConfig.token) + .set('X-Api-Key', domainConfig.token) .timeout(30 * 1000) .send(data) .end(function (error, result) { @@ -72,14 +72,14 @@ function get(domainObject, location, type, callback) { assert.strictEqual(typeof type, 'string'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || '@'; debug(`get: ${name} in zone ${zoneName} of type ${type}`); superagent.get(`${GANDI_API}/domains/${zoneName}/records/${name}/${type}`) - .set('X-Api-Key', dnsConfig.token) + .set('X-Api-Key', domainConfig.token) .timeout(30 * 1000) .end(function (error, result) { if (error && !error.response) return callback(new BoxError(BoxError.NETWORK_ERROR, error.message)); @@ -100,14 +100,14 @@ function del(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || '@'; debug(`del: ${name} in zone ${zoneName} of type ${type} with values ${JSON.stringify(values)}`); superagent.del(`${GANDI_API}/domains/${zoneName}/records/${name}/${type}`) - .set('X-Api-Key', dnsConfig.token) + .set('X-Api-Key', domainConfig.token) .timeout(30 * 1000) .end(function (error, result) { if (error && !error.response) return callback(new BoxError(BoxError.NETWORK_ERROR, error.message)); @@ -134,17 +134,17 @@ function wait(domainObject, location, type, value, options, callback) { waitForDns(fqdn, domainObject.zoneName, type, value, options, callback); } -function verifyDnsConfig(domainObject, callback) { +function verifyDomainConfig(domainObject, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName; - if (!dnsConfig.token || typeof dnsConfig.token !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'token must be a non-empty string', { field: 'token' })); + if (!domainConfig.token || typeof domainConfig.token !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'token must be a non-empty string', { field: 'token' })); var credentials = { - token: dnsConfig.token + token: domainConfig.token }; const ip = '127.0.0.1'; @@ -156,7 +156,7 @@ function verifyDnsConfig(domainObject, callback) { if (error || !nameservers) return callback(new BoxError(BoxError.BAD_FIELD, error ? error.message : 'Unable to get nameservers', { field: 'nameservers' })); if (!nameservers.every(function (n) { return n.toLowerCase().indexOf('.gandi.net') !== -1; })) { - debug('verifyDnsConfig: %j does not contain Gandi NS', nameservers); + debug('verifyDomainConfig: %j does not contain Gandi NS', nameservers); return callback(new BoxError(BoxError.BAD_FIELD, 'Domain nameservers are not set to Gandi', { field: 'nameservers' })); } @@ -165,12 +165,12 @@ function verifyDnsConfig(domainObject, callback) { upsert(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record added'); + debug('verifyDomainConfig: Test A record added'); del(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record removed again'); + debug('verifyDomainConfig: Test A record removed again'); callback(null, credentials); }); diff --git a/src/dns/gcdns.js b/src/dns/gcdns.js index 2304c7187..ce4a72846 100644 --- a/src/dns/gcdns.js +++ b/src/dns/gcdns.js @@ -7,7 +7,7 @@ exports = module.exports = { get, del, wait, - verifyDnsConfig + verifyDomainConfig }; const assert = require('assert'), @@ -28,24 +28,24 @@ function injectPrivateFields(newConfig, currentConfig) { if (newConfig.credentials.private_key === constants.SECRET_PLACEHOLDER && currentConfig.credentials) newConfig.credentials.private_key = currentConfig.credentials.private_key; } -function getDnsCredentials(dnsConfig) { - assert.strictEqual(typeof dnsConfig, 'object'); +function getDnsCredentials(domainConfig) { + assert.strictEqual(typeof domainConfig, 'object'); return { - projectId: dnsConfig.projectId, + projectId: domainConfig.projectId, credentials: { - client_email: dnsConfig.credentials.client_email, - private_key: dnsConfig.credentials.private_key + client_email: domainConfig.credentials.client_email, + private_key: domainConfig.credentials.private_key } }; } -function getZoneByName(dnsConfig, zoneName, callback) { - assert.strictEqual(typeof dnsConfig, 'object'); +function getZoneByName(domainConfig, zoneName, callback) { + assert.strictEqual(typeof domainConfig, 'object'); assert.strictEqual(typeof zoneName, 'string'); assert.strictEqual(typeof callback, 'function'); - var gcdns = new GCDNS(getDnsCredentials(dnsConfig)); + var gcdns = new GCDNS(getDnsCredentials(domainConfig)); gcdns.getZones(function (error, zones) { if (error && error.message === 'invalid_grant') return callback(new BoxError(BoxError.ACCESS_DENIED, 'The key was probably revoked')); @@ -74,13 +74,13 @@ function upsert(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, fqdn = dns.fqdn(location, domainObject); debug('add: %s for zone %s of type %s with values %j', fqdn, zoneName, type, values); - getZoneByName(getDnsCredentials(dnsConfig), zoneName, function (error, zone) { + getZoneByName(getDnsCredentials(domainConfig), zoneName, function (error, zone) { if (error) return callback(error); zone.getRecords({ type: type, name: fqdn + '.' }, function (error, oldRecords) { @@ -116,11 +116,11 @@ function get(domainObject, location, type, callback) { assert.strictEqual(typeof type, 'string'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, fqdn = dns.fqdn(location, domainObject); - getZoneByName(getDnsCredentials(dnsConfig), zoneName, function (error, zone) { + getZoneByName(getDnsCredentials(domainConfig), zoneName, function (error, zone) { if (error) return callback(error); var params = { @@ -145,11 +145,11 @@ function del(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, fqdn = dns.fqdn(location, domainObject); - getZoneByName(getDnsCredentials(dnsConfig), zoneName, function (error, zone) { + getZoneByName(getDnsCredentials(domainConfig), zoneName, function (error, zone) { if (error) return callback(error); zone.getRecords({ type: type, name: fqdn + '.' }, function(error, oldRecords) { @@ -186,19 +186,19 @@ function wait(domainObject, location, type, value, options, callback) { waitForDns(fqdn, domainObject.zoneName, type, value, options, callback); } -function verifyDnsConfig(domainObject, callback) { +function verifyDomainConfig(domainObject, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName; - if (typeof dnsConfig.projectId !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'projectId must be a string', { field: 'projectId' })); - if (!dnsConfig.credentials || typeof dnsConfig.credentials !== 'object') return callback(new BoxError(BoxError.BAD_FIELD, 'credentials must be an object', { field: 'credentials' })); - if (typeof dnsConfig.credentials.client_email !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'credentials.client_email must be a string', { field: 'client_email' })); - if (typeof dnsConfig.credentials.private_key !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'credentials.private_key must be a string', { field: 'private_key' })); + if (typeof domainConfig.projectId !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'projectId must be a string', { field: 'projectId' })); + if (!domainConfig.credentials || typeof domainConfig.credentials !== 'object') return callback(new BoxError(BoxError.BAD_FIELD, 'credentials must be an object', { field: 'credentials' })); + if (typeof domainConfig.credentials.client_email !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'credentials.client_email must be a string', { field: 'client_email' })); + if (typeof domainConfig.credentials.private_key !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'credentials.private_key must be a string', { field: 'private_key' })); - var credentials = getDnsCredentials(dnsConfig); + var credentials = getDnsCredentials(domainConfig); const ip = '127.0.0.1'; @@ -213,7 +213,7 @@ function verifyDnsConfig(domainObject, callback) { var definedNS = zone.metadata.nameServers.sort().map(function(r) { return r.replace(/\.$/, ''); }); if (!_.isEqual(definedNS, nameservers.sort())) { - debug('verifyDnsConfig: %j and %j do not match', nameservers, definedNS); + debug('verifyDomainConfig: %j and %j do not match', nameservers, definedNS); return callback(new BoxError(BoxError.BAD_FIELD, 'Domain nameservers are not set to Google Cloud DNS', { field: 'nameservers' })); } @@ -222,12 +222,12 @@ function verifyDnsConfig(domainObject, callback) { upsert(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record added'); + debug('verifyDomainConfig: Test A record added'); del(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record removed again'); + debug('verifyDomainConfig: Test A record removed again'); callback(null, credentials); }); diff --git a/src/dns/godaddy.js b/src/dns/godaddy.js index fe5be0855..cc771dcb9 100644 --- a/src/dns/godaddy.js +++ b/src/dns/godaddy.js @@ -7,7 +7,7 @@ exports = module.exports = { get, del, wait, - verifyDnsConfig + verifyDomainConfig }; const assert = require('assert'), @@ -47,7 +47,7 @@ function upsert(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || '@'; @@ -68,7 +68,7 @@ function upsert(domainObject, location, type, values, callback) { }); superagent.put(`${GODADDY_API}/${zoneName}/records/${type}/${name}`) - .set('Authorization', `sso-key ${dnsConfig.apiKey}:${dnsConfig.apiSecret}`) + .set('Authorization', `sso-key ${domainConfig.apiKey}:${domainConfig.apiSecret}`) .timeout(30 * 1000) .send(records) .end(function (error, result) { @@ -88,14 +88,14 @@ function get(domainObject, location, type, callback) { assert.strictEqual(typeof type, 'string'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || '@'; debug(`get: ${name} in zone ${zoneName} of type ${type}`); superagent.get(`${GODADDY_API}/${zoneName}/records/${type}/${name}`) - .set('Authorization', `sso-key ${dnsConfig.apiKey}:${dnsConfig.apiSecret}`) + .set('Authorization', `sso-key ${domainConfig.apiKey}:${domainConfig.apiSecret}`) .timeout(30 * 1000) .end(function (error, result) { if (error && !error.response) return callback(new BoxError(BoxError.NETWORK_ERROR, error.message)); @@ -120,7 +120,7 @@ function del(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || '@'; @@ -140,7 +140,7 @@ function del(domainObject, location, type, values, callback) { }]; superagent.put(`${GODADDY_API}/${zoneName}/records/${type}/${name}`) - .set('Authorization', `sso-key ${dnsConfig.apiKey}:${dnsConfig.apiSecret}`) + .set('Authorization', `sso-key ${domainConfig.apiKey}:${domainConfig.apiSecret}`) .send(records) .timeout(30 * 1000) .end(function (error, result) { @@ -169,21 +169,21 @@ function wait(domainObject, location, type, value, options, callback) { waitForDns(fqdn, domainObject.zoneName, type, value, options, callback); } -function verifyDnsConfig(domainObject, callback) { +function verifyDomainConfig(domainObject, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName; - if (!dnsConfig.apiKey || typeof dnsConfig.apiKey !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'apiKey must be a non-empty string', { field: 'apiKey' })); - if (!dnsConfig.apiSecret || typeof dnsConfig.apiSecret !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'apiSecret must be a non-empty string', { field: 'apiSecret' })); + if (!domainConfig.apiKey || typeof domainConfig.apiKey !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'apiKey must be a non-empty string', { field: 'apiKey' })); + if (!domainConfig.apiSecret || typeof domainConfig.apiSecret !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'apiSecret must be a non-empty string', { field: 'apiSecret' })); const ip = '127.0.0.1'; var credentials = { - apiKey: dnsConfig.apiKey, - apiSecret: dnsConfig.apiSecret + apiKey: domainConfig.apiKey, + apiSecret: domainConfig.apiSecret }; if (process.env.BOX_ENV === 'test') return callback(null, credentials); // this shouldn't be here @@ -193,7 +193,7 @@ function verifyDnsConfig(domainObject, callback) { if (error || !nameservers) return callback(new BoxError(BoxError.BAD_FIELD, error ? error.message : 'Unable to get nameservers', { field: 'nameservers' })); if (!nameservers.every(function (n) { return n.toLowerCase().indexOf('.domaincontrol.com') !== -1; })) { - debug('verifyDnsConfig: %j does not contain GoDaddy NS', nameservers); + debug('verifyDomainConfig: %j does not contain GoDaddy NS', nameservers); return callback(new BoxError(BoxError.BAD_FIELD, 'Domain nameservers are not set to GoDaddy', { field: 'nameservers' })); } @@ -202,12 +202,12 @@ function verifyDnsConfig(domainObject, callback) { upsert(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record added'); + debug('verifyDomainConfig: Test A record added'); del(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record removed again'); + debug('verifyDomainConfig: Test A record removed again'); callback(null, credentials); }); diff --git a/src/dns/interface.js b/src/dns/interface.js index a6e7bf820..68bcc5605 100644 --- a/src/dns/interface.js +++ b/src/dns/interface.js @@ -13,7 +13,7 @@ exports = module.exports = { get, del, wait, - verifyDnsConfig + verifyDomainConfig }; const assert = require('assert'), @@ -75,11 +75,11 @@ function wait(domainObject, location, type, value, options, callback) { callback(); } -function verifyDnsConfig(domainObject, callback) { +function verifyDomainConfig(domainObject, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof callback, 'function'); - // Result: dnsConfig object + // Result: domainConfig object - callback(new BoxError(BoxError.NOT_IMPLEMENTED, 'verifyDnsConfig is not implemented')); + callback(new BoxError(BoxError.NOT_IMPLEMENTED, 'verifyDomainConfig is not implemented')); } diff --git a/src/dns/linode.js b/src/dns/linode.js index 65c0ecc5d..0790c7512 100644 --- a/src/dns/linode.js +++ b/src/dns/linode.js @@ -7,7 +7,7 @@ exports = module.exports = { get, del, wait, - verifyDnsConfig + verifyDomainConfig }; const async = require('async'), @@ -35,14 +35,14 @@ function injectPrivateFields(newConfig, currentConfig) { if (newConfig.token === constants.SECRET_PLACEHOLDER) newConfig.token = currentConfig.token; } -function getZoneId(dnsConfig, zoneName, callback) { - assert.strictEqual(typeof dnsConfig, 'object'); +function getZoneId(domainConfig, zoneName, callback) { + assert.strictEqual(typeof domainConfig, 'object'); assert.strictEqual(typeof zoneName, 'string'); assert.strictEqual(typeof callback, 'function'); // returns 100 at a time superagent.get(`${LINODE_ENDPOINT}/domains`) - .set('Authorization', 'Bearer ' + dnsConfig.token) + .set('Authorization', 'Bearer ' + domainConfig.token) .timeout(30 * 1000) .retry(5) .end(function (error, result) { @@ -62,8 +62,8 @@ function getZoneId(dnsConfig, zoneName, callback) { }); } -function getZoneRecords(dnsConfig, zoneName, name, type, callback) { - assert.strictEqual(typeof dnsConfig, 'object'); +function getZoneRecords(domainConfig, zoneName, name, type, callback) { + assert.strictEqual(typeof domainConfig, 'object'); assert.strictEqual(typeof zoneName, 'string'); assert.strictEqual(typeof name, 'string'); assert.strictEqual(typeof type, 'string'); @@ -71,7 +71,7 @@ function getZoneRecords(dnsConfig, zoneName, name, type, callback) { debug(`getInternal: getting dns records of ${zoneName} with ${name} and type ${type}`); - getZoneId(dnsConfig, zoneName, function (error, zoneId) { + getZoneId(domainConfig, zoneName, function (error, zoneId) { if (error) return callback(error); let page = 0, more = false; @@ -81,7 +81,7 @@ function getZoneRecords(dnsConfig, zoneName, name, type, callback) { const url = `${LINODE_ENDPOINT}/domains/${zoneId}/records?page=${++page}`; superagent.get(url) - .set('Authorization', 'Bearer ' + dnsConfig.token) + .set('Authorization', 'Bearer ' + domainConfig.token) .timeout(30 * 1000) .retry(5) .end(function (error, result) { @@ -114,11 +114,11 @@ function get(domainObject, location, type, callback) { assert.strictEqual(typeof type, 'string'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || ''; - getZoneRecords(dnsConfig, zoneName, name, type, function (error, result) { + getZoneRecords(domainConfig, zoneName, name, type, function (error, result) { if (error) return callback(error); const { records } = result; @@ -137,13 +137,13 @@ function upsert(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || ''; debug('upsert: %s for zone %s of type %s with values %j', name, zoneName, type, values); - getZoneRecords(dnsConfig, zoneName, name, type, function (error, result) { + getZoneRecords(domainConfig, zoneName, name, type, function (error, result) { if (error) return callback(error); const { zoneId, records } = result; @@ -168,7 +168,7 @@ function upsert(domainObject, location, type, values, callback) { data.name = name; // only set for new records superagent.post(`${LINODE_ENDPOINT}/domains/${zoneId}/records`) - .set('Authorization', 'Bearer ' + dnsConfig.token) + .set('Authorization', 'Bearer ' + domainConfig.token) .send(data) .timeout(30 * 1000) .retry(5) @@ -184,7 +184,7 @@ function upsert(domainObject, location, type, values, callback) { }); } else { superagent.put(`${LINODE_ENDPOINT}/domains/${zoneId}/records/${records[i].id}`) - .set('Authorization', 'Bearer ' + dnsConfig.token) + .set('Authorization', 'Bearer ' + domainConfig.token) .send(data) .timeout(30 * 1000) .retry(5) @@ -219,11 +219,11 @@ function del(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || ''; - getZoneRecords(dnsConfig, zoneName, name, type, function (error, result) { + getZoneRecords(domainConfig, zoneName, name, type, function (error, result) { if (error) return callback(error); const { zoneId, records } = result; @@ -238,7 +238,7 @@ function del(domainObject, location, type, values, callback) { // FIXME we only handle the first one currently superagent.del(`${LINODE_ENDPOINT}/domains/${zoneId}/records/${tmp[0].id}`) - .set('Authorization', 'Bearer ' + dnsConfig.token) + .set('Authorization', 'Bearer ' + domainConfig.token) .timeout(30 * 1000) .retry(5) .end(function (error, result) { @@ -267,19 +267,19 @@ function wait(domainObject, location, type, value, options, callback) { waitForDns(fqdn, domainObject.zoneName, type, value, options, callback); } -function verifyDnsConfig(domainObject, callback) { +function verifyDomainConfig(domainObject, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName; - if (!dnsConfig.token || typeof dnsConfig.token !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'token must be a non-empty string', { field: 'token' })); + if (!domainConfig.token || typeof domainConfig.token !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'token must be a non-empty string', { field: 'token' })); const ip = '127.0.0.1'; var credentials = { - token: dnsConfig.token + token: domainConfig.token }; if (process.env.BOX_ENV === 'test') return callback(null, credentials); // this shouldn't be here @@ -289,7 +289,7 @@ function verifyDnsConfig(domainObject, callback) { if (error || !nameservers) return callback(new BoxError(BoxError.BAD_FIELD, error ? error.message : 'Unable to get nameservers', { field: 'nameservers' })); if (nameservers.map(function (n) { return n.toLowerCase(); }).indexOf('ns1.linode.com') === -1) { - debug('verifyDnsConfig: %j does not contains linode NS', nameservers); + debug('verifyDomainConfig: %j does not contains linode NS', nameservers); return callback(new BoxError(BoxError.BAD_FIELD, 'Domain nameservers are not set to Linode', { field: 'nameservers' })); } @@ -298,12 +298,12 @@ function verifyDnsConfig(domainObject, callback) { upsert(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record added'); + debug('verifyDomainConfig: Test A record added'); del(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record removed again'); + debug('verifyDomainConfig: Test A record removed again'); callback(null, credentials); }); diff --git a/src/dns/manual.js b/src/dns/manual.js index 9e605cb73..ef1b0f2aa 100644 --- a/src/dns/manual.js +++ b/src/dns/manual.js @@ -1,13 +1,13 @@ 'use strict'; exports = module.exports = { - removePrivateFields: removePrivateFields, - injectPrivateFields: injectPrivateFields, - upsert: upsert, - get: get, - del: del, - wait: wait, - verifyDnsConfig: verifyDnsConfig + removePrivateFields, + injectPrivateFields, + upsert, + get, + del, + wait, + verifyDomainConfig }; const assert = require('assert'), @@ -69,7 +69,7 @@ function wait(domainObject, location, type, value, options, callback) { waitForDns(fqdn, domainObject.zoneName, type, value, options, callback); } -function verifyDnsConfig(domainObject, callback) { +function verifyDomainConfig(domainObject, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof callback, 'function'); diff --git a/src/dns/namecheap.js b/src/dns/namecheap.js index 3fcac221b..21efb2fc4 100644 --- a/src/dns/namecheap.js +++ b/src/dns/namecheap.js @@ -6,7 +6,7 @@ exports = module.exports = { upsert, get, del, - verifyDnsConfig, + verifyDomainConfig, wait }; @@ -34,25 +34,25 @@ function injectPrivateFields(newConfig, currentConfig) { if (newConfig.token === constants.SECRET_PLACEHOLDER) newConfig.token = currentConfig.token; } -async function getQuery(dnsConfig) { - assert.strictEqual(typeof dnsConfig, 'object'); +async function getQuery(domainConfig) { + assert.strictEqual(typeof domainConfig, 'object'); const ip = await sysinfo.getServerIPv4(); return { - ApiUser: dnsConfig.username, - ApiKey: dnsConfig.token, - UserName: dnsConfig.username, + ApiUser: domainConfig.username, + ApiKey: domainConfig.token, + UserName: domainConfig.username, ClientIp: ip }; } -function getZone(dnsConfig, zoneName, callback) { - assert.strictEqual(typeof dnsConfig, 'object'); +function getZone(domainConfig, zoneName, callback) { + assert.strictEqual(typeof domainConfig, 'object'); assert.strictEqual(typeof zoneName, 'string'); assert.strictEqual(typeof callback, 'function'); - util.callbackify(getQuery)(dnsConfig, function (error, query) { + util.callbackify(getQuery)(domainConfig, function (error, query) { if (error) return callback(error); query.Command = 'namecheap.domains.dns.getHosts'; @@ -84,13 +84,13 @@ function getZone(dnsConfig, zoneName, callback) { }); } -function setZone(dnsConfig, zoneName, hosts, callback) { - assert.strictEqual(typeof dnsConfig, 'object'); +function setZone(domainConfig, zoneName, hosts, callback) { + assert.strictEqual(typeof domainConfig, 'object'); assert.strictEqual(typeof zoneName, 'string'); assert(Array.isArray(hosts)); assert.strictEqual(typeof callback, 'function'); - util.callbackify(getQuery)(dnsConfig, function (error, query) { + util.callbackify(getQuery)(domainConfig, function (error, query) { if (error) return callback(error); query.Command = 'namecheap.domains.dns.setHosts'; @@ -145,14 +145,14 @@ function upsert(domainObject, subdomain, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config; + const domainConfig = domainObject.config; const zoneName = domainObject.zoneName; subdomain = dns.getName(domainObject, subdomain, type) || '@'; debug('upsert: %s for zone %s of type %s with values %j', subdomain, zoneName, type, values); - getZone(dnsConfig, zoneName, function (error, result) { + getZone(domainConfig, zoneName, function (error, result) { if (error) return callback(error); // Array to keep track of records that need to be inserted @@ -198,7 +198,7 @@ function upsert(domainObject, subdomain, type, values, callback) { const hosts = result.concat(toInsert); - setZone(dnsConfig, zoneName, hosts, callback); + setZone(domainConfig, zoneName, hosts, callback); }); } @@ -208,12 +208,12 @@ function get(domainObject, subdomain, type, callback) { assert.strictEqual(typeof type, 'string'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config; + const domainConfig = domainObject.config; const zoneName = domainObject.zoneName; subdomain = dns.getName(domainObject, subdomain, type) || '@'; - getZone(dnsConfig, zoneName, function (error, result) { + getZone(domainConfig, zoneName, function (error, result) { if (error) return callback(error); // We need to filter hosts to ones with this subdomain and type @@ -235,14 +235,14 @@ function del(domainObject, subdomain, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config; + const domainConfig = domainObject.config; const zoneName = domainObject.zoneName; subdomain = dns.getName(domainObject, subdomain, type) || '@'; debug('del: %s for zone %s of type %s with values %j', subdomain, zoneName, type, values); - getZone(dnsConfig, zoneName, function (error, result) { + getZone(domainConfig, zoneName, function (error, result) { if (error) return callback(error); if (result.length === 0) return callback(); @@ -254,26 +254,26 @@ function del(domainObject, subdomain, type, values, callback) { result = result.filter(curHost => curHost.Type !== type || curHost.Name !== subdomain || curHost.Address !== curValue); } - if (result.length !== originalLength) return setZone(dnsConfig, zoneName, result, callback); + if (result.length !== originalLength) return setZone(domainConfig, zoneName, result, callback); callback(); }); } -function verifyDnsConfig(domainObject, callback) { +function verifyDomainConfig(domainObject, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config; + const domainConfig = domainObject.config; const zoneName = domainObject.zoneName; const ip = '127.0.0.1'; - if (!dnsConfig.username || typeof dnsConfig.username !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'username must be a non-empty string', { field: 'username' })); - if (!dnsConfig.token || typeof dnsConfig.token !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'token must be a non-empty string', { field: 'token' })); + if (!domainConfig.username || typeof domainConfig.username !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'username must be a non-empty string', { field: 'username' })); + if (!domainConfig.token || typeof domainConfig.token !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'token must be a non-empty string', { field: 'token' })); let credentials = { - username: dnsConfig.username, - token: dnsConfig.token + username: domainConfig.username, + token: domainConfig.token }; if (process.env.BOX_ENV === 'test') return callback(null, credentials); // this shouldn't be here @@ -283,7 +283,7 @@ function verifyDnsConfig(domainObject, callback) { if (error || !nameservers) return callback(new BoxError(BoxError.BAD_FIELD, error ? error.message : 'Unable to get nameservers', { field: 'nameservers' })); if (nameservers.some(function (n) { return n.toLowerCase().indexOf('.registrar-servers.com') === -1; })) { - debug('verifyDnsConfig: %j does not contains NC NS', nameservers); + debug('verifyDomainConfig: %j does not contains NC NS', nameservers); return callback(new BoxError(BoxError.BAD_FIELD, 'Domain nameservers are not set to NameCheap', { field: 'nameservers' })); } @@ -292,12 +292,12 @@ function verifyDnsConfig(domainObject, callback) { upsert(domainObject, testSubdomain, 'A', [ip], function (error, changeId) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record added with change id %s', changeId); + debug('verifyDomainConfig: Test A record added with change id %s', changeId); del(domainObject, testSubdomain, 'A', [ip], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record removed again'); + debug('verifyDomainConfig: Test A record removed again'); callback(null, credentials); }); diff --git a/src/dns/namecom.js b/src/dns/namecom.js index 1049f6cd7..24391ea1c 100644 --- a/src/dns/namecom.js +++ b/src/dns/namecom.js @@ -7,7 +7,7 @@ exports = module.exports = { get, del, wait, - verifyDnsConfig + verifyDomainConfig }; const assert = require('assert'), @@ -34,8 +34,8 @@ function injectPrivateFields(newConfig, currentConfig) { if (newConfig.token === constants.SECRET_PLACEHOLDER) newConfig.token = currentConfig.token; } -function addRecord(dnsConfig, zoneName, name, type, values, callback) { - assert.strictEqual(typeof dnsConfig, 'object'); +function addRecord(domainConfig, zoneName, name, type, values, callback) { + assert.strictEqual(typeof domainConfig, 'object'); assert.strictEqual(typeof zoneName, 'string'); assert.strictEqual(typeof name, 'string'); assert.strictEqual(typeof type, 'string'); @@ -62,7 +62,7 @@ function addRecord(dnsConfig, zoneName, name, type, values, callback) { } superagent.post(`${NAMECOM_API}/domains/${zoneName}/records`) - .auth(dnsConfig.username, dnsConfig.token) + .auth(domainConfig.username, domainConfig.token) .timeout(30 * 1000) .send(data) .end(function (error, result) { @@ -74,8 +74,8 @@ function addRecord(dnsConfig, zoneName, name, type, values, callback) { }); } -function updateRecord(dnsConfig, zoneName, recordId, name, type, values, callback) { - assert.strictEqual(typeof dnsConfig, 'object'); +function updateRecord(domainConfig, zoneName, recordId, name, type, values, callback) { + assert.strictEqual(typeof domainConfig, 'object'); assert.strictEqual(typeof zoneName, 'string'); assert.strictEqual(typeof recordId, 'number'); assert.strictEqual(typeof name, 'string'); @@ -103,7 +103,7 @@ function updateRecord(dnsConfig, zoneName, recordId, name, type, values, callbac } superagent.put(`${NAMECOM_API}/domains/${zoneName}/records/${recordId}`) - .auth(dnsConfig.username, dnsConfig.token) + .auth(domainConfig.username, domainConfig.token) .timeout(30 * 1000) .send(data) .end(function (error, result) { @@ -115,8 +115,8 @@ function updateRecord(dnsConfig, zoneName, recordId, name, type, values, callbac }); } -function getInternal(dnsConfig, zoneName, name, type, callback) { - assert.strictEqual(typeof dnsConfig, 'object'); +function getInternal(domainConfig, zoneName, name, type, callback) { + assert.strictEqual(typeof domainConfig, 'object'); assert.strictEqual(typeof zoneName, 'string'); assert.strictEqual(typeof name, 'string'); assert.strictEqual(typeof type, 'string'); @@ -125,7 +125,7 @@ function getInternal(dnsConfig, zoneName, name, type, callback) { debug(`getInternal: ${name} in zone ${zoneName} of type ${type}`); superagent.get(`${NAMECOM_API}/domains/${zoneName}/records`) - .auth(dnsConfig.username, dnsConfig.token) + .auth(domainConfig.username, domainConfig.token) .timeout(30 * 1000) .end(function (error, result) { if (error && !error.response) return callback(new BoxError(BoxError.NETWORK_ERROR, error.message)); @@ -158,18 +158,18 @@ function upsert(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || ''; debug(`upsert: ${name} in zone ${zoneName} of type ${type} with values ${JSON.stringify(values)}`); - getInternal(dnsConfig, zoneName, name, type, function (error, result) { + getInternal(domainConfig, zoneName, name, type, function (error, result) { if (error) return callback(error); - if (result.length === 0) return addRecord(dnsConfig, zoneName, name, type, values, callback); + if (result.length === 0) return addRecord(domainConfig, zoneName, name, type, values, callback); - return updateRecord(dnsConfig, zoneName, result[0].id, name, type, values, callback); + return updateRecord(domainConfig, zoneName, result[0].id, name, type, values, callback); }); } @@ -179,11 +179,11 @@ function get(domainObject, location, type, callback) { assert.strictEqual(typeof type, 'string'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || ''; - getInternal(dnsConfig, zoneName, name, type, function (error, result) { + getInternal(domainConfig, zoneName, name, type, function (error, result) { if (error) return callback(error); var tmp = result.map(function (record) { return record.answer; }); @@ -201,19 +201,19 @@ function del(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || ''; debug(`del: ${name} in zone ${zoneName} of type ${type} with values ${JSON.stringify(values)}`); - getInternal(dnsConfig, zoneName, name, type, function (error, result) { + getInternal(domainConfig, zoneName, name, type, function (error, result) { if (error) return callback(error); if (result.length === 0) return callback(); superagent.del(`${NAMECOM_API}/domains/${zoneName}/records/${result[0].id}`) - .auth(dnsConfig.username, dnsConfig.token) + .auth(domainConfig.username, domainConfig.token) .timeout(30 * 1000) .end(function (error, result) { if (error && !error.response) return callback(new BoxError(BoxError.NETWORK_ERROR, error.message)); @@ -238,19 +238,19 @@ function wait(domainObject, location, type, value, options, callback) { waitForDns(fqdn, domainObject.zoneName, type, value, options, callback); } -function verifyDnsConfig(domainObject, callback) { +function verifyDomainConfig(domainObject, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName; - if (typeof dnsConfig.username !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'username must be a string', { field: 'username' })); - if (typeof dnsConfig.token !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'token must be a string', { field: 'token' })); + if (typeof domainConfig.username !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'username must be a string', { field: 'username' })); + if (typeof domainConfig.token !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'token must be a string', { field: 'token' })); var credentials = { - username: dnsConfig.username, - token: dnsConfig.token + username: domainConfig.username, + token: domainConfig.token }; const ip = '127.0.0.1'; @@ -262,7 +262,7 @@ function verifyDnsConfig(domainObject, callback) { if (error || !nameservers) return callback(new BoxError(BoxError.BAD_FIELD, error ? error.message : 'Unable to get nameservers', { field: 'nameservers' })); if (!nameservers.every(function (n) { return n.toLowerCase().indexOf('.name.com') !== -1; })) { - debug('verifyDnsConfig: %j does not contain Name.com NS', nameservers); + debug('verifyDomainConfig: %j does not contain Name.com NS', nameservers); return callback(new BoxError(BoxError.BAD_FIELD, 'Domain nameservers are not set to name.com', { field: 'nameservers' })); } @@ -271,12 +271,12 @@ function verifyDnsConfig(domainObject, callback) { upsert(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record added'); + debug('verifyDomainConfig: Test A record added'); del(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record removed again'); + debug('verifyDomainConfig: Test A record removed again'); callback(null, credentials); }); diff --git a/src/dns/netcup.js b/src/dns/netcup.js index 4d916ea96..0dcc4376c 100644 --- a/src/dns/netcup.js +++ b/src/dns/netcup.js @@ -7,7 +7,7 @@ exports = module.exports = { get, del, wait, - verifyDnsConfig + verifyDomainConfig }; const assert = require('assert'), @@ -36,16 +36,16 @@ function injectPrivateFields(newConfig, currentConfig) { } // returns a api session id -function login(dnsConfig, callback) { - assert.strictEqual(typeof dnsConfig, 'object'); +function login(domainConfig, callback) { + assert.strictEqual(typeof domainConfig, 'object'); assert.strictEqual(typeof callback, 'function'); const data = { action: 'login', param:{ - apikey: dnsConfig.apiKey, - apipassword: dnsConfig.apiPassword, - customernumber: dnsConfig.customerNumber + apikey: domainConfig.apiKey, + apipassword: domainConfig.apiPassword, + customernumber: domainConfig.customerNumber } }; @@ -57,8 +57,8 @@ function login(dnsConfig, callback) { }); } -function getAllRecords(dnsConfig, apiSessionId, zoneName, callback) { - assert.strictEqual(typeof dnsConfig, 'object'); +function getAllRecords(domainConfig, apiSessionId, zoneName, callback) { + assert.strictEqual(typeof domainConfig, 'object'); assert.strictEqual(typeof apiSessionId, 'string'); assert.strictEqual(typeof zoneName, 'string'); assert.strictEqual(typeof callback, 'function'); @@ -68,9 +68,9 @@ function getAllRecords(dnsConfig, apiSessionId, zoneName, callback) { const data = { action: 'infoDnsRecords', param:{ - apikey: dnsConfig.apiKey, + apikey: domainConfig.apiKey, apisessionid: apiSessionId, - customernumber: dnsConfig.customerNumber, + customernumber: domainConfig.customerNumber, domainname: zoneName, } }; @@ -90,16 +90,16 @@ function upsert(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || '@'; debug('upsert: %s for zone %s of type %s with values %j', name, zoneName, type, values); - login(dnsConfig, function (error, apiSessionId) { + login(domainConfig, function (error, apiSessionId) { if (error) return callback(error); - getAllRecords(dnsConfig, apiSessionId, zoneName, function (error, result) { + getAllRecords(domainConfig, apiSessionId, zoneName, function (error, result) { if (error) return callback(error); let records = []; @@ -127,9 +127,9 @@ function upsert(domainObject, location, type, values, callback) { const data = { action: 'updateDnsRecords', param:{ - apikey: dnsConfig.apiKey, + apikey: domainConfig.apiKey, apisessionid: apiSessionId, - customernumber: dnsConfig.customerNumber, + customernumber: domainConfig.customerNumber, domainname: zoneName, dnsrecordset: { dnsrecords: records @@ -154,16 +154,16 @@ function get(domainObject, location, type, callback) { assert.strictEqual(typeof type, 'string'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || '@'; debug('get: %s for zone %s of type %s', name, zoneName, type); - login(dnsConfig, function (error, apiSessionId) { + login(domainConfig, function (error, apiSessionId) { if (error) return callback(error); - getAllRecords(dnsConfig, apiSessionId, zoneName, function (error, result) { + getAllRecords(domainConfig, apiSessionId, zoneName, function (error, result) { if (error) return callback(error); // We only return the value string @@ -179,16 +179,16 @@ function del(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || '@'; debug('del: %s for zone %s of type %s with values %j', name, zoneName, type, values); - login(dnsConfig, function (error, apiSessionId) { + login(domainConfig, function (error, apiSessionId) { if (error) return callback(error); - getAllRecords(dnsConfig, apiSessionId, zoneName, function (error, result) { + getAllRecords(domainConfig, apiSessionId, zoneName, function (error, result) { if (error) return callback(error); let records = []; @@ -211,9 +211,9 @@ function del(domainObject, location, type, values, callback) { const data = { action: 'updateDnsRecords', param:{ - apikey: dnsConfig.apiKey, + apikey: domainConfig.apiKey, apisessionid: apiSessionId, - customernumber: dnsConfig.customerNumber, + customernumber: domainConfig.customerNumber, domainname: zoneName, dnsrecordset: { dnsrecords: records @@ -245,23 +245,23 @@ function wait(domainObject, location, type, value, options, callback) { waitForDns(fqdn, domainObject.zoneName, type, value, options, callback); } -function verifyDnsConfig(domainObject, callback) { +function verifyDomainConfig(domainObject, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName; - if (!dnsConfig.customerNumber || typeof dnsConfig.customerNumber !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'customerNumber must be a non-empty string', { field: 'customerNumber' })); - if (!dnsConfig.apiKey || typeof dnsConfig.apiKey !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'apiKey must be a non-empty string', { field: 'apiKey' })); - if (!dnsConfig.apiPassword || typeof dnsConfig.apiPassword !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'apiPassword must be a non-empty string', { field: 'apiPassword' })); + if (!domainConfig.customerNumber || typeof domainConfig.customerNumber !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'customerNumber must be a non-empty string', { field: 'customerNumber' })); + if (!domainConfig.apiKey || typeof domainConfig.apiKey !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'apiKey must be a non-empty string', { field: 'apiKey' })); + if (!domainConfig.apiPassword || typeof domainConfig.apiPassword !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'apiPassword must be a non-empty string', { field: 'apiPassword' })); const ip = '127.0.0.1'; var credentials = { - customerNumber: dnsConfig.customerNumber, - apiKey: dnsConfig.apiKey, - apiPassword: dnsConfig.apiPassword, + customerNumber: domainConfig.customerNumber, + apiKey: domainConfig.apiKey, + apiPassword: domainConfig.apiPassword, }; if (process.env.BOX_ENV === 'test') return callback(null, credentials); // this shouldn't be here @@ -271,7 +271,7 @@ function verifyDnsConfig(domainObject, callback) { if (error || !nameservers) return callback(new BoxError(BoxError.BAD_FIELD, error ? error.message : 'Unable to get nameservers', { field: 'nameservers' })); if (!nameservers.every(function (n) { return n.toLowerCase().indexOf('dns.netcup.net') !== -1; })) { - debug('verifyDnsConfig: %j does not contains Netcup NS', nameservers); + debug('verifyDomainConfig: %j does not contains Netcup NS', nameservers); return callback(new BoxError(BoxError.BAD_FIELD, 'Domain nameservers are not set to Netcup', { field: 'nameservers' })); } @@ -280,12 +280,12 @@ function verifyDnsConfig(domainObject, callback) { upsert(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record added'); + debug('verifyDomainConfig: Test A record added'); del(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record removed again'); + debug('verifyDomainConfig: Test A record removed again'); callback(null, credentials); }); diff --git a/src/dns/noop.js b/src/dns/noop.js index 3c0124baf..3dda59908 100644 --- a/src/dns/noop.js +++ b/src/dns/noop.js @@ -7,7 +7,7 @@ exports = module.exports = { get, del, wait, - verifyDnsConfig + verifyDomainConfig }; const assert = require('assert'), @@ -63,7 +63,7 @@ function wait(domainObject, location, type, value, options, callback) { callback(); } -function verifyDnsConfig(domainObject, callback) { +function verifyDomainConfig(domainObject, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof callback, 'function'); diff --git a/src/dns/route53.js b/src/dns/route53.js index 4fe6fac74..933a63025 100644 --- a/src/dns/route53.js +++ b/src/dns/route53.js @@ -7,7 +7,7 @@ exports = module.exports = { get, del, wait, - verifyDnsConfig + verifyDomainConfig }; const assert = require('assert'), @@ -28,30 +28,30 @@ function injectPrivateFields(newConfig, currentConfig) { if (newConfig.secretAccessKey === constants.SECRET_PLACEHOLDER) newConfig.secretAccessKey = currentConfig.secretAccessKey; } -function getDnsCredentials(dnsConfig) { - assert.strictEqual(typeof dnsConfig, 'object'); +function getDnsCredentials(domainConfig) { + assert.strictEqual(typeof domainConfig, 'object'); var credentials = { - accessKeyId: dnsConfig.accessKeyId, - secretAccessKey: dnsConfig.secretAccessKey, - region: dnsConfig.region + accessKeyId: domainConfig.accessKeyId, + secretAccessKey: domainConfig.secretAccessKey, + region: domainConfig.region }; - if (dnsConfig.endpoint) credentials.endpoint = new AWS.Endpoint(dnsConfig.endpoint); + if (domainConfig.endpoint) credentials.endpoint = new AWS.Endpoint(domainConfig.endpoint); return credentials; } -function getZoneByName(dnsConfig, zoneName, callback) { - assert.strictEqual(typeof dnsConfig, 'object'); +function getZoneByName(domainConfig, zoneName, callback) { + assert.strictEqual(typeof domainConfig, 'object'); assert.strictEqual(typeof zoneName, 'string'); assert.strictEqual(typeof callback, 'function'); - var route53 = new AWS.Route53(getDnsCredentials(dnsConfig)); + var route53 = new AWS.Route53(getDnsCredentials(domainConfig)); // backward compat for 2.2, where we only required access to "listHostedZones" let listHostedZones; - if (dnsConfig.listHostedZonesByName) { + if (domainConfig.listHostedZonesByName) { listHostedZones = route53.listHostedZonesByName.bind(route53, { MaxItems: '1', DNSName: zoneName + '.' }); } else { listHostedZones = route53.listHostedZones.bind(route53, {}); // currently, this route does not support > 100 zones @@ -72,15 +72,15 @@ function getZoneByName(dnsConfig, zoneName, callback) { }); } -function getHostedZone(dnsConfig, zoneName, callback) { - assert.strictEqual(typeof dnsConfig, 'object'); +function getHostedZone(domainConfig, zoneName, callback) { + assert.strictEqual(typeof domainConfig, 'object'); assert.strictEqual(typeof zoneName, 'string'); assert.strictEqual(typeof callback, 'function'); - getZoneByName(dnsConfig, zoneName, function (error, zone) { + getZoneByName(domainConfig, zoneName, function (error, zone) { if (error) return callback(error); - var route53 = new AWS.Route53(getDnsCredentials(dnsConfig)); + var route53 = new AWS.Route53(getDnsCredentials(domainConfig)); route53.getHostedZone({ Id: zone.Id }, function (error, result) { if (error && error.code === 'AccessDenied') return callback(new BoxError(BoxError.ACCESS_DENIED, error.message)); if (error && error.code === 'InvalidClientTokenId') return callback(new BoxError(BoxError.ACCESS_DENIED, error.message)); @@ -98,13 +98,13 @@ function upsert(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, fqdn = dns.fqdn(location, domainObject); debug('add: %s for zone %s of type %s with values %j', fqdn, zoneName, type, values); - getZoneByName(dnsConfig, zoneName, function (error, zone) { + getZoneByName(domainConfig, zoneName, function (error, zone) { if (error) return callback(error); var records = values.map(function (v) { return { Value: v }; }); // for mx records, value is already of the ' ' format @@ -124,7 +124,7 @@ function upsert(domainObject, location, type, values, callback) { HostedZoneId: zone.Id }; - var route53 = new AWS.Route53(getDnsCredentials(dnsConfig)); + var route53 = new AWS.Route53(getDnsCredentials(domainConfig)); route53.changeResourceRecordSets(params, function(error) { if (error && error.code === 'AccessDenied') return callback(new BoxError(BoxError.ACCESS_DENIED, error.message)); if (error && error.code === 'InvalidClientTokenId') return callback(new BoxError(BoxError.ACCESS_DENIED, error.message)); @@ -143,11 +143,11 @@ function get(domainObject, location, type, callback) { assert.strictEqual(typeof type, 'string'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, fqdn = dns.fqdn(location, domainObject); - getZoneByName(dnsConfig, zoneName, function (error, zone) { + getZoneByName(domainConfig, zoneName, function (error, zone) { if (error) return callback(error); var params = { @@ -157,7 +157,7 @@ function get(domainObject, location, type, callback) { StartRecordType: type }; - var route53 = new AWS.Route53(getDnsCredentials(dnsConfig)); + var route53 = new AWS.Route53(getDnsCredentials(domainConfig)); route53.listResourceRecordSets(params, function (error, result) { if (error && error.code === 'AccessDenied') return callback(new BoxError(BoxError.ACCESS_DENIED, error.message)); if (error && error.code === 'InvalidClientTokenId') return callback(new BoxError(BoxError.ACCESS_DENIED, error.message)); @@ -179,11 +179,11 @@ function del(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, fqdn = dns.fqdn(location, domainObject); - getZoneByName(dnsConfig, zoneName, function (error, zone) { + getZoneByName(domainConfig, zoneName, function (error, zone) { if (error) return callback(error); var records = values.map(function (v) { return { Value: v }; }); @@ -205,7 +205,7 @@ function del(domainObject, location, type, values, callback) { HostedZoneId: zone.Id }; - var route53 = new AWS.Route53(getDnsCredentials(dnsConfig)); + var route53 = new AWS.Route53(getDnsCredentials(domainConfig)); route53.changeResourceRecordSets(params, function(error) { if (error && error.code === 'AccessDenied') return callback(new BoxError(BoxError.ACCESS_DENIED, error.message)); if (error && error.code === 'InvalidClientTokenId') return callback(new BoxError(BoxError.ACCESS_DENIED, error.message)); @@ -244,21 +244,21 @@ function wait(domainObject, location, type, value, options, callback) { waitForDns(fqdn, domainObject.zoneName, type, value, options, callback); } -function verifyDnsConfig(domainObject, callback) { +function verifyDomainConfig(domainObject, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName; - if (!dnsConfig.accessKeyId || typeof dnsConfig.accessKeyId !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'accessKeyId must be a non-empty string', { field: 'accessKeyId' })); - if (!dnsConfig.secretAccessKey || typeof dnsConfig.secretAccessKey !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'secretAccessKey must be a non-empty string', { field: 'secretAccessKey' })); + if (!domainConfig.accessKeyId || typeof domainConfig.accessKeyId !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'accessKeyId must be a non-empty string', { field: 'accessKeyId' })); + if (!domainConfig.secretAccessKey || typeof domainConfig.secretAccessKey !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'secretAccessKey must be a non-empty string', { field: 'secretAccessKey' })); var credentials = { - accessKeyId: dnsConfig.accessKeyId, - secretAccessKey: dnsConfig.secretAccessKey, - region: dnsConfig.region || 'us-east-1', - endpoint: dnsConfig.endpoint || null, + accessKeyId: domainConfig.accessKeyId, + secretAccessKey: domainConfig.secretAccessKey, + region: domainConfig.region || 'us-east-1', + endpoint: domainConfig.endpoint || null, listHostedZonesByName: true, // new/updated creds require this perm }; @@ -274,7 +274,7 @@ function verifyDnsConfig(domainObject, callback) { if (error) return callback(error); if (!_.isEqual(zone.DelegationSet.NameServers.sort(), nameservers.sort())) { - debug('verifyDnsConfig: %j and %j do not match', nameservers, zone.DelegationSet.NameServers); + debug('verifyDomainConfig: %j and %j do not match', nameservers, zone.DelegationSet.NameServers); return callback(new BoxError(BoxError.BAD_FIELD, 'Domain nameservers are not set to Route53', { field: 'nameservers' })); } @@ -284,12 +284,12 @@ function verifyDnsConfig(domainObject, callback) { upsert(newDomainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record added'); + debug('verifyDomainConfig: Test A record added'); del(newDomainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record removed again'); + debug('verifyDomainConfig: Test A record removed again'); callback(null, credentials); }); diff --git a/src/dns/vultr.js b/src/dns/vultr.js index 8fad66ab8..831621fb8 100644 --- a/src/dns/vultr.js +++ b/src/dns/vultr.js @@ -7,7 +7,7 @@ exports = module.exports = { get, del, wait, - verifyDnsConfig + verifyDomainConfig }; const async = require('async'), @@ -36,8 +36,8 @@ function injectPrivateFields(newConfig, currentConfig) { if (newConfig.token === constants.SECRET_PLACEHOLDER) newConfig.token = currentConfig.token; } -function getZoneRecords(dnsConfig, zoneName, name, type, callback) { - assert.strictEqual(typeof dnsConfig, 'object'); +function getZoneRecords(domainConfig, zoneName, name, type, callback) { + assert.strictEqual(typeof domainConfig, 'object'); assert.strictEqual(typeof zoneName, 'string'); assert.strictEqual(typeof name, 'string'); assert.strictEqual(typeof type, 'string'); @@ -52,7 +52,7 @@ function getZoneRecords(dnsConfig, zoneName, name, type, callback) { const url = `${VULTR_ENDPOINT}/domains/${zoneName}/records?per_page=${per_page}` + (cursor ? `&cursor=${cursor}` : ''); superagent.get(url) - .set('Authorization', 'Bearer ' + dnsConfig.token) + .set('Authorization', 'Bearer ' + domainConfig.token) .timeout(30 * 1000) .retry(5) .end(function (error, result) { @@ -84,11 +84,11 @@ function get(domainObject, location, type, callback) { assert.strictEqual(typeof type, 'string'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || ''; - getZoneRecords(dnsConfig, zoneName, name, type, function (error, records) { + getZoneRecords(domainConfig, zoneName, name, type, function (error, records) { if (error) return callback(error); var tmp = records.map(function (record) { return record.data; }); @@ -106,13 +106,13 @@ function upsert(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || ''; debug('upsert: %s for zone %s of type %s with values %j', name, zoneName, type, values); - getZoneRecords(dnsConfig, zoneName, name, type, function (error, records) { + getZoneRecords(domainConfig, zoneName, name, type, function (error, records) { if (error) return callback(error); let i = 0, recordIds = []; // used to track available records to update instead of create @@ -136,7 +136,7 @@ function upsert(domainObject, location, type, values, callback) { data.name = name; // only set for new records superagent.post(`${VULTR_ENDPOINT}/domains/${zoneName}/records`) - .set('Authorization', 'Bearer ' + dnsConfig.token) + .set('Authorization', 'Bearer ' + domainConfig.token) .send(data) .timeout(30 * 1000) .retry(5) @@ -152,7 +152,7 @@ function upsert(domainObject, location, type, values, callback) { }); } else { superagent.patch(`${VULTR_ENDPOINT}/domains/${zoneName}/records/${records[i].id}`) - .set('Authorization', 'Bearer ' + dnsConfig.token) + .set('Authorization', 'Bearer ' + domainConfig.token) .send(data) .timeout(30 * 1000) .retry(5) @@ -187,11 +187,11 @@ function del(domainObject, location, type, values, callback) { assert(Array.isArray(values)); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName, name = dns.getName(domainObject, location, type) || ''; - getZoneRecords(dnsConfig, zoneName, name, type, function (error, records) { + getZoneRecords(domainConfig, zoneName, name, type, function (error, records) { if (error) return callback(error); if (records.length === 0) return callback(null); @@ -205,7 +205,7 @@ function del(domainObject, location, type, values, callback) { // FIXME we only handle the first one currently superagent.del(`${VULTR_ENDPOINT}/domains/${zoneName}/records/${tmp[0].id}`) - .set('Authorization', 'Bearer ' + dnsConfig.token) + .set('Authorization', 'Bearer ' + domainConfig.token) .timeout(30 * 1000) .retry(5) .end(function (error, result) { @@ -234,19 +234,19 @@ function wait(domainObject, location, type, value, options, callback) { waitForDns(fqdn, domainObject.zoneName, type, value, options, callback); } -function verifyDnsConfig(domainObject, callback) { +function verifyDomainConfig(domainObject, callback) { assert.strictEqual(typeof domainObject, 'object'); assert.strictEqual(typeof callback, 'function'); - const dnsConfig = domainObject.config, + const domainConfig = domainObject.config, zoneName = domainObject.zoneName; - if (!dnsConfig.token || typeof dnsConfig.token !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'token must be a non-empty string', { field: 'token' })); + if (!domainConfig.token || typeof domainConfig.token !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'token must be a non-empty string', { field: 'token' })); const ip = '127.0.0.1'; var credentials = { - token: dnsConfig.token + token: domainConfig.token }; if (process.env.BOX_ENV === 'test') return callback(null, credentials); // this shouldn't be here @@ -256,7 +256,7 @@ function verifyDnsConfig(domainObject, callback) { if (error || !nameservers) return callback(new BoxError(BoxError.BAD_FIELD, error ? error.message : 'Unable to get nameservers', { field: 'nameservers' })); if (nameservers.map(function (n) { return n.toLowerCase(); }).indexOf('ns1.vultr.com') === -1) { - debug('verifyDnsConfig: %j does not contains vultr NS', nameservers); + debug('verifyDomainConfig: %j does not contains vultr NS', nameservers); return callback(new BoxError(BoxError.BAD_FIELD, 'Domain nameservers are not set to Vultr', { field: 'nameservers' })); } @@ -265,12 +265,12 @@ function verifyDnsConfig(domainObject, callback) { upsert(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record added'); + debug('verifyDomainConfig: Test A record added'); del(domainObject, location, 'A', [ ip ], function (error) { if (error) return callback(error); - debug('verifyDnsConfig: Test A record removed again'); + debug('verifyDomainConfig: Test A record removed again'); callback(null, credentials); }); diff --git a/src/dns/wildcard.js b/src/dns/wildcard.js index 847fc3873..a89e4ee39 100644 --- a/src/dns/wildcard.js +++ b/src/dns/wildcard.js @@ -7,7 +7,7 @@ exports = module.exports = { get, del, wait, - verifyDnsConfig + verifyDomainConfig }; const assert = require('assert'), @@ -70,7 +70,7 @@ function wait(domainObject, location, type, value, options, callback) { waitForDns(fqdn, domainObject.zoneName, type, value, options, callback); } -async function verifyDnsConfig(domainObject) { +async function verifyDomainConfig(domainObject) { assert.strictEqual(typeof domainObject, 'object'); const zoneName = domainObject.zoneName; diff --git a/src/domains.js b/src/domains.js index 5cf0ca39a..894ad7951 100644 --- a/src/domains.js +++ b/src/domains.js @@ -72,8 +72,8 @@ function maybePromisify(func) { return util.promisify(func); } -async function verifyDnsConfig(dnsConfig, domain, zoneName, provider) { - assert(dnsConfig && typeof dnsConfig === 'object'); // the dns config to test with +async function verifyDomainConfig(domainConfig, domain, zoneName, provider) { + assert(domainConfig && typeof domainConfig === 'object'); // the dns config to test with assert.strictEqual(typeof domain, 'string'); assert.strictEqual(typeof zoneName, 'string'); assert.strictEqual(typeof provider, 'string'); @@ -81,8 +81,8 @@ async function verifyDnsConfig(dnsConfig, domain, zoneName, provider) { const backend = api(provider); if (!backend) throw new BoxError(BoxError.BAD_FIELD, 'Invalid provider', { field: 'provider' }); - const domainObject = { config: dnsConfig, domain: domain, zoneName: zoneName }; - const [error, result] = await safe(maybePromisify(api(provider).verifyDnsConfig)(domainObject)); + const domainObject = { config: domainConfig, domain: domain, zoneName: zoneName }; + const [error, result] = await safe(maybePromisify(api(provider).verifyDomainConfig)(domainObject)); if (error && error.reason === BoxError.ACCESS_DENIED) return { error: new BoxError(BoxError.BAD_FIELD, `Access denied: ${error.message}`) }; if (error && error.reason === BoxError.NOT_FOUND) return { error: new BoxError(BoxError.BAD_FIELD, `Zone not found: ${error.message}`) }; if (error && error.reason === BoxError.EXTERNAL_ERROR) return { error: new BoxError(BoxError.BAD_FIELD, `Configuration error: ${error.message}`) }; @@ -156,7 +156,7 @@ async function add(domain, data, auditSource) { dkimSelector = `cloudron-${suffix}`; } - const result = await verifyDnsConfig(config, domain, zoneName, provider); + const result = await verifyDomainConfig(config, domain, zoneName, provider); if (result.error) throw result.error; let queries = [ @@ -221,7 +221,7 @@ async function setConfig(domain, data, auditSource) { if (provider === domainObject.provider) api(provider).injectPrivateFields(config, domainObject.config); - const result = await verifyDnsConfig(config, domain, zoneName, provider); + const result = await verifyDomainConfig(config, domain, zoneName, provider); if (result.error) throw result.error; const newData = { diff --git a/src/provision.js b/src/provision.js index a044485a1..b6c212c9b 100644 --- a/src/provision.js +++ b/src/provision.js @@ -83,8 +83,8 @@ async function setupTask(domain, auditSource) { gProvisionStatus.setup.active = false; } -async function setup(dnsConfig, sysinfoConfig, auditSource) { - assert.strictEqual(typeof dnsConfig, 'object'); +async function setup(domainConfig, sysinfoConfig, auditSource) { + assert.strictEqual(typeof domainConfig, 'object'); assert.strictEqual(typeof sysinfoConfig, 'object'); assert.strictEqual(typeof auditSource, 'object'); @@ -98,17 +98,17 @@ async function setup(dnsConfig, sysinfoConfig, auditSource) { await unprovision(); - const domain = dnsConfig.domain.toLowerCase(); - const zoneName = dnsConfig.zoneName ? dnsConfig.zoneName : (tld.getDomain(domain) || domain); + const domain = domainConfig.domain.toLowerCase(); + const zoneName = domainConfig.zoneName ? domainConfig.zoneName : (tld.getDomain(domain) || domain); debug(`setup: Setting up Cloudron with domain ${domain} and zone ${zoneName}`); const data = { zoneName: zoneName, - provider: dnsConfig.provider, - config: dnsConfig.config, - fallbackCertificate: dnsConfig.fallbackCertificate || null, - tlsConfig: dnsConfig.tlsConfig || { provider: 'letsencrypt-prod' }, + provider: domainConfig.provider, + config: domainConfig.config, + fallbackCertificate: domainConfig.fallbackCertificate || null, + tlsConfig: domainConfig.tlsConfig || { provider: 'letsencrypt-prod' }, dkimSelector: 'cloudron' }; diff --git a/src/routes/provision.js b/src/routes/provision.js index 012044911..d536fbfc4 100644 --- a/src/routes/provision.js +++ b/src/routes/provision.js @@ -52,25 +52,25 @@ async function providerTokenAuth(req, res, next) { async function setup(req, res, next) { assert.strictEqual(typeof req.body, 'object'); - if (!req.body.dnsConfig || typeof req.body.dnsConfig !== 'object') return next(new HttpError(400, 'dnsConfig is required')); + if (!req.body.domainConfig || typeof req.body.domainConfig !== 'object') return next(new HttpError(400, 'domainConfig is required')); - const dnsConfig = req.body.dnsConfig; + const domainConfig = req.body.domainConfig; - if (typeof dnsConfig.provider !== 'string' || !dnsConfig.provider) return next(new HttpError(400, 'provider is required')); - if (typeof dnsConfig.domain !== 'string' || !dnsConfig.domain) return next(new HttpError(400, 'domain is required')); + if (typeof domainConfig.provider !== 'string' || !domainConfig.provider) return next(new HttpError(400, 'provider is required')); + if (typeof domainConfig.domain !== 'string' || !domainConfig.domain) return next(new HttpError(400, 'domain is required')); - if ('zoneName' in dnsConfig && typeof dnsConfig.zoneName !== 'string') return next(new HttpError(400, 'zoneName must be a string')); - if (!dnsConfig.config || typeof dnsConfig.config !== 'object') return next(new HttpError(400, 'config must be an object')); + if ('zoneName' in domainConfig && typeof domainConfig.zoneName !== 'string') return next(new HttpError(400, 'zoneName must be a string')); + if (!domainConfig.config || typeof domainConfig.config !== 'object') return next(new HttpError(400, 'config must be an object')); - if ('tlsConfig' in dnsConfig && typeof dnsConfig.tlsConfig !== 'object') return next(new HttpError(400, 'tlsConfig must be an object')); - if (dnsConfig.tlsConfig && (!dnsConfig.tlsConfig.provider || typeof dnsConfig.tlsConfig.provider !== 'string')) return next(new HttpError(400, 'tlsConfig.provider must be a string')); + if ('tlsConfig' in domainConfig && typeof domainConfig.tlsConfig !== 'object') return next(new HttpError(400, 'tlsConfig must be an object')); + if (domainConfig.tlsConfig && (!domainConfig.tlsConfig.provider || typeof domainConfig.tlsConfig.provider !== 'string')) return next(new HttpError(400, 'tlsConfig.provider must be a string')); if ('sysinfoConfig' in req.body && typeof req.body.sysinfoConfig !== 'object') return next(new HttpError(400, 'sysinfoConfig must be an object')); // it can take sometime to setup DNS, register cloudron req.clearTimeout(); - const [error] = await safe(provision.setup(dnsConfig, req.body.sysinfoConfig || { provider: 'generic' }, AuditSource.fromRequest(req))); + const [error] = await safe(provision.setup(domainConfig, req.body.sysinfoConfig || { provider: 'generic' }, AuditSource.fromRequest(req))); if (error) return next(BoxError.toHttpError(error)); next(new HttpSuccess(200, {})); diff --git a/src/routes/test/apps-test.js b/src/routes/test/apps-test.js index 009cb2f90..c96aee8a2 100644 --- a/src/routes/test/apps-test.js +++ b/src/routes/test/apps-test.js @@ -143,7 +143,7 @@ function startBox(done) { function (callback) { superagent.post(SERVER_URL + '/api/v1/cloudron/setup') - .send({ dnsConfig: DOMAIN_0 }) + .send({ domainConfig: DOMAIN_0 }) .end(function (error, result) { expect(result).to.be.ok(); expect(result.statusCode).to.eql(200); diff --git a/src/routes/test/common.js b/src/routes/test/common.js index 300729a87..123c91253 100644 --- a/src/routes/test/common.js +++ b/src/routes/test/common.js @@ -59,7 +59,7 @@ async function setup() { // setup let response = await superagent.post(`${serverUrl}/api/v1/cloudron/setup`) - .send({ dnsConfig: { provider: 'noop', domain: exports.dashboardDomain, config: {}, tlsConfig: { provider: 'fallback' } } }); + .send({ domainConfig: { provider: 'noop', domain: exports.dashboardDomain, config: {}, tlsConfig: { provider: 'fallback' } } }); expect(response.status).to.eql(200); await delay(2000); diff --git a/src/routes/test/provision-test.js b/src/routes/test/provision-test.js index 5adddc98c..0ef99313d 100644 --- a/src/routes/test/provision-test.js +++ b/src/routes/test/provision-test.js @@ -36,7 +36,7 @@ describe('Provision', function () { describe('DNS Setup', async function () { it('fails without provider', async function () { const response = await superagent.post(`${serverUrl}/api/v1/cloudron/setup`) - .send({ dnsConfig: { domain: DOMAIN, config: {} } }) + .send({ domainConfig: { domain: DOMAIN, config: {} } }) .ok(() => true); expect(response.statusCode).to.eql(400); @@ -44,7 +44,7 @@ describe('Provision', function () { it('fails with invalid provider', async function () { const response = await superagent.post(`${serverUrl}/api/v1/cloudron/setup`) - .send({ dnsConfig: { provider: 'foobar', domain: DOMAIN, config: {} } }) + .send({ domainConfig: { provider: 'foobar', domain: DOMAIN, config: {} } }) .ok(() => true); expect(response.statusCode).to.eql(400); @@ -52,7 +52,7 @@ describe('Provision', function () { it('fails with missing domain', async function () { const response = await superagent.post(`${serverUrl}/api/v1/cloudron/setup`) - .send({ dnsConfig: { provider: 'noop', config: {} } }) + .send({ domainConfig: { provider: 'noop', config: {} } }) .ok(() => true); expect(response.statusCode).to.eql(400); @@ -60,7 +60,7 @@ describe('Provision', function () { it('fails with invalid domain', async function () { const response = await superagent.post(`${serverUrl}/api/v1/cloudron/setup`) - .send({ dnsConfig: { provider: 'noop', domain: '.foo', config: {} } }) + .send({ domainConfig: { provider: 'noop', domain: '.foo', config: {} } }) .ok(() => true); expect(response.statusCode).to.eql(400); @@ -68,7 +68,7 @@ describe('Provision', function () { it('fails with invalid config', async function () { const response = await superagent.post(`${serverUrl}/api/v1/cloudron/setup`) - .send({ dnsConfig: { provider: 'noop', domain: DOMAIN, config: 'not an object' } }) + .send({ domainConfig: { provider: 'noop', domain: DOMAIN, config: 'not an object' } }) .ok(() => true); expect(response.statusCode).to.eql(400); @@ -76,7 +76,7 @@ describe('Provision', function () { it('fails with invalid zoneName', async function () { const response = await superagent.post(`${serverUrl}/api/v1/cloudron/setup`) - .send({ dnsConfig: { provider: 'noop', domain: DOMAIN, config: {}, zoneName: 1337 } }) + .send({ domainConfig: { provider: 'noop', domain: DOMAIN, config: {}, zoneName: 1337 } }) .ok(() => true); expect(response.statusCode).to.eql(400); @@ -84,7 +84,7 @@ describe('Provision', function () { it('fails with invalid tlsConfig', async function () { const response = await superagent.post(`${serverUrl}/api/v1/cloudron/setup`) - .send({ dnsConfig: { provider: 'noop', domain: DOMAIN, config: {}, tlsConfig: 'foobar' } }) + .send({ domainConfig: { provider: 'noop', domain: DOMAIN, config: {}, tlsConfig: 'foobar' } }) .ok(() => true); expect(response.statusCode).to.eql(400); @@ -92,7 +92,7 @@ describe('Provision', function () { it('fails with invalid tlsConfig provider', async function () { const response = await superagent.post(`${serverUrl}/api/v1/cloudron/setup`) - .send({ dnsConfig: { provider: 'noop', domain: DOMAIN, config: {}, tlsConfig: { provider: 1337 } } }) + .send({ domainConfig: { provider: 'noop', domain: DOMAIN, config: {}, tlsConfig: { provider: 1337 } } }) .ok(() => true); expect(response.statusCode).to.eql(400); @@ -100,7 +100,7 @@ describe('Provision', function () { it('succeeds', async function () { const response = await superagent.post(`${serverUrl}/api/v1/cloudron/setup`) - .send({ dnsConfig: { provider: 'noop', domain: DOMAIN, adminFqdn: 'my.' + DOMAIN, config: {}, tlsConfig: { provider: 'fallback' } } }) + .send({ domainConfig: { provider: 'noop', domain: DOMAIN, adminFqdn: 'my.' + DOMAIN, config: {}, tlsConfig: { provider: 'fallback' } } }) .ok(() => true); expect(response.statusCode).to.eql(200); @@ -110,7 +110,7 @@ describe('Provision', function () { it('twice succeeds', async function () { const response = await superagent.post(`${serverUrl}/api/v1/cloudron/setup`) - .send({ dnsConfig: { provider: 'noop', domain: DOMAIN, adminFqdn: 'my.' + DOMAIN, config: {}, tlsConfig: { provider: 'fallback' } } }) + .send({ domainConfig: { provider: 'noop', domain: DOMAIN, adminFqdn: 'my.' + DOMAIN, config: {}, tlsConfig: { provider: 'fallback' } } }) .ok(() => true); expect(response.statusCode).to.eql(200); @@ -224,7 +224,7 @@ describe('Provision', function () { it('after fails', async function () { const response = await superagent.post(`${serverUrl}/api/v1/cloudron/setup`) - .send({ dnsConfig: { provider: 'noop', domain: DOMAIN, adminFqdn: 'my.' + DOMAIN, config: {}, tlsConfig: { provider: 'fallback' } } }) + .send({ domainConfig: { provider: 'noop', domain: DOMAIN, adminFqdn: 'my.' + DOMAIN, config: {}, tlsConfig: { provider: 'fallback' } } }) .ok(() => true); expect(response.statusCode).to.eql(409);