Skip to content

Commit a1ba9df

Browse files
committed
test: ensure securityContext and resources are part of workload
Add test coverage; this is in preparation for an upcoming change where we are going to read these values from a different place.
1 parent 473cfcc commit a1ba9df

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

test/fixtures/java-deployment.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,12 @@ spec:
2121
name: java
2222
command: ['/bin/sleep']
2323
args: ['9999999']
24-
securityContext: {}
24+
securityContext:
25+
privileged: false
26+
capabilities:
27+
drop:
28+
- ALL
29+
resources:
30+
limits:
31+
cpu: '1'
32+
memory: '1Gi'

test/system/kind.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ tap.test('Kubernetes-Monitor with KinD', async (t) => {
105105
'all properties are present in the workload metadata',
106106
);
107107
t.ok('agentId' in requestBody, 'agent ID is present in workload payload');
108+
109+
const podSpec = requestBody.workloadMetadata.podSpec;
110+
const resources = podSpec.containers[0].resources;
111+
t.same(resources?.limits, { cpu: '1', memory: '1Gi' });
112+
113+
const securityContext = podSpec.containers[0].securityContext;
114+
t.same(securityContext?.privileged, false);
115+
t.same(securityContext?.capabilities?.drop, ['ALL']);
108116
});
109117

110118
nock('https://kubernetes-upstream.snyk.io')

test/unit/supervisor/watchers.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ tap.test('isKubernetesInternalNamespace', async (t) => {
3232
'kube-public is a k8s internal namespace');
3333
t.ok(watchers.isKubernetesInternalNamespace('kube-system'),
3434
'kube-system is a k8s internal namespace');
35+
t.ok(watchers.isKubernetesInternalNamespace('local-path-storage'),
36+
'local-path-storage is a k8s internal namespace');
3537
t.ok(watchers.isKubernetesInternalNamespace('openshift-apiserver'),
3638
'openshift-apiserver is a k8s internal namespace');
3739
t.ok(watchers.isKubernetesInternalNamespace('openshift-apiserver-operator'),

0 commit comments

Comments
 (0)