@f5devcentral/f5-cloud-libs-aws
Advanced tools
Comparing version 2.8.0 to 2.9.1
{ | ||
"name": "@f5devcentral/f5-cloud-libs-aws", | ||
"version": "2.8.0", | ||
"version": "2.9.1", | ||
"description": "AWS implementation of f5-cloud-libs cloud provider code", | ||
@@ -15,2 +15,7 @@ "keywords": [ | ||
}, | ||
"auditProcessor": { | ||
"whitelist": [ | ||
"1523" | ||
] | ||
}, | ||
"bugs": { | ||
@@ -28,2 +33,11 @@ "url": "https://github.com/F5Networks/f5-cloud-libs-aws/issues" | ||
}, | ||
"eslintConfig": { | ||
"plugins": [ | ||
"mocha" | ||
], | ||
"env": { | ||
"mocha": true, | ||
"node": true | ||
} | ||
}, | ||
"devDependencies": { | ||
@@ -33,10 +47,12 @@ "eslint": "^4.19.1", | ||
"eslint-plugin-import": "^2.11.0", | ||
"nodeunit": "^0.11.3" | ||
"eslint-plugin-mocha": "^8.0.0", | ||
"mocha": "^7.1.1" | ||
}, | ||
"scripts": { | ||
"audit": "npm audit --json > .auditReport.json; node scripts/auditProcessor.js", | ||
"lint": "node node_modules/eslint/bin/eslint lib", | ||
"package": "./package.sh", | ||
"test": "node_modules/nodeunit/bin/nodeunit --reporter eclipse test test/lib", | ||
"test": "mocha --exit test test/lib", | ||
"version": "./setVersion.sh $npm_package_version && git add ." | ||
} | ||
} |
@@ -34,3 +34,3 @@ #!/usr/bin/env node | ||
const loggerOptions = {}; | ||
const DEFAULT_LOG_FILE = '/var/log/cloudlibs/verifyDeploymentCompletion.log'; | ||
const DEFAULT_LOG_FILE = '/var/log/cloud/aws/verifyDeploymentCompletion.log'; | ||
options | ||
@@ -37,0 +37,0 @@ .version('1.0.0') |
@@ -19,2 +19,3 @@ /** | ||
const assert = require('assert'); | ||
process.env.NODE_PATH = `${__dirname}/../../../`; | ||
@@ -25,46 +26,46 @@ require('module').Module._initPaths(); // eslint-disable-line no-underscore-dangle | ||
let q; | ||
let fsMock; | ||
let awsMock; | ||
let AwsCloudProvider; | ||
let bigIpMock; | ||
let utilMock; | ||
let provider; | ||
describe('aws cloud provider tests', () => { | ||
let q; | ||
let fsMock; | ||
let awsMock; | ||
let AwsCloudProvider; | ||
let bigIpMock; | ||
let utilMock; | ||
let provider; | ||
const providerOptions = { | ||
s3Bucket: 'foo', | ||
sqsUrl: 'bar' | ||
}; | ||
const providerOptions = { | ||
s3Bucket: 'foo', | ||
sqsUrl: 'bar' | ||
}; | ||
const user = 'foo'; | ||
const password = 'bar'; | ||
const instanceId = '1234'; | ||
const user = 'foo'; | ||
const password = 'bar'; | ||
const instanceId = '1234'; | ||
let fsReadFile; | ||
let fsStat; | ||
let fsReadFile; | ||
let fsStat; | ||
let iidDoc; | ||
let instances; | ||
let instance1; | ||
let instance2; | ||
let iidDoc; | ||
let instances; | ||
let instance1; | ||
let instance2; | ||
let deletedInstances; | ||
let deletedInstances; | ||
let getObjectParams; | ||
let instanceProtectionParams; | ||
let getObjectParams; | ||
let instanceProtectionParams; | ||
let passedCreateTagsParams; | ||
let deleteTagRequests; | ||
let passedDescribeTagsParams; | ||
let describeTagsResults; | ||
let passedCreateTagsParams; | ||
let deleteTagRequests; | ||
let passedDescribeTagsParams; | ||
let describeTagsResults; | ||
let passedSignalResourceParams; | ||
let passedSignalResourceParams; | ||
const INSTANCES_FOLDER = 'instances/'; | ||
const INSTANCES_FOLDER = 'instances/'; | ||
// Our tests cause too many event listeners. Turn off the check. | ||
process.setMaxListeners(0); | ||
// Our tests cause too many event listeners. Turn off the check. | ||
process.setMaxListeners(0); | ||
module.exports = { | ||
setUp(callback) { | ||
beforeEach(() => { | ||
/* eslint-disable global-require */ | ||
@@ -103,7 +104,5 @@ q = require('q'); | ||
utilMock.MEDIUM_RETRY = utilMock.NO_RETRY; | ||
}); | ||
callback(); | ||
}, | ||
tearDown(callback) { | ||
afterEach(() => { | ||
fsMock.readFile = fsReadFile; | ||
@@ -115,13 +114,11 @@ fsMock.stat = fsStat; | ||
}); | ||
callback(); | ||
}, | ||
}); | ||
testFeatures(test) { | ||
test.expect(1); | ||
test.ok(provider.features.FEATURE_MESSAGING); | ||
test.done(); | ||
}, | ||
it('features test', (done) => { | ||
assert.ok(provider.features.FEATURE_MESSAGING); | ||
done(); | ||
}); | ||
testInit: { | ||
setUp(callback) { | ||
describe('init tests', () => { | ||
beforeEach(() => { | ||
iidDoc = '{}'; | ||
@@ -186,7 +183,5 @@ | ||
}; | ||
callback(); | ||
}, | ||
testGetIidDoc(test) { | ||
}); | ||
it('get Iid doc test', (done) => { | ||
iidDoc = { | ||
@@ -199,19 +194,18 @@ privateIp: '1.2.3.4', | ||
test.expect(4); | ||
provider.init(providerOptions) | ||
.then(() => { | ||
test.strictEqual(provider.nodeProperties.mgmtIp, '1.2.3.4'); | ||
test.strictEqual(provider.nodeProperties.privateIp, '1.2.3.4'); | ||
test.strictEqual(provider.nodeProperties.instanceId, 'myInstanceId'); | ||
test.strictEqual(provider.nodeProperties.region, 'myRegion'); | ||
assert.strictEqual(provider.nodeProperties.mgmtIp, '1.2.3.4'); | ||
assert.strictEqual(provider.nodeProperties.privateIp, '1.2.3.4'); | ||
assert.strictEqual(provider.nodeProperties.instanceId, 'myInstanceId'); | ||
assert.strictEqual(provider.nodeProperties.region, 'myRegion'); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testSetRegion(test) { | ||
it('set region test', (done) => { | ||
iidDoc = { | ||
@@ -222,17 +216,16 @@ region: 'myRegion' | ||
test.expect(1); | ||
provider.init(providerOptions) | ||
.then(() => { | ||
test.strictEqual(awsMock.config.configUpdate.region, 'myRegion'); | ||
assert.strictEqual(awsMock.config.configUpdate.region, 'myRegion'); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testCreateBucket: { | ||
setUp(callback) { | ||
describe('create bucket tests', () => { | ||
beforeEach(() => { | ||
awsMock.S3.prototype.listObjectsV2 = function listObjectsV2() { | ||
@@ -246,6 +239,5 @@ return { | ||
providerOptions.region = 'foo'; | ||
callback(); | ||
}, | ||
}); | ||
testCreated(test) { | ||
it('created test', (done) => { | ||
let putParams; | ||
@@ -261,16 +253,15 @@ awsMock.S3.prototype.putObject = function putObject(params) { | ||
test.expect(1); | ||
provider.init(providerOptions) | ||
.then(() => { | ||
test.strictEqual(putParams.Key, 'backup/'); | ||
assert.strictEqual(putParams.Key, 'backup/'); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testListObjectsError(test) { | ||
it('list objects error test', (done) => { | ||
const errorMessage = 'foobar'; | ||
@@ -285,16 +276,15 @@ awsMock.S3.prototype.listObjectsV2 = function listObjectsV2() { | ||
test.expect(1); | ||
provider.init(providerOptions) | ||
.then(() => { | ||
test.ok(false, 'Should have had list objects error'); | ||
assert.ok(false, 'Should have had list objects error'); | ||
}) | ||
.catch((err) => { | ||
test.notStrictEqual(err.message.indexOf(errorMessage), -1); | ||
assert.notStrictEqual(err.message.indexOf(errorMessage), -1); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testPutObjectError(test) { | ||
it('put object error test', (done) => { | ||
const errorMessage = 'foobar'; | ||
@@ -309,18 +299,17 @@ awsMock.S3.prototype.putObject = function putObject() { | ||
test.expect(1); | ||
provider.init(providerOptions) | ||
.then(() => { | ||
test.ok(false, 'Should have had list objects error'); | ||
assert.ok(false, 'Should have had list objects error'); | ||
}) | ||
.catch((err) => { | ||
test.notStrictEqual(err.message.indexOf(errorMessage), -1); | ||
assert.notStrictEqual(err.message.indexOf(errorMessage), -1); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
} | ||
}, | ||
}); | ||
}); | ||
testAutoscale: { | ||
testInstanceMaps(test) { | ||
describe('autoscale tests', () => { | ||
it('instance maps test', (done) => { | ||
const nextToken = 'this is the next token'; | ||
@@ -392,6 +381,5 @@ | ||
test.expect(3); | ||
provider.init(providerOptions, { autoscale: true }) | ||
.then(() => { | ||
test.deepEqual( | ||
assert.deepEqual( | ||
provider.instanceIdToAutoscaleGroupMap, | ||
@@ -406,3 +394,3 @@ { | ||
); | ||
test.deepEqual( | ||
assert.deepEqual( | ||
provider.instanceIdToLaunchConfigMap, | ||
@@ -417,3 +405,3 @@ { | ||
test.deepEqual( | ||
assert.deepEqual( | ||
provider.stackIdToInstanceMap, | ||
@@ -427,13 +415,13 @@ { | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
} | ||
} | ||
}, | ||
}); | ||
}); | ||
}); | ||
testGetDataFromUri: { | ||
setUp(callback) { | ||
describe('get data from uri tests', () => { | ||
beforeEach(() => { | ||
provider.s3 = { | ||
@@ -454,100 +442,93 @@ getObject(params) { | ||
getObjectParams = undefined; | ||
callback(); | ||
}, | ||
}); | ||
testBasic(test) { | ||
test.expect(3); | ||
it('basic test', (done) => { | ||
provider.getDataFromUri('arn:aws:s3:::myBucket/myKey') | ||
.then((data) => { | ||
test.strictEqual(getObjectParams.Bucket, 'myBucket'); | ||
test.strictEqual(getObjectParams.Key, 'myKey'); | ||
test.strictEqual(data, 'bucket data'); | ||
assert.strictEqual(getObjectParams.Bucket, 'myBucket'); | ||
assert.strictEqual(getObjectParams.Key, 'myKey'); | ||
assert.strictEqual(data, 'bucket data'); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err); | ||
assert.ok(false, err); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testCn(test) { | ||
test.expect(3); | ||
it('cn test', (done) => { | ||
provider.getDataFromUri('arn:aws-cn:s3:::myBucket/myKey') | ||
.then((data) => { | ||
test.strictEqual(getObjectParams.Bucket, 'myBucket'); | ||
test.strictEqual(getObjectParams.Key, 'myKey'); | ||
test.strictEqual(data, 'bucket data'); | ||
assert.strictEqual(getObjectParams.Bucket, 'myBucket'); | ||
assert.strictEqual(getObjectParams.Key, 'myKey'); | ||
assert.strictEqual(data, 'bucket data'); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err); | ||
assert.ok(false, err); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testUsGov(test) { | ||
test.expect(3); | ||
it('us gov test', (done) => { | ||
provider.getDataFromUri('arn:aws-us-gov:s3:::myBucket/myKey') | ||
.then((data) => { | ||
test.strictEqual(getObjectParams.Bucket, 'myBucket'); | ||
test.strictEqual(getObjectParams.Key, 'myKey'); | ||
test.strictEqual(data, 'bucket data'); | ||
assert.strictEqual(getObjectParams.Bucket, 'myBucket'); | ||
assert.strictEqual(getObjectParams.Key, 'myKey'); | ||
assert.strictEqual(data, 'bucket data'); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err); | ||
assert.ok(false, err); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testComplexKey(test) { | ||
test.expect(3); | ||
it('complex key test', (done) => { | ||
provider.getDataFromUri('arn:aws:s3:::myBucket/myFolder/myKey') | ||
.then((data) => { | ||
test.strictEqual(getObjectParams.Bucket, 'myBucket'); | ||
test.strictEqual(getObjectParams.Key, 'myFolder/myKey'); | ||
test.strictEqual(data, 'bucket data'); | ||
assert.strictEqual(getObjectParams.Bucket, 'myBucket'); | ||
assert.strictEqual(getObjectParams.Key, 'myFolder/myKey'); | ||
assert.strictEqual(data, 'bucket data'); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err); | ||
assert.ok(false, err); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testInvalidUri(test) { | ||
test.expect(1); | ||
it('invalid uri test', (done) => { | ||
provider.getDataFromUri('https://aws.s3.com/myBucket/myKey') | ||
.then(() => { | ||
test.ok(false, 'Should have thrown invalid URI'); | ||
assert.ok(false, 'Should have thrown invalid URI'); | ||
}) | ||
.catch((err) => { | ||
test.notStrictEqual(err.message.indexOf('Invalid URI'), -1); | ||
assert.notStrictEqual(err.message.indexOf('Invalid URI'), -1); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testInvalidArn(test) { | ||
test.expect(1); | ||
it('invalid arn test', (done) => { | ||
provider.getDataFromUri('arn:aws:s3:::foo/') | ||
.then(() => { | ||
test.ok(false, 'Should have thrown invalid ARN'); | ||
assert.ok(false, 'Should have thrown invalid ARN'); | ||
}) | ||
.catch((err) => { | ||
test.notStrictEqual(err.message.indexOf('Invalid ARN'), -1); | ||
assert.notStrictEqual(err.message.indexOf('Invalid ARN'), -1); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
} | ||
}, | ||
}); | ||
}); | ||
testDeleteStoredUcs: { | ||
setUp(callback) { | ||
describe('delete stored ucs tests', () => { | ||
beforeEach(() => { | ||
provider.s3 = { | ||
@@ -567,23 +548,23 @@ deleteObjects: function() { | ||
}; | ||
callback(); | ||
}, | ||
testExists(test) { | ||
}); | ||
it('exists test', (done) => { | ||
provider.deleteStoredUcs('foo.ucs') | ||
.then((response) => { | ||
test.ok(true); | ||
test.strictEqual(response.status, 'OK'); | ||
test.notStrictEqual(response.message | ||
assert.ok(true); | ||
assert.strictEqual(response.status, 'OK'); | ||
assert.notStrictEqual(response.message | ||
.indexOf('The following items were successfully deleted'), -1); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
} | ||
}, | ||
}); | ||
}); | ||
testGetInstances: { | ||
setUp(callback) { | ||
describe('get instances tests', () => { | ||
beforeEach(() => { | ||
provider.providerOptions = providerOptions; | ||
@@ -747,8 +728,5 @@ provider.initOptions = {}; | ||
deletedInstances = []; | ||
}); | ||
callback(); | ||
}, | ||
testInstanceMap(test) { | ||
test.expect(3); | ||
it('instance map test', (done) => { | ||
provider.getInstances() | ||
@@ -759,15 +737,15 @@ .then((returnedInstances) => { | ||
delete mungedInstances.id2.lastUpdate; | ||
test.strictEqual(Object.keys(mungedInstances).length, 2); | ||
test.deepEqual(mungedInstances.id1, instance1); | ||
test.deepEqual(mungedInstances.id2, instance2); | ||
assert.strictEqual(Object.keys(mungedInstances).length, 2); | ||
assert.deepEqual(mungedInstances.id1, instance1); | ||
assert.deepEqual(mungedInstances.id2, instance2); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testInstanceMapMissingInstanceId(test) { | ||
it('instance map missing instance id test', (done) => { | ||
// If an instance ID is missing from the db, we should get it from | ||
@@ -834,21 +812,21 @@ // describe instances | ||
.then((returnedInstances) => { | ||
test.strictEqual(returnedInstances.id3.isPrimary, false); | ||
test.strictEqual(returnedInstances.id3.mgmtIp, '7.8.9.0'); | ||
test.strictEqual(returnedInstances.id3.privateIp, '7.8.9.0'); | ||
test.strictEqual(returnedInstances.id3.publicIp, '111.222.333.444'); | ||
test.strictEqual(returnedInstances.id3.providerVisible, true); | ||
test.strictEqual(returnedInstances.id3.external, false); | ||
test.strictEqual(returnedInstances.id3.status, AutoscaleInstance.INSTANCE_STATUS_OK); | ||
assert.strictEqual(returnedInstances.id3.isPrimary, false); | ||
assert.strictEqual(returnedInstances.id3.mgmtIp, '7.8.9.0'); | ||
assert.strictEqual(returnedInstances.id3.privateIp, '7.8.9.0'); | ||
assert.strictEqual(returnedInstances.id3.publicIp, '111.222.333.444'); | ||
assert.strictEqual(returnedInstances.id3.providerVisible, true); | ||
assert.strictEqual(returnedInstances.id3.external, false); | ||
assert.strictEqual(returnedInstances.id3.status, AutoscaleInstance.INSTANCE_STATUS_OK); | ||
test.deepEqual(returnedInstances.id2, instance2); | ||
assert.deepEqual(returnedInstances.id2, instance2); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testInstanceMapWithExternalTag(test) { | ||
it('instance map with external tag test', (done) => { | ||
const externalTag = { | ||
@@ -943,7 +921,6 @@ key: 'foo', | ||
test.expect(2); | ||
provider.getInstances({ externalTag, instanceId: 'id1' }) | ||
.then((returnedInstances) => { | ||
test.strictEqual(returnedInstances['111'].external, true); | ||
test.deepEqual( | ||
assert.strictEqual(returnedInstances['111'].external, true); | ||
assert.deepEqual( | ||
passedParams.Filters[0], | ||
@@ -957,28 +934,27 @@ { | ||
.catch((err) => { | ||
test.ok(false, err); | ||
assert.ok(false, err); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testNonPrimariesDeleted(test) { | ||
test.expect(3); | ||
it('non primaries deleted test', (done) => { | ||
provider.getInstances({ instanceId: 'id1' }) | ||
.then(() => { | ||
test.strictEqual(deletedInstances.length, 2); | ||
test.strictEqual(deletedInstances[0], 'instances/goneMissing'); | ||
test.strictEqual(deletedInstances[1], 'public_keys/goneMissing'); | ||
assert.strictEqual(deletedInstances.length, 2); | ||
assert.strictEqual(deletedInstances[0], 'instances/goneMissing'); | ||
assert.strictEqual(deletedInstances[1], 'public_keys/goneMissing'); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
} | ||
}, | ||
}); | ||
}); | ||
testGetNicsByTag: { | ||
testBasic(test) { | ||
describe('get nics by tag tests', () => { | ||
it('basic test', (done) => { | ||
const myTag = { | ||
@@ -1015,38 +991,36 @@ key: 'foo', | ||
test.expect(7); | ||
provider.getNicsByTag(myTag) | ||
.then((response) => { | ||
test.strictEqual(passedParams.Filters[0].Name, `tag:${myTag.key}`); | ||
test.strictEqual(response[0].id, '1'); | ||
test.strictEqual(response[0].ip.private, '1.2.3.4'); | ||
test.strictEqual(response[0].ip.public, undefined); | ||
test.strictEqual(response[1].id, '2'); | ||
test.strictEqual(response[1].ip.private, '2.3.4.5'); | ||
test.strictEqual(response[1].ip.public, '3.4.5.6'); | ||
assert.strictEqual(passedParams.Filters[0].Name, `tag:${myTag.key}`); | ||
assert.strictEqual(response[0].id, '1'); | ||
assert.strictEqual(response[0].ip.private, '1.2.3.4'); | ||
assert.strictEqual(response[0].ip.public, undefined); | ||
assert.strictEqual(response[1].id, '2'); | ||
assert.strictEqual(response[1].ip.private, '2.3.4.5'); | ||
assert.strictEqual(response[1].ip.public, '3.4.5.6'); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testBadTag(test) { | ||
it('bad tag test', (done) => { | ||
const myTag = 'foo'; | ||
test.expect(1); | ||
provider.getNicsByTag(myTag) | ||
.then(() => { | ||
test.ok(false, 'getNicsByTag should have thrown'); | ||
assert.ok(false, 'getNicsByTag should have thrown'); | ||
}) | ||
.catch((err) => { | ||
test.notStrictEqual(err.message.indexOf('key and value'), -1); | ||
assert.notStrictEqual(err.message.indexOf('key and value'), -1); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testError(test) { | ||
it('error test', (done) => { | ||
const myTag = { | ||
@@ -1067,18 +1041,17 @@ key: 'foo', | ||
test.expect(1); | ||
provider.getNicsByTag(myTag) | ||
.then(() => { | ||
test.ok(false, 'getNicsByTag should have thrown'); | ||
assert.ok(false, 'getNicsByTag should have thrown'); | ||
}) | ||
.catch((err) => { | ||
test.strictEqual(err.message, 'uh oh'); | ||
assert.strictEqual(err.message, 'uh oh'); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
} | ||
}, | ||
}); | ||
}); | ||
testGetVmsByTag: { | ||
testBasic(test) { | ||
describe('get vms by tag tests', () => { | ||
it('basic test', (done) => { | ||
const myTag = { | ||
@@ -1131,22 +1104,21 @@ key: 'foo', | ||
test.expect(7); | ||
provider.getVmsByTag(myTag) | ||
.then((response) => { | ||
test.strictEqual(passedParams.Filters[0].Name, `tag:${myTag.key}`); | ||
test.strictEqual(response.length, 2); | ||
test.strictEqual(response[0].id, '1'); | ||
test.strictEqual(response[0].ip.private, '1.2.3.4'); | ||
test.strictEqual(response[1].id, '2'); | ||
test.strictEqual(response[1].ip.private, '2.3.4.5'); | ||
test.strictEqual(response[1].ip.public, '3.4.5.6'); | ||
assert.strictEqual(passedParams.Filters[0].Name, `tag:${myTag.key}`); | ||
assert.strictEqual(response.length, 2); | ||
assert.strictEqual(response[0].id, '1'); | ||
assert.strictEqual(response[0].ip.private, '1.2.3.4'); | ||
assert.strictEqual(response[1].id, '2'); | ||
assert.strictEqual(response[1].ip.private, '2.3.4.5'); | ||
assert.strictEqual(response[1].ip.public, '3.4.5.6'); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testPending(test) { | ||
it('pending test', (done) => { | ||
const myTag = { | ||
@@ -1199,36 +1171,34 @@ key: 'foo', | ||
test.expect(5); | ||
provider.getVmsByTag(myTag, { includePending: true }) | ||
.then((response) => { | ||
test.strictEqual(passedParams.Filters[0].Name, `tag:${myTag.key}`); | ||
test.strictEqual(response.length, 3); | ||
test.strictEqual(response[2].id, '3'); | ||
test.strictEqual(response[2].ip.private, '4.5.6.7'); | ||
test.strictEqual(response[2].ip.public, '5.6.7.8'); | ||
assert.strictEqual(passedParams.Filters[0].Name, `tag:${myTag.key}`); | ||
assert.strictEqual(response.length, 3); | ||
assert.strictEqual(response[2].id, '3'); | ||
assert.strictEqual(response[2].ip.private, '4.5.6.7'); | ||
assert.strictEqual(response[2].ip.public, '5.6.7.8'); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testBadTag(test) { | ||
it('bad tag test', (done) => { | ||
const myTag = 'foo'; | ||
test.expect(1); | ||
provider.getVmsByTag(myTag) | ||
.then(() => { | ||
test.ok(false, 'getVmsByTag should have thrown'); | ||
assert.ok(false, 'getVmsByTag should have thrown'); | ||
}) | ||
.catch((err) => { | ||
test.notStrictEqual(err.message.indexOf('key and value'), -1); | ||
assert.notStrictEqual(err.message.indexOf('key and value'), -1); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testError(test) { | ||
it('error test', (done) => { | ||
const myTag = { | ||
@@ -1249,25 +1219,23 @@ key: 'foo', | ||
test.expect(1); | ||
provider.getVmsByTag(myTag) | ||
.then(() => { | ||
test.ok(false, 'getVmsByTag should have thrown'); | ||
assert.ok(false, 'getVmsByTag should have thrown'); | ||
}) | ||
.catch((err) => { | ||
test.strictEqual(err.message, 'uh oh'); | ||
assert.strictEqual(err.message, 'uh oh'); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
} | ||
}, | ||
}); | ||
}); | ||
testElectPrimary: { | ||
setUp(callback) { | ||
describe('elect Primary tests', () => { | ||
beforeEach(() => { | ||
provider.instanceIdToLaunchConfigMap = {}; | ||
provider.instanceIdToAutoscaleGroupMap = {}; | ||
provider.autoscaleGroupToLaunchConfigMap = {}; | ||
callback(); | ||
}, | ||
}); | ||
testBasic(test) { | ||
it('basic test', (done) => { | ||
const possiblePrimaryInstances = { | ||
@@ -1286,16 +1254,15 @@ id1: { | ||
test.expect(1); | ||
provider.electPrimary(possiblePrimaryInstances) | ||
.then((electedPrimaryId) => { | ||
test.strictEqual(electedPrimaryId, 'id1'); | ||
assert.strictEqual(electedPrimaryId, 'id1'); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testProviderNotVisible(test) { | ||
it('provider not visible test', (done) => { | ||
const possiblePrimaryInstances = { | ||
@@ -1314,16 +1281,15 @@ id1: { | ||
test.expect(1); | ||
provider.electPrimary(possiblePrimaryInstances) | ||
.then((electedPrimaryId) => { | ||
test.strictEqual(electedPrimaryId, 'id2'); | ||
assert.strictEqual(electedPrimaryId, 'id2'); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testLaunchConfigName(test) { | ||
it('launch config name test', (done) => { | ||
const possiblePrimaryInstances = { | ||
@@ -1356,16 +1322,15 @@ id1: { | ||
test.expect(1); | ||
provider.electPrimary(possiblePrimaryInstances) | ||
.then((electedPrimaryId) => { | ||
test.strictEqual(electedPrimaryId, 'id2'); | ||
assert.strictEqual(electedPrimaryId, 'id2'); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testExternal(test) { | ||
it('external test', (done) => { | ||
const possiblePrimaryInstances = { | ||
@@ -1391,16 +1356,15 @@ id1: { | ||
test.expect(1); | ||
provider.electPrimary(possiblePrimaryInstances) | ||
.then((electedPrimaryId) => { | ||
test.strictEqual(electedPrimaryId, 'id3'); | ||
assert.strictEqual(electedPrimaryId, 'id3'); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testVersionOk(test) { | ||
it('version ok test', (done) => { | ||
const possiblePrimaryInstances = { | ||
@@ -1424,18 +1388,17 @@ id1: { | ||
test.expect(1); | ||
provider.electPrimary(possiblePrimaryInstances) | ||
.then((electedPrimaryId) => { | ||
test.strictEqual(electedPrimaryId, 'id1'); | ||
assert.strictEqual(electedPrimaryId, 'id1'); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
} | ||
}, | ||
}); | ||
}); | ||
testIsValidPrimary: { | ||
setUp(callback) { | ||
describe('is valid Primary tests', () => { | ||
beforeEach(() => { | ||
instance1 = { | ||
@@ -1469,23 +1432,20 @@ isPrimary: false, | ||
}; | ||
}); | ||
callback(); | ||
}, | ||
testIsPrimary(test) { | ||
it('is primary test', (done) => { | ||
provider.nodeProperties.instanceId = instanceId; | ||
test.expect(1); | ||
provider.isValidPrimary(instanceId, instances) | ||
.then((isValid) => { | ||
test.ok(isValid); | ||
assert.ok(isValid); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testNoInstanceInfo(test) { | ||
it('no instance info test', (done) => { | ||
provider.s3.getObject = function getObject() { | ||
@@ -1499,18 +1459,17 @@ return { | ||
test.expect(1); | ||
provider.isValidPrimary(instanceId, instances) | ||
.then((isValid) => { | ||
test.ok(isValid); | ||
assert.ok(isValid); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
} | ||
}, | ||
}); | ||
}); | ||
testPrimaryElected: { | ||
setUp(callback) { | ||
describe('Primary elected tests', () => { | ||
beforeEach(() => { | ||
provider.nodeProperties = { instanceId }; | ||
@@ -1547,37 +1506,33 @@ instanceProtectionParams = undefined; | ||
}; | ||
}); | ||
callback(); | ||
}, | ||
testInstanceProtectionSetWhenPrimary(test) { | ||
test.expect(3); | ||
it('instance protection set when primary test', (done) => { | ||
provider.primaryElected(instanceId) | ||
.then(() => { | ||
test.strictEqual(instanceProtectionParams.InstanceIds.length, 1); | ||
test.strictEqual(instanceProtectionParams.InstanceIds[0], instanceId); | ||
test.ok(instanceProtectionParams.ProtectedFromScaleIn); | ||
assert.strictEqual(instanceProtectionParams.InstanceIds.length, 1); | ||
assert.strictEqual(instanceProtectionParams.InstanceIds[0], instanceId); | ||
assert.ok(instanceProtectionParams.ProtectedFromScaleIn); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testInstanceProtectionNotSetWhenNotPrimary(test) { | ||
test.expect(1); | ||
it('instance protection not set when not primary test', (done) => { | ||
provider.primaryElected('foo') | ||
.then(() => { | ||
test.strictEqual(instanceProtectionParams, undefined); | ||
assert.strictEqual(instanceProtectionParams, undefined); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testOtherPrimariesSetToNonPrimary(test) { | ||
it('other primaries set to non primary test', (done) => { | ||
let instancePut; | ||
@@ -1623,18 +1578,18 @@ let instancePutId; | ||
test.expect(2); | ||
provider.primaryElected(instanceId) | ||
.then(() => { | ||
test.strictEqual(instancePutId, '5678'); | ||
test.strictEqual(instancePut.isPrimary, false); | ||
assert.strictEqual(instancePutId, '5678'); | ||
assert.strictEqual(instancePut.isPrimary, false); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
} | ||
}, | ||
testTagPrimary: { | ||
setUp(callback) { | ||
}); | ||
}); | ||
describe('tag Primary tests', () => { | ||
beforeEach(() => { | ||
provider.ec2 = { | ||
@@ -1667,7 +1622,5 @@ describeTags(params) { | ||
deleteTagRequests = []; | ||
}); | ||
callback(); | ||
}, | ||
testTagPrimaryWithStackName(test) { | ||
it('tag primary with stack name test', (done) => { | ||
describeTagsResults = { | ||
@@ -1719,7 +1672,6 @@ Tags: | ||
test.expect(4); | ||
provider.tagPrimaryInstance(primaryId, clusterInstances) | ||
.then(() => { | ||
test.strictEqual(passedDescribeTagsParams.Filters[0].Values[0], primaryId); | ||
test.deepEqual(passedCreateTagsParams, | ||
assert.strictEqual(passedDescribeTagsParams.Filters[0].Values[0], primaryId); | ||
assert.deepEqual(passedCreateTagsParams, | ||
{ | ||
@@ -1734,14 +1686,14 @@ Resources: ['1234'], | ||
}); | ||
test.deepEqual(deleteTagRequests, expectedDeleteTagsRequest); | ||
test.strictEqual(deleteTagRequests.length, 2); | ||
assert.deepEqual(deleteTagRequests, expectedDeleteTagsRequest); | ||
assert.strictEqual(deleteTagRequests.length, 2); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testTagPrimarySingleInstance(test) { | ||
it('tag primary single instance test', (done) => { | ||
describeTagsResults = { | ||
@@ -1766,18 +1718,17 @@ Tags: | ||
test.expect(1); | ||
provider.tagPrimaryInstance(primaryId, clusterInstances) | ||
.then(() => { | ||
test.strictEqual(deleteTagRequests.length, 0); | ||
assert.strictEqual(deleteTagRequests.length, 0); | ||
}) | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.finally(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
} | ||
}, | ||
}); | ||
}); | ||
testSignalInstanceProvisioned: { | ||
setUp(callback) { | ||
describe('signal Instance Provisioned tests', () => { | ||
beforeEach(() => { | ||
provider.ec2 = { | ||
@@ -1820,11 +1771,8 @@ describeTags() { | ||
}; | ||
}); | ||
callback(); | ||
}, | ||
testSignalResourceCallSuccess(test) { | ||
test.expect(1); | ||
it('Signal Resource Call Success test', (done) => { | ||
provider.signalInstanceProvisioned('i-1234') | ||
.then(() => { | ||
test.deepEqual(passedSignalResourceParams, { | ||
assert.deepEqual(passedSignalResourceParams, { | ||
LogicalResourceId: 'BigIpAutoScaleGroup', | ||
@@ -1837,10 +1785,10 @@ StackName: 'StackName', | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.done(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testSignalResourceNoInstance(test) { | ||
it('Signal Resource no instance test', (done) => { | ||
provider.nodeProperties = { | ||
@@ -1851,6 +1799,5 @@ instanceId: 'i-1234', | ||
test.expect(1); | ||
provider.signalInstanceProvisioned() | ||
.then(() => { | ||
test.deepEqual(passedSignalResourceParams, { | ||
assert.deepEqual(passedSignalResourceParams, { | ||
LogicalResourceId: 'BigIpAutoScaleGroup', | ||
@@ -1863,11 +1810,11 @@ StackName: 'StackName', | ||
.catch((err) => { | ||
test.ok(false, err.message); | ||
assert.ok(false, err.message); | ||
}) | ||
.done(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testErrors: { | ||
testSignalNoInstanceStackTag(test) { | ||
describe('errors tests', () => { | ||
it('Signal No Instance Stack Tag test', (done) => { | ||
provider.ec2 = { | ||
@@ -1891,16 +1838,15 @@ describeTags() { | ||
test.expect(1); | ||
provider.signalInstanceProvisioned('i-1234') | ||
.then(() => { | ||
test.ok(false, 'signalInstanceProvisioned should have thrown'); | ||
assert.ok(false, 'signalInstanceProvisioned should have thrown'); | ||
}) | ||
.catch((err) => { | ||
test.strictEqual(err.message, 'Cannot find stack-name for instance: i-1234'); | ||
assert.strictEqual(err.message, 'Cannot find stack-name for instance: i-1234'); | ||
}) | ||
.done(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
}, | ||
}); | ||
testSignalNoInstanceTags(test) { | ||
it('Signal No Instance Tags test', (done) => { | ||
provider.ec2 = { | ||
@@ -1918,16 +1864,15 @@ describeTags() { | ||
test.expect(1); | ||
provider.signalInstanceProvisioned('i-1234') | ||
.then(() => { | ||
test.ok(false, 'signalInstanceProvisioned should have thrown'); | ||
assert.ok(false, 'signalInstanceProvisioned should have thrown'); | ||
}) | ||
.catch((err) => { | ||
test.strictEqual(err.message, expectedError); | ||
assert.strictEqual(err.message, expectedError); | ||
}) | ||
.done(() => { | ||
test.done(); | ||
done(); | ||
}); | ||
} | ||
} | ||
} | ||
}; | ||
}); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4420
199481
5
16
8
1