fix storage test

This commit is contained in:
Girish Ramakrishnan
2022-04-14 20:43:04 -05:00
parent 72408f2542
commit f7ed044a40
3 changed files with 147 additions and 171 deletions

View File

@@ -46,8 +46,8 @@ describe('dns provider', function () {
});
describe('digitalocean', function () {
let TOKEN = 'sometoken';
let DIGITALOCEAN_ENDPOINT = 'https://api.digitalocean.com';
const TOKEN = 'sometoken';
const DIGITALOCEAN_ENDPOINT = 'https://api.digitalocean.com';
before(async function () {
domainCopy.provider = 'digitalocean';
@@ -61,7 +61,7 @@ describe('dns provider', function () {
it('upsert non-existing record succeeds', async function () {
nock.cleanAll();
let DOMAIN_RECORD_0 = {
const DOMAIN_RECORD_0 = {
id: 3352892,
type: 'A',
name: '@',
@@ -71,10 +71,10 @@ describe('dns provider', function () {
weight: null
};
let req1 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
const req1 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
.get('/v2/domains/' + domainCopy.zoneName + '/records')
.reply(200, { domain_records: [] });
let req2 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
const req2 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
.post('/v2/domains/' + domainCopy.zoneName + '/records')
.reply(201, { domain_record: DOMAIN_RECORD_0 });
@@ -86,7 +86,7 @@ describe('dns provider', function () {
it('upsert existing record succeeds', async function () {
nock.cleanAll();
let DOMAIN_RECORD_0 = {
const DOMAIN_RECORD_0 = {
id: 3352892,
type: 'A',
name: '@',
@@ -96,7 +96,7 @@ describe('dns provider', function () {
weight: null
};
let DOMAIN_RECORD_1 = {
const DOMAIN_RECORD_1 = {
id: 3352893,
type: 'A',
name: 'test',
@@ -106,7 +106,7 @@ describe('dns provider', function () {
weight: null
};
let DOMAIN_RECORD_1_NEW = {
const DOMAIN_RECORD_1_NEW = {
id: 3352893,
type: 'A',
name: 'test',
@@ -116,10 +116,10 @@ describe('dns provider', function () {
weight: null
};
let req1 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
const req1 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
.get('/v2/domains/' + domainCopy.zoneName + '/records')
.reply(200, { domain_records: [DOMAIN_RECORD_0, DOMAIN_RECORD_1] });
let req2 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
const req2 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
.put('/v2/domains/' + domainCopy.zoneName + '/records/' + DOMAIN_RECORD_1.id)
.reply(200, { domain_record: DOMAIN_RECORD_1_NEW });
@@ -131,7 +131,7 @@ describe('dns provider', function () {
it('upsert multiple record succeeds', async function () {
nock.cleanAll();
let DOMAIN_RECORD_0 = {
const DOMAIN_RECORD_0 = {
id: 3352892,
type: 'A',
name: '@',
@@ -141,7 +141,7 @@ describe('dns provider', function () {
weight: null
};
let DOMAIN_RECORD_1 = {
const DOMAIN_RECORD_1 = {
id: 3352893,
type: 'TXT',
name: '@',
@@ -151,7 +151,7 @@ describe('dns provider', function () {
weight: null
};
let DOMAIN_RECORD_1_NEW = {
const DOMAIN_RECORD_1_NEW = {
id: 3352893,
type: 'TXT',
name: '@',
@@ -161,7 +161,7 @@ describe('dns provider', function () {
weight: null
};
let DOMAIN_RECORD_2 = {
const DOMAIN_RECORD_2 = {
id: 3352894,
type: 'TXT',
name: '@',
@@ -171,7 +171,7 @@ describe('dns provider', function () {
weight: null
};
let DOMAIN_RECORD_2_NEW = {
const DOMAIN_RECORD_2_NEW = {
id: 3352894,
type: 'TXT',
name: '@',
@@ -181,7 +181,7 @@ describe('dns provider', function () {
weight: null
};
let DOMAIN_RECORD_3_NEW = {
const DOMAIN_RECORD_3_NEW = {
id: 3352895,
type: 'TXT',
name: '@',
@@ -191,16 +191,16 @@ describe('dns provider', function () {
weight: null
};
let req1 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
const req1 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
.get('/v2/domains/' + domainCopy.zoneName + '/records')
.reply(200, { domain_records: [DOMAIN_RECORD_0, DOMAIN_RECORD_1, DOMAIN_RECORD_2] });
let req2 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
const req2 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
.put('/v2/domains/' + domainCopy.zoneName + '/records/' + DOMAIN_RECORD_1.id)
.reply(200, { domain_record: DOMAIN_RECORD_1_NEW });
let req3 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
const req3 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
.put('/v2/domains/' + domainCopy.zoneName + '/records/' + DOMAIN_RECORD_2.id)
.reply(200, { domain_record: DOMAIN_RECORD_2_NEW });
let req4 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
const req4 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
.post('/v2/domains/' + domainCopy.zoneName + '/records')
.reply(201, { domain_record: DOMAIN_RECORD_2_NEW });
@@ -214,7 +214,7 @@ describe('dns provider', function () {
it('get succeeds', async function () {
nock.cleanAll();
let DOMAIN_RECORD_0 = {
const DOMAIN_RECORD_0 = {
id: 3352892,
type: 'A',
name: '@',
@@ -224,7 +224,7 @@ describe('dns provider', function () {
weight: null
};
let DOMAIN_RECORD_1 = {
const DOMAIN_RECORD_1 = {
id: 3352893,
type: 'A',
name: 'test',
@@ -234,7 +234,7 @@ describe('dns provider', function () {
weight: null
};
let req1 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
const req1 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
.get('/v2/domains/' + domainCopy.zoneName + '/records')
.reply(200, { domain_records: [DOMAIN_RECORD_0, DOMAIN_RECORD_1] });
@@ -248,7 +248,7 @@ describe('dns provider', function () {
it('del succeeds', async function () {
nock.cleanAll();
let DOMAIN_RECORD_0 = {
const DOMAIN_RECORD_0 = {
id: 3352892,
type: 'A',
name: '@',
@@ -258,7 +258,7 @@ describe('dns provider', function () {
weight: null
};
let DOMAIN_RECORD_1 = {
const DOMAIN_RECORD_1 = {
id: 3352893,
type: 'A',
name: 'test',
@@ -268,10 +268,10 @@ describe('dns provider', function () {
weight: null
};
let req1 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
const req1 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
.get('/v2/domains/' + domainCopy.zoneName + '/records')
.reply(200, { domain_records: [DOMAIN_RECORD_0, DOMAIN_RECORD_1] });
let req2 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
const req2 = nock(DIGITALOCEAN_ENDPOINT).filteringRequestBody(function () { return false; })
.delete('/v2/domains/' + domainCopy.zoneName + '/records/' + DOMAIN_RECORD_1.id)
.reply(204, {});
@@ -282,8 +282,8 @@ describe('dns provider', function () {
});
describe('godaddy', function () {
let KEY = 'somekey', SECRET = 'somesecret';
let GODADDY_API = 'https://api.godaddy.com/v1/domains';
const KEY = 'somekey', SECRET = 'somesecret';
const GODADDY_API = 'https://api.godaddy.com/v1/domains';
before(async function () {
domainCopy.provider = 'godaddy';
@@ -298,12 +298,12 @@ describe('dns provider', function () {
it('upsert record succeeds', async function () {
nock.cleanAll();
let DOMAIN_RECORD_0 = [{
const DOMAIN_RECORD_0 = [{
ttl: 600,
data: '1.2.3.4'
}];
let req1 = nock(GODADDY_API)
const req1 = nock(GODADDY_API)
.put('/' + domainCopy.zoneName + '/records/A/test', DOMAIN_RECORD_0)
.reply(200, {});
@@ -314,12 +314,12 @@ describe('dns provider', function () {
it('get succeeds', async function () {
nock.cleanAll();
let DOMAIN_RECORD_0 = [{
const DOMAIN_RECORD_0 = [{
ttl: 600,
data: '1.2.3.4'
}];
let req1 = nock(GODADDY_API)
const req1 = nock(GODADDY_API)
.get('/' + domainCopy.zoneName + '/records/A/test')
.reply(200, DOMAIN_RECORD_0);
@@ -333,21 +333,21 @@ describe('dns provider', function () {
it('del succeeds', async function () {
nock.cleanAll();
let DOMAIN_RECORD_0 = [{ // existing
const DOMAIN_RECORD_0 = [{ // existing
ttl: 600,
data: '1.2.3.4'
}];
let DOMAIN_RECORD_1 = [{ // replaced
const DOMAIN_RECORD_1 = [{ // replaced
ttl: 600,
data: '0.0.0.0'
}];
let req1 = nock(GODADDY_API)
const req1 = nock(GODADDY_API)
.get('/' + domainCopy.zoneName + '/records/A/test')
.reply(200, DOMAIN_RECORD_0);
let req2 = nock(GODADDY_API)
const req2 = nock(GODADDY_API)
.put('/' + domainCopy.zoneName + '/records/A/test', DOMAIN_RECORD_1)
.reply(200, {});
@@ -358,8 +358,8 @@ describe('dns provider', function () {
});
describe('gandi', function () {
let TOKEN = 'sometoken';
let GANDI_API = 'https://dns.api.gandi.net/api/v5';
const TOKEN = 'sometoken';
const GANDI_API = 'https://dns.api.gandi.net/api/v5';
before(async function () {
domainCopy.provider = 'gandi';
@@ -373,12 +373,12 @@ describe('dns provider', function () {
it('upsert record succeeds', async function () {
nock.cleanAll();
let DOMAIN_RECORD_0 = {
const DOMAIN_RECORD_0 = {
'rrset_ttl': 300,
'rrset_values': ['1.2.3.4']
};
let req1 = nock(GANDI_API)
const req1 = nock(GANDI_API)
.put('/domains/' + domainCopy.zoneName + '/records/test/A', DOMAIN_RECORD_0)
.reply(201, { message: 'Zone Record Created' });
@@ -389,14 +389,14 @@ describe('dns provider', function () {
it('get succeeds', async function () {
nock.cleanAll();
let DOMAIN_RECORD_0 = {
const DOMAIN_RECORD_0 = {
'rrset_type': 'A',
'rrset_ttl': 600,
'rrset_name': 'test',
'rrset_values': ['1.2.3.4']
};
let req1 = nock(GANDI_API)
const req1 = nock(GANDI_API)
.get('/domains/' + domainCopy.zoneName + '/records/test/A')
.reply(200, DOMAIN_RECORD_0);
@@ -410,7 +410,7 @@ describe('dns provider', function () {
it('del succeeds', async function () {
nock.cleanAll();
let req2 = nock(GANDI_API)
const req2 = nock(GANDI_API)
.delete('/domains/' + domainCopy.zoneName + '/records/test/A')
.reply(204, {});
@@ -436,18 +436,18 @@ describe('dns provider', function () {
it('upsert record succeeds', async function () {
nock.cleanAll();
let DOMAIN_RECORD_0 = {
const DOMAIN_RECORD_0 = {
host: 'test',
type: 'A',
answer: '1.2.3.4',
ttl: 300
};
let req1 = nock(NAMECOM_API)
const req1 = nock(NAMECOM_API)
.get(`/domains/${domainCopy.zoneName}/records`)
.reply(200, { records: [] });
let req2 = nock(NAMECOM_API)
const req2 = nock(NAMECOM_API)
.post(`/domains/${domainCopy.zoneName}/records`, DOMAIN_RECORD_0)
.reply(200, {});
@@ -459,14 +459,14 @@ describe('dns provider', function () {
it('get succeeds', async function () {
nock.cleanAll();
let DOMAIN_RECORD_0 = {
const DOMAIN_RECORD_0 = {
host: 'test',
type: 'A',
answer: '1.2.3.4',
ttl: 300
};
let req1 = nock(NAMECOM_API)
const req1 = nock(NAMECOM_API)
.get(`/domains/${domainCopy.zoneName}/records`)
.reply(200, { records: [DOMAIN_RECORD_0] });
@@ -480,7 +480,7 @@ describe('dns provider', function () {
it('del succeeds', async function () {
nock.cleanAll();
let DOMAIN_RECORD_0 = {
const DOMAIN_RECORD_0 = {
id: 'someid',
host: 'test',
type: 'A',
@@ -488,11 +488,11 @@ describe('dns provider', function () {
ttl: 300
};
let req1 = nock(NAMECOM_API)
const req1 = nock(NAMECOM_API)
.get(`/domains/${domainCopy.zoneName}/records`)
.reply(200, { records: [DOMAIN_RECORD_0] });
let req2 = nock(NAMECOM_API)
const req2 = nock(NAMECOM_API)
.delete(`/domains/${domainCopy.zoneName}/records/${DOMAIN_RECORD_0.id}`)
.reply(200, {});
@@ -554,7 +554,7 @@ describe('dns provider', function () {
<ExecutionTime>0.16</ExecutionTime>
</ApiResponse>`;
let req1 = nock(NAMECHEAP_ENDPOINT).get('/xml.response')
const req1 = nock(NAMECHEAP_ENDPOINT).get('/xml.response')
.query({
ApiUser: username,
ApiKey: token,
@@ -566,7 +566,7 @@ describe('dns provider', function () {
})
.reply(200, GET_HOSTS_RETURN);
let req2 = nock(NAMECHEAP_ENDPOINT).post('/xml.response', (body) => {
const req2 = nock(NAMECHEAP_ENDPOINT).post('/xml.response', (body) => {
const expected = {
ApiUser: username,
ApiKey: token,
@@ -619,7 +619,7 @@ describe('dns provider', function () {
<ExecutionTime>0.16</ExecutionTime>
</ApiResponse>`;
let req1 = nock(NAMECHEAP_ENDPOINT).get('/xml.response')
const req1 = nock(NAMECHEAP_ENDPOINT).get('/xml.response')
.query({
ApiUser: username,
ApiKey: token,
@@ -631,7 +631,7 @@ describe('dns provider', function () {
})
.reply(200, GET_HOSTS_RETURN);
let req2 = nock(NAMECHEAP_ENDPOINT).post('/xml.response', (body) => {
const req2 = nock(NAMECHEAP_ENDPOINT).post('/xml.response', (body) => {
const expected = {
ApiUser: username,
ApiKey: token,
@@ -694,7 +694,7 @@ describe('dns provider', function () {
<ExecutionTime>0.16</ExecutionTime>
</ApiResponse>`;
let req1 = nock(NAMECHEAP_ENDPOINT).get('/xml.response')
const req1 = nock(NAMECHEAP_ENDPOINT).get('/xml.response')
.query({
ApiUser: username,
ApiKey: token,
@@ -706,7 +706,7 @@ describe('dns provider', function () {
})
.reply(200, GET_HOSTS_RETURN);
let req2 = nock(NAMECHEAP_ENDPOINT).post('/xml.response', (body) => {
const req2 = nock(NAMECHEAP_ENDPOINT).post('/xml.response', (body) => {
const expected = {
ApiUser: username,
ApiKey: token,
@@ -755,7 +755,7 @@ describe('dns provider', function () {
<ExecutionTime>0.16</ExecutionTime>
</ApiResponse>`;
let req1 = nock(NAMECHEAP_ENDPOINT).get('/xml.response')
const req1 = nock(NAMECHEAP_ENDPOINT).get('/xml.response')
.query({
ApiUser: username,
ApiKey: token,
@@ -791,7 +791,7 @@ describe('dns provider', function () {
<ExecutionTime>0.16</ExecutionTime>
</ApiResponse>`;
let req1 = nock(NAMECHEAP_ENDPOINT).get('/xml.response')
const req1 = nock(NAMECHEAP_ENDPOINT).get('/xml.response')
.query({
ApiUser: username,
ApiKey: token,
@@ -803,7 +803,7 @@ describe('dns provider', function () {
})
.reply(200, GET_HOSTS_RETURN);
let req2 = nock(NAMECHEAP_ENDPOINT).post('/xml.response', (body) => {
const req2 = nock(NAMECHEAP_ENDPOINT).post('/xml.response', (body) => {
const expected = {
ApiUser: username,
ApiKey: token,
@@ -846,7 +846,7 @@ describe('dns provider', function () {
<ExecutionTime>0.16</ExecutionTime>
</ApiResponse>`;
let req1 = nock(NAMECHEAP_ENDPOINT).get('/xml.response')
const req1 = nock(NAMECHEAP_ENDPOINT).get('/xml.response')
.query({
ApiUser: username,
ApiKey: token,
@@ -866,7 +866,7 @@ describe('dns provider', function () {
describe('route53', function () {
// do not clear this with [] but .length = 0 so we don't loose the reference in mockery
let awsAnswerQueue = []; // every element itself is array: [0] is error and [1] is result
const awsAnswerQueue = []; // every element itself is array: [0] is error and [1] is result
let AWS_HOSTED_ZONES = null;
@@ -1021,7 +1021,7 @@ describe('dns provider', function () {
describe('gcdns', function () {
let HOSTED_ZONES = [];
let zoneQueue = []; // every element itself is array: [0] is error and [1] is result
const zoneQueue = []; // every element itself is array: [0] is error and [1] is result
let _OriginalGCDNS;
before(async function () {