diff --git a/ccx_messaging/publishers/rule_processing_publisher.py b/ccx_messaging/publishers/rule_processing_publisher.py index 9fd81119..5a2fcc36 100644 --- a/ccx_messaging/publishers/rule_processing_publisher.py +++ b/ccx_messaging/publishers/rule_processing_publisher.py @@ -41,7 +41,6 @@ class RuleProcessingPublisher(KafkaPublisher): def __init__(self, outgoing_topic, kafka_broker_config=None, **kwargs): """Construct a new `RuleProcessingPublisher` given `kwargs` from the config YAML.""" super().__init__(outgoing_topic, kafka_broker_config, **kwargs) - self.outdata_schema_version = 2 def validate_timestamp_rfc3339(self, timestamp): """Check if the timestamp matches RFC3339 format.""" @@ -107,13 +106,14 @@ def publish(self, input_msg, report): try: msg_timestamp = input_msg["timestamp"] + msg_version = report.pop("version", 1) output_msg = { "OrgID": org_id, "AccountNumber": account_number, "ClusterName": input_msg["cluster_name"], "Report": report, "LastChecked": msg_timestamp, - "Version": self.outdata_schema_version, + "Version": msg_version, "RequestId": input_msg.get("request_id"), "Metadata": {"gathering_time": self.get_gathering_time(input_msg)}, } diff --git a/test/publishers/rule_processing_publisher_test.py b/test/publishers/rule_processing_publisher_test.py index 69b0a23d..fbd791e1 100644 --- a/test/publishers/rule_processing_publisher_test.py +++ b/test/publishers/rule_processing_publisher_test.py @@ -147,7 +147,7 @@ def test_publish_bad_argument(wrong_input_msg): "ClusterName": "uuid", "Report": {"reports": []}, "LastChecked": "a timestamp", - "Version": 2, + "Version": 1, "RequestId": "a request id", "Metadata": {"gathering_time": "2012-01-14T00:00:00Z"}, }, @@ -174,7 +174,7 @@ def test_publish_bad_argument(wrong_input_msg): "ClusterName": "uuid", "Report": {"reports": []}, "LastChecked": "a timestamp", - "Version": 2, + "Version": 1, "RequestId": "a request id", "Metadata": {"gathering_time": "2012-01-14T00:00:00Z"}, }, @@ -201,7 +201,7 @@ def test_publish_bad_argument(wrong_input_msg): "ClusterName": "uuid", "Report": {"reports": []}, "LastChecked": "a timestamp", - "Version": 2, + "Version": 1, "RequestId": "a request id", "Metadata": {"gathering_time": "2012-01-14T00:00:00Z"}, }, @@ -227,7 +227,7 @@ def test_publish_bad_argument(wrong_input_msg): "ClusterName": "uuid", "Report": {"reports": []}, "LastChecked": "a timestamp", - "Version": 2, + "Version": 1, "RequestId": "a request id", "Metadata": {"gathering_time": "2012-01-14T00:00:00Z"}, }, @@ -254,7 +254,7 @@ def test_publish_bad_argument(wrong_input_msg): "ClusterName": "uuid", "Report": {"reports": []}, "LastChecked": "a timestamp", - "Version": 2, + "Version": 1, "RequestId": "a request id", "Metadata": {"gathering_time": "2023-08-14T09:31:46Z"}, }, @@ -281,7 +281,7 @@ def test_publish_bad_argument(wrong_input_msg): "ClusterName": "uuid", "Report": {"reports": []}, "LastChecked": "a timestamp", - "Version": 2, + "Version": 1, "RequestId": "a request id", "Metadata": {"gathering_time": "2023-08-14T09:31:46Z"}, }, @@ -308,7 +308,7 @@ def test_publish_bad_argument(wrong_input_msg): "ClusterName": "uuid", "Report": {"reports": []}, "LastChecked": "a timestamp", - "Version": 2, + "Version": 1, "RequestId": "a request id", "Metadata": {"gathering_time": "2012-01-14T00:00:00Z"}, }, @@ -335,7 +335,7 @@ def test_publish_bad_argument(wrong_input_msg): "ClusterName": "uuid", "Report": {"reports": []}, "LastChecked": "a timestamp", - "Version": 2, + "Version": 1, "RequestId": "a request id", "Metadata": {"gathering_time": "2012-01-14T00:00:00Z"}, }, @@ -402,7 +402,23 @@ def test_error(input, output): "OrgID": 10, "AccountNumber": 1, "ClusterName": "uuid", - "Report": {"version": 1, "reports": [], "pass": [], "info": []}, + "Report": {"reports": [], "pass": [], "info": []}, + "LastChecked": "a timestamp", + "Version": 1, + "RequestId": "a request id", + "Metadata": {"gathering_time": "2012-01-14T00:00:00Z"}, + }, + id="valid_report", + ), + pytest.param( + json.dumps( + {"version": 2, "reports": [], "pass": [], "info": [], "workload_recommendations": []} + ), + { + "OrgID": 10, + "AccountNumber": 1, + "ClusterName": "uuid", + "Report": {"reports": [], "pass": [], "info": []}, "LastChecked": "a timestamp", "Version": 2, "RequestId": "a request id",