diff --git a/Sekoia.io/CHANGELOG.md b/Sekoia.io/CHANGELOG.md index b226cbf53..6988b2fb1 100644 --- a/Sekoia.io/CHANGELOG.md +++ b/Sekoia.io/CHANGELOG.md @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased -## 2024-12-11 - 2.65.11 +## 2024-12-10 - 2.65.12 ### Changed diff --git a/Sekoia.io/manifest.json b/Sekoia.io/manifest.json index 415436d03..6fa4f7f61 100644 --- a/Sekoia.io/manifest.json +++ b/Sekoia.io/manifest.json @@ -12,7 +12,7 @@ "name": "Sekoia.io", "uuid": "92d8bb47-7c51-445d-81de-ae04edbb6f0a", "slug": "sekoia.io", - "version": "2.65.11", + "version": "2.65.12", "categories": [ "Generic" ] diff --git a/Sekoia.io/sekoiaio/operation_center/synchronize_assets_with_ad.py b/Sekoia.io/sekoiaio/operation_center/synchronize_assets_with_ad.py index ee1549901..01d574a9e 100644 --- a/Sekoia.io/sekoiaio/operation_center/synchronize_assets_with_ad.py +++ b/Sekoia.io/sekoiaio/operation_center/synchronize_assets_with_ad.py @@ -60,14 +60,15 @@ def get_assets(search_query: str, also_search_in_detection_properties: bool = Fa def post_request(endpoint: str, json_data: str) -> Dict[str, Any]: api_path = urljoin(base_url + "/", endpoint) - response = session.post(api_path, json=json_data) + response = session.post(api_path, data=json_data) if not response.ok: self.error(f"HTTP POST request failed: {api_path} with status code {response.status_code}") return response.json() def put_request(endpoint: str, json_data: str) -> None: api_path = urljoin(base_url + "/", endpoint) - response = session.put(api_path, json=json_data) + response = session.put(api_path, data=json_data) + # print(f"\nresponse.status_code: {response.status_code}") if not response.ok: self.error(f"HTTP PUT request failed: {api_path} with status code {response.status_code}") diff --git a/Sekoia.io/tests/operation_center_action/test_synchronize_assets.py b/Sekoia.io/tests/operation_center_action/test_synchronize_assets.py index 41e050bdf..fc970ac7a 100644 --- a/Sekoia.io/tests/operation_center_action/test_synchronize_assets.py +++ b/Sekoia.io/tests/operation_center_action/test_synchronize_assets.py @@ -151,9 +151,9 @@ def match_detection_properties(request): "atoms": {"email": ["jdoe@example.com"], "department": ["engineering"]}, "community_uuid": "community-1234", } - assert post_request.json() == json.dumps(expected_post_payload), "POST request payload mismatch." + assert post_request.json() == expected_post_payload, "POST request payload mismatch." - def test_on_asset_found_and_merge(self, requests_mock, action_instance, arguments): + def test_one_asset_found_and_merge(self, requests_mock, action_instance, arguments): """ Test the SynchronizeAssetsWithAD action for the scenario where multiple assets are found, and one of them is edited while merging the others. @@ -244,7 +244,7 @@ def match_detection_properties(request): "props": {"dept": "engineering"}, "atoms": {"email": ["jdoe@example.com"], "department": ["engineering"]}, } - assert put_request.json() == json.dumps(expected_put_payload), "PUT request payload mismatch." + assert put_request.json() == expected_put_payload, "PUT request payload mismatch." def test_multiple_assets_found_and_merge(self, requests_mock, action_instance, arguments): """ @@ -351,7 +351,7 @@ def match_detection_properties(request): "props": {"dept": "engineering"}, "atoms": {"email": ["jdoe@example.com"], "department": ["engineering"]}, } - assert put_request.json() == json.dumps(expected_put_payload), "PUT request payload mismatch." + assert put_request.json() == expected_put_payload, "PUT request payload mismatch." # Verify POST merge request payload post_merge_requests = [ @@ -368,3 +368,24 @@ def match_detection_properties(request): # Assert 'sources' list contains the same elements, regardless of order assert set(post_merge["sources"]) == set(expected_merge_payload["sources"]), "Sources mismatch." + + # def test_one_asset_found_and_merge_testapp(self): + # # Extract configuration from the mock module + # base_url = "https://app.test.sekoia.io" + # api_key = "TO_ADD" + + # app_test_arg = Arguments( # TO COMPLETE + # user_ad_data={}, + # asset_synchronization_configuration={}, + # community_uuid="", + # ) + + # configuration = { + # "base_url": base_url, + # "api_key": api_key, + # } + # module = MockModule(configuration=configuration) + # action = SynchronizeAssetsWithAD() + # action.module = module + # # Execute the action + # response = action.run(app_test_arg)