forked from aquasecurity/cloudsploit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbMultiAz.spec.js
More file actions
101 lines (99 loc) · 3.51 KB
/
Copy pathdbMultiAz.spec.js
File metadata and controls
101 lines (99 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
var expect = require('chai').expect;
var plugin = require('./dbMultiAz');
const createCache = (err, data) => {
return {
instances: {
sql: {
list: {
'global': {
err: err,
data: data
}
}
}
},
projects: {
get: {
'global': {
data: [{ name: 'test-project' }]
}
}
}
}
};
describe('dbMultiAz', function () {
describe('run', function () {
it('should give unknown result if a sql instance error is passed or no data is present', function (done) {
const callback = (err, results) => {
expect(results.length).to.be.above(0);
expect(results[0].status).to.equal(3);
expect(results[0].message).to.include('Unable to query SQL instances');
expect(results[0].region).to.equal('global');
done()
};
const cache = createCache(
['error'],
null,
);
plugin.run(cache, {}, callback);
});
it('should give passing result if no sql instances found', function (done) {
const callback = (err, results) => {
expect(results.length).to.be.above(0);
expect(results[0].status).to.equal(0);
expect(results[0].message).to.include('No SQL instances found');
expect(results[0].region).to.equal('global');
done()
};
const cache = createCache(
null,
[],
);
plugin.run(cache, {}, callback);
});
it('should give passing result if sql instance has multi-AZ enabled', function (done) {
const callback = (err, results) => {
expect(results.length).to.be.above(0);
expect(results[0].status).to.equal(0);
expect(results[0].message).to.include('SQL instance has multi-AZ enabled');
expect(results[0].region).to.equal('global');
done()
};
const cache = createCache(
null,
[
{
name: 'testing-instance1',
instanceType: 'CLOUD_SQL_INSTANCE',
failoverReplica:{
available: true,
}
}
],
);
plugin.run(cache, {}, callback);
});
it('should give failing result if sql instance does not have multi-AZ enabled', function (done) {
const callback = (err, results) => {
expect(results.length).to.be.above(0);
expect(results[0].status).to.equal(2);
expect(results[0].message).to.include('SQL instance does not have multi-AZ enabled');
expect(results[0].region).to.equal('global');
done()
};
const cache = createCache(
null,
[
{
name: 'testing-instance1',
instanceType: 'CLOUD_SQL_INSTANCE',
failoverReplica:{
available: false,
}
}
],
);
plugin.run(cache, {}, callback);
});
})
});