@@ -50,6 +50,8 @@ test('deploy sample workloads', async () => {
5050 kubectl . applyK8sYaml ( './test/fixtures/centos-deployment.yaml' ) ,
5151 kubectl . applyK8sYaml ( './test/fixtures/scratch-deployment.yaml' ) ,
5252 kubectl . applyK8sYaml ( './test/fixtures/consul-deployment.yaml' ) ,
53+ kubectl . applyK8sYaml ( './test/fixtures/cronjob.yaml' ) ,
54+ kubectl . applyK8sYaml ( './test/fixtures/cronjob-v1beta1.yaml' ) ,
5355 kubectl . createPodFromImage (
5456 'alpine-from-sha' ,
5557 someImageWithSha ,
@@ -112,7 +114,6 @@ test('snyk-monitor sends data to kubernetes-upstream', async () => {
112114 const validatorFn : WorkloadLocatorValidator = ( workloads ) => {
113115 return (
114116 workloads !== undefined &&
115- workloads . length === 8 &&
116117 workloads . find (
117118 ( workload ) =>
118119 workload . name === 'alpine' && workload . type === WorkloadKind . Pod ,
@@ -150,6 +151,16 @@ test('snyk-monitor sends data to kubernetes-upstream', async () => {
150151 ( workload ) =>
151152 workload . name === 'consul' &&
152153 workload . type === WorkloadKind . Deployment ,
154+ ) !== undefined &&
155+ workloads . find (
156+ ( workload ) =>
157+ workload . name === 'cron-job' &&
158+ workload . type === WorkloadKind . CronJob ,
159+ ) !== undefined &&
160+ workloads . find (
161+ ( workload ) =>
162+ workload . name === 'cron-job-v1beta1' &&
163+ workload . type === WorkloadKind . CronJob ,
153164 ) !== undefined
154165 ) ;
155166 } ;
@@ -226,6 +237,33 @@ test('snyk-monitor sends data to kubernetes-upstream', async () => {
226237 target : { image : 'docker-image|docker.io/snyk/runtime-fixtures' } ,
227238 } ,
228239 ] ) ;
240+
241+ const scanResultsCronJob = await getUpstreamResponseBody (
242+ `api/v1/scan-results/${ integrationId } /Default%20cluster/services/CronJob/cron-job` ,
243+ ) ;
244+ expect ( scanResultsCronJob . workloadScanResults [ 'busybox' ] ) . toEqual <
245+ ScanResult [ ]
246+ > ( [
247+ {
248+ identity : { type : 'linux' , args : { platform : 'linux/amd64' } } ,
249+ facts : expect . any ( Array ) ,
250+ target : { image : 'docker-image|busybox' } ,
251+ } ,
252+ ] ) ;
253+
254+ // the v1 reader works for both v1 and v1beta1
255+ const scanResultsCronJobBeta = await getUpstreamResponseBody (
256+ `api/v1/scan-results/${ integrationId } /Default%20cluster/services/CronJob/cron-job-v1beta1` ,
257+ ) ;
258+ expect ( scanResultsCronJobBeta . workloadScanResults [ 'busybox' ] ) . toEqual <
259+ ScanResult [ ]
260+ > ( [
261+ {
262+ identity : { type : 'linux' , args : { platform : 'linux/amd64' } } ,
263+ facts : expect . any ( Array ) ,
264+ target : { image : 'docker-image|busybox' } ,
265+ } ,
266+ ] ) ;
229267} ) ;
230268
231269test ( 'snyk-monitor sends binary hashes to kubernetes-upstream after adding another deployment' , async ( ) => {
0 commit comments