From 106e17f7ff5c7a12b1c2b27659b1b4eede490fea Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Sun, 17 Jun 2018 22:22:03 -0700 Subject: [PATCH] caas: verify dns config this is so that it fails if someone gives invalid token via API call --- src/dns/caas.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/dns/caas.js b/src/dns/caas.js index 7c664e1fe..455383afe 100644 --- a/src/dns/caas.js +++ b/src/dns/caas.js @@ -133,5 +133,19 @@ function verifyDnsConfig(dnsConfig, domain, zoneName, ip, callback) { fqdn: domain }; - return callback(null, credentials); + const testSubdomain = 'cloudrontestdns'; + + upsert(credentials, zoneName, testSubdomain, 'A', [ ip ], function (error, changeId) { + if (error) return callback(error); + + debug('verifyDnsConfig: Test A record added with change id %s', changeId); + + del(credentials, zoneName, testSubdomain, 'A', [ ip ], function (error) { + if (error) return callback(error); + + debug('verifyDnsConfig: Test A record removed again'); + + callback(null, credentials); + }); + }); }