From 1340f0e39bb37a1764e1bef274996f4ee2f1fe50 Mon Sep 17 00:00:00 2001 From: Mikita Iwanowski Date: Thu, 20 Jun 2024 11:30:47 +0200 Subject: [PATCH] fix: exclude services from assets score check in the integration test --- tests/integration/audit_config_base_suite.go | 10 +++++++++- tests/integration/audit_config_namespace_test.go | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/integration/audit_config_base_suite.go b/tests/integration/audit_config_base_suite.go index 70e8dd9b..f3e10841 100644 --- a/tests/integration/audit_config_base_suite.go +++ b/tests/integration/audit_config_base_suite.go @@ -223,7 +223,15 @@ func (s *AuditConfigBaseSuite) testMondooAuditConfigKubernetesResources(auditCon assetsExceptCluster := utils.ExcludeClusterAsset(assets) // TODO: this number should exclude services and the cluster asset - s.Equalf(len(assets)-4, len(assetsExceptCluster), "Cluster asset was sent upstream.") + srvs := &corev1.ServiceList{} + err = s.testCluster.K8sHelper.ExecuteWithRetries(func() (bool, error) { + if err := s.testCluster.K8sHelper.Clientset.List(s.ctx, srvs); err != nil { + return false, nil + } + return true, nil + }) + s.NoError(err, "Failed to list Kubernetes Services") + s.Equalf(len(assets)-1-len(srvs.Items), len(assetsExceptCluster), "Cluster asset was sent upstream.") assetNames := utils.AssetNames(assetsExceptCluster) s.ElementsMatchf(workloadNames, assetNames, "Workloads were not sent upstream.") diff --git a/tests/integration/audit_config_namespace_test.go b/tests/integration/audit_config_namespace_test.go index 6c3f7af8..9bb0eff0 100644 --- a/tests/integration/audit_config_namespace_test.go +++ b/tests/integration/audit_config_namespace_test.go @@ -80,7 +80,7 @@ func (s *AuditConfigCustomNamespaceSuite) TearDownSuite() { s.AuditConfigBaseSuite.TearDownSuite() } -func (s *AuditConfigCustomNamespaceSuite) TestReconcile_KubernetesResources2() { +func (s *AuditConfigCustomNamespaceSuite) TestReconcile_KubernetesResources() { auditConfig := utils.DefaultAuditConfigMinimal(s.ns.Name, true, false, false, false) auditConfig.Spec.Scanner.ServiceAccountName = s.sa.Name s.testMondooAuditConfigKubernetesResources(auditConfig)