@@ -134,21 +134,48 @@ func TestExtractMetadataFromJsonBytes(t *testing.T) {
134
134
kind string
135
135
apiVersion string
136
136
podSelectorMatchLabels map [string ]string
137
+ podSpecLabels map [string ]string
137
138
}{
139
+ {
140
+ name : "testcronjob" ,
141
+ annotations : map [string ]string {},
142
+ labels : map [string ]string {
143
+ "app" : "backup-system" ,
144
+ "team" : "platform" ,
145
+ "cost-center" : "platform-123" ,
146
+ },
147
+ ownerReferences : map [string ]string {},
148
+ creationTs : "" ,
149
+ resourceVersion : "" ,
150
+ kind : "CronJob" ,
151
+ apiVersion : "batch/v1" ,
152
+ podSelectorMatchLabels : map [string ]string {},
153
+ podSpecLabels : map [string ]string {
154
+ "app" : "backup-job" ,
155
+ "type" : "scheduled-backup" ,
156
+ "environment" : "prod" ,
157
+ "component" : "database" ,
158
+ "version" : "v1.2" ,
159
+ },
160
+ },
138
161
{
139
162
name : "testdeployment" ,
140
163
annotations : map [string ]string {
141
164
"deployment.kubernetes.io/revision" : "1" ,
142
165
},
143
166
labels : map [string ]string {
144
- "app " : "emailservice " ,
167
+ "label-key-1 " : "label-value-1 " ,
145
168
},
146
169
ownerReferences : map [string ]string {},
147
170
creationTs : "2024-07-18T19:58:44Z" ,
148
171
resourceVersion : "6486" ,
149
172
kind : "Deployment" ,
150
173
apiVersion : "apps/v1" ,
151
174
podSelectorMatchLabels : map [string ]string {},
175
+ podSpecLabels : map [string ]string {
176
+ "app" : "emailservice" ,
177
+ "pod_label_key" : "pod_label_value" ,
178
+ },
152
179
},
153
180
{
154
181
name : "networkpolicy_withoutmatching_labels" ,
@@ -160,6 +187,7 @@ func TestExtractMetadataFromJsonBytes(t *testing.T) {
160
187
kind : "NetworkPolicy" ,
161
188
apiVersion : "networking.k8s.io/v1" ,
162
189
podSelectorMatchLabels : map [string ]string {},
190
+ podSpecLabels : map [string ]string {},
163
191
},
164
192
{
165
193
name : "networkpolicy_withmatching_labels" ,
@@ -174,6 +202,7 @@ func TestExtractMetadataFromJsonBytes(t *testing.T) {
174
202
"role" : "frontend" ,
175
203
"tier" : "tier1" ,
176
204
},
205
+ podSpecLabels : map [string ]string {},
177
206
},
178
207
{
179
208
name : "applicationactivity" ,
@@ -194,6 +223,7 @@ func TestExtractMetadataFromJsonBytes(t *testing.T) {
194
223
kind : "ApplicationActivity" ,
195
224
apiVersion : "spdx.softwarecomposition.kubescape.io/v1beta1" ,
196
225
podSelectorMatchLabels : map [string ]string {},
226
+ podSpecLabels : map [string ]string {},
197
227
},
198
228
{
199
229
name : "pod" ,
@@ -225,6 +255,7 @@ func TestExtractMetadataFromJsonBytes(t *testing.T) {
225
255
kind : "Pod" ,
226
256
apiVersion : "v1" ,
227
257
podSelectorMatchLabels : map [string ]string {},
258
+ podSpecLabels : map [string ]string {},
228
259
},
229
260
{
230
261
name : "sbom" ,
@@ -242,6 +273,7 @@ func TestExtractMetadataFromJsonBytes(t *testing.T) {
242
273
kind : "SBOMSPDXv2p3" ,
243
274
apiVersion : "spdx.softwarecomposition.kubescape.io/v1beta1" ,
244
275
podSelectorMatchLabels : map [string ]string {},
276
+ podSpecLabels : map [string ]string {},
245
277
},
246
278
{
247
279
name : "caliconetworkpolicy" ,
@@ -251,6 +283,7 @@ func TestExtractMetadataFromJsonBytes(t *testing.T) {
251
283
kind : "NetworkPolicy" ,
252
284
apiVersion : "projectcalico.org/v3" ,
253
285
podSelectorMatchLabels : map [string ]string {"role" : "database" },
286
+ podSpecLabels : map [string ]string {},
254
287
},
255
288
{
256
289
name : "ciliumnetworkpolicy" ,
@@ -260,6 +293,7 @@ func TestExtractMetadataFromJsonBytes(t *testing.T) {
260
293
kind : "CiliumNetworkPolicy" ,
261
294
apiVersion : "cilium.io/v2" ,
262
295
podSelectorMatchLabels : map [string ]string {"any:app" : "frontend" , "app" : "frontend" },
296
+ podSpecLabels : map [string ]string {},
263
297
},
264
298
{
265
299
name : "istionetworkpolicy" ,
@@ -269,6 +303,7 @@ func TestExtractMetadataFromJsonBytes(t *testing.T) {
269
303
kind : "AuthorizationPolicy" ,
270
304
apiVersion : "security.istio.io/v1" ,
271
305
podSelectorMatchLabels : map [string ]string {"app" : "myapi" },
306
+ podSpecLabels : map [string ]string {},
272
307
},
273
308
}
274
309
for _ , tt := range tests {
@@ -285,6 +320,7 @@ func TestExtractMetadataFromJsonBytes(t *testing.T) {
285
320
assert .Equal (t , tt .kind , m .Kind )
286
321
assert .Equal (t , tt .apiVersion , m .ApiVersion )
287
322
assert .Equal (t , tt .podSelectorMatchLabels , m .PodSelectorMatchLabels )
323
+ assert .Equal (t , tt .podSpecLabels , m .PodSpecLabels )
288
324
})
289
325
}
290
326
}
0 commit comments