From 4a1331efdab0cd50ae6637e741b48cf0ed742e8e Mon Sep 17 00:00:00 2001 From: kubasobon Date: Mon, 15 Apr 2024 16:04:01 +0200 Subject: [PATCH] check if CNVM resources have host section --- tests/integration/tests/test_sanity_checks.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/integration/tests/test_sanity_checks.py b/tests/integration/tests/test_sanity_checks.py index b8fb99e09a..76f61741cf 100644 --- a/tests/integration/tests/test_sanity_checks.py +++ b/tests/integration/tests/test_sanity_checks.py @@ -202,6 +202,11 @@ def test_cnvm_findings(cnvm_client, match_type): query, sort = cnvm_client.build_es_must_match_query(must_query_list=query_list, time_range="now-24h") results = get_findings(cnvm_client, CNVM_CONFIG_TIMEOUT, query, sort, match_type) assert len(results) > 0, f"The resource type '{match_type}' is missing" + # Check every finding has host section + for finding in results["hits"]["hits"]: + resource = finding["_source"] + assert "host" in resource, f"Resource '{match_type}' is missing 'host' section" + assert "name" in resource["host"], f"Resource '{match_type}' is missing 'host.name'" @pytest.mark.sanity