88 validateUpstreamStoredData ,
99 validateUpstreamStoredMetadata ,
1010 getUpstreamResponseBody ,
11+ validateUpstreamStoredDepGraphs ,
1112} from '../helpers/kubernetes-upstream' ;
1213import {
1314 validateSecureConfiguration ,
@@ -22,6 +23,10 @@ tap.tearDown(async() => {
2223 console . log ( 'Begin removing the snyk-monitor...' ) ;
2324 await setup . removeMonitor ( ) ;
2425 console . log ( 'Removed the snyk-monitor!' ) ;
26+
27+ console . log ( 'Begin removing "kind" network...' ) ;
28+ await setup . removeUnusedKindNetwork ( ) ;
29+ console . log ( 'Removed "kind" network' ) ;
2530} ) ;
2631
2732// Make sure this runs first -- deploying the monitor for the next tests
@@ -129,7 +134,7 @@ tap.test('snyk-monitor sends data to kubernetes-upstream', async (t) => {
129134} ) ;
130135
131136tap . test ( 'snyk-monitor sends binary hashes to kubernetes-upstream after adding another deployment' , async ( t ) => {
132- t . plan ( 9 ) ;
137+ t . plan ( 10 ) ;
133138
134139 const deploymentName = 'binaries-deployment' ;
135140 const namespace = 'services' ;
@@ -139,16 +144,32 @@ tap.test('snyk-monitor sends binary hashes to kubernetes-upstream after adding a
139144 await kubectl . applyK8sYaml ( './test/fixtures/binaries-deployment.yaml' ) ;
140145 console . log ( `Begin polling kubernetes-upstream for the expected workloads with integration ID ${ integrationId } ...` ) ;
141146
142- const validatorFn : WorkloadLocatorValidator = ( workloads ) => {
147+ const workloadLocatorValidatorFn : WorkloadLocatorValidator = ( workloads ) => {
143148 return workloads !== undefined &&
144149 workloads . find ( ( workload ) => workload . name === deploymentName &&
145150 workload . type === WorkloadKind . Deployment ) !== undefined ;
146151 } ;
147152
153+ const depGraphsValidatorFn = ( depGraphs ?: {
154+ node ?: object ;
155+ openjdk ?: object ;
156+ } ) => {
157+ return (
158+ depGraphs !== undefined &&
159+ depGraphs . node !== undefined &&
160+ depGraphs . openjdk !== undefined
161+ ) ;
162+ } ;
163+
148164 const testResult = await validateUpstreamStoredData (
149- validatorFn , `api/v2/workloads/${ integrationId } /${ clusterName } /${ namespace } ` ) ;
165+ workloadLocatorValidatorFn , `api/v2/workloads/${ integrationId } /${ clusterName } /${ namespace } ` ) ;
150166 t . ok ( testResult , 'snyk-monitor sent expected data to kubernetes-upstream in the expected timeframe' ) ;
151167
168+ const depGraphsResult = await validateUpstreamStoredDepGraphs (
169+ depGraphsValidatorFn , `api/v1/dependency-graphs/${ integrationId } /${ clusterName } /${ namespace } /${ deploymentType } /${ deploymentName } `
170+ ) ;
171+ t . ok ( depGraphsResult , 'snyk-monitor sent expected dependency graphs to kubernetes-upstream in the expected timeframe' ) ;
172+
152173 const depGraphResult = await getUpstreamResponseBody (
153174 `api/v1/dependency-graphs/${ integrationId } /${ clusterName } /${ namespace } /${ deploymentType } /${ deploymentName } ` ) ;
154175 t . ok ( 'dependencyGraphResults' in depGraphResult ,
@@ -249,9 +270,6 @@ tap.test('snyk-monitor pulls images from a local registry and sends data to kube
249270 console . log ( 'Begin removing local container registry...' ) ;
250271 await setup . removeLocalContainerRegistry ( ) ;
251272 console . log ( 'Removed local container registry' ) ;
252- console . log ( 'Begin removing "kind" network...' ) ;
253- await setup . removeUnusedKindNetwork ( ) ;
254- console . log ( 'Removed "kind" network' ) ;
255273 } ) ;
256274
257275 if ( process . env [ 'TEST_PLATFORM' ] !== 'kind' ) {
0 commit comments