godaddy: do not remove all the records of type

This commit is contained in:
Girish Ramakrishnan
2022-04-28 17:43:10 -07:00
parent 765f6d1b12
commit e097b79f65
2 changed files with 9 additions and 7 deletions
+7
View File
@@ -126,6 +126,13 @@ async function del(domainObject, location, type, values) {
debug(`del: ${name} in zone ${zoneName} of type ${type} with values ${JSON.stringify(values)}`);
const result = await get(domainObject, location, type);
if (result.length === 0) return;
const tmp = result.filter(r => !values.includes(r));
if (tmp.length) return await upsert(domainObject, location, type, tmp); // only remove 'values'
const [error, response] = await safe(superagent.del(`${GODADDY_API}/${zoneName}/records/${type}/${name}`)
.set('Authorization', `sso-key ${domainConfig.apiKey}:${domainConfig.apiSecret}`)
.timeout(30 * 1000)
+2 -7
View File
@@ -338,18 +338,13 @@ describe('dns provider', function () {
data: '1.2.3.4'
}];
const DOMAIN_RECORD_1 = [{ // replaced
ttl: 600,
data: '0.0.0.0'
}];
const req1 = nock(GODADDY_API)
.get('/' + domainCopy.zoneName + '/records/A/test')
.reply(200, DOMAIN_RECORD_0);
const req2 = nock(GODADDY_API)
.put('/' + domainCopy.zoneName + '/records/A/test', DOMAIN_RECORD_1)
.reply(200, {});
.delete('/' + domainCopy.zoneName + '/records/A/test')
.reply(204, {});
await dns.removeDnsRecords('test', domainCopy.domain, 'A', ['1.2.3.4']);
expect(req1.isDone()).to.be.ok();