forked from aquasecurity/cloudsploit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegrityMonitoringEnabled.spec.js
157 lines (144 loc) · 5.77 KB
/
integrityMonitoringEnabled.spec.js
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
var assert = require('assert');
var expect = require('chai').expect;
var plugin = require('./integrityMonitoringEnabled');
const createCache = (err, data) => {
return {
kubernetes: {
list: {
'global': {
err: err,
data: data
}
}
},
projects: {
get: {
'global': {
data: [ { name: 'testproj' }]
}
}
}
}
};
describe('integrityMonitoringEnabled', function () {
describe('run', function () {
it('should give unknown result if a clusters 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 Kubernetes clusters');
expect(results[0].region).to.equal('global');
done()
};
const cache = createCache(
['error'],
null,
);
plugin.run(cache, {}, callback);
});
it('should give passing result if no clusters are 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 Kubernetes clusters found');
expect(results[0].region).to.equal('global');
done()
};
const cache = createCache(
null,
[],
);
plugin.run(cache, {}, callback);
});
it('should give passing result if integrity monitoring is 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('Integrity Monitoring is enabled for all node pools');
expect(results[0].region).to.equal('global');
done()
};
const cache = createCache(
null,
[
{
"name": "standard-cluster-2",
"nodePools": [
{
"name": "default-pool",
"config": {
"machineType": "n1-standard-1",
"diskSizeGb": 100,
"shieldedInstanceConfig": {
"enableIntegrityMonitoring": true
}
},
"initialNodeCount": 3,
"locations": [
"us-central1-a"
],
"status": "RUNNING"
}
],
"locations": [
"us-central1-a"
],
"zone": "us-central1-a",
"status": "RUNNING",
"servicesIpv4Cidr": "10.70.0.0/20",
"instanceGroupUrls": [
"https://www.googleapis.com/compute/v1/projects/frost-forest-281330/zones/us-central1-a/instanceGroupManagers/gke-standard-cluster-2-default-pool-941e601d-grp"
],
"currentNodeCount": 3,
"location": "us-central1-a"
}
]
);
plugin.run(cache, {}, callback);
});
it('should give failing result if integrity monitoring is disabled', 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('Integrity Monitoring is disabled for these node pools');
expect(results[0].region).to.equal('global');
done()
};
const cache = createCache(
null,
[
{
"name": "standard-cluster-1",
"nodePools": [
{
"name": "default-pool",
"config": {
"machineType": "n1-standard-1",
"diskSizeGb": 100,
"shieldedInstanceConfig": {}
},
"initialNodeCount": 3,
"locations": [
"us-east1-b",
"us-east1-c",
"us-east1-d"
],
"status": "RUNNING"
}
],
"locations": [
"us-east1-b",
"us-east1-c",
"us-east1-d"
],
"zone": "us-east1",
"status": "RUNNING",
"currentNodeCount": 5,
"location": "us-east1"
}
]
);
plugin.run(cache, {}, callback);
})
})
})