test : added unit tests for build_alert_payload in notification_service#1711
Open
tmdeveloper007 wants to merge 1 commit into
Open
test : added unit tests for build_alert_payload in notification_service#1711tmdeveloper007 wants to merge 1 commit into
tmdeveloper007 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1705.
Summary of What Has Been Done:
Added
testing/backend/unit/test_notification_service_build_alert_payload.pywith 8 unit tests coveringbuild_alert_payloadinbackend/secuscan/notification_service.py.Changes Made:
test_builds_payload_with_all_fields: verifies complete finding and rule dicts produce the correct payload structure with event, rule, and finding sectionstest_missing_metadata_json_produces_empty_metadata: missingmetadata_jsonkey results inmetadata={}test_invalid_metadata_json_falls_back_to_raw_string: non-JSONmetadata_jsonis caught by the try/except and stored as{"raw": "..."}test_non_string_metadata_json_raises_type_error_and_falls_back: intmetadata_jsonraisesTypeErrorcaught by the except clausetest_missing_finding_fields_produce_none_in_payload: optional finding fields that are missing appear asNonein the payloadtest_valid_dict_metadata_json_is_parsed_and_redacted: valid JSON dict inmetadata_jsonis parsed andredact_inputsappliedtest_rule_channel_type_is_included:rule.channel_typeis present in the payload rule sectiontest_redact_dict_is_called_on_result: mocksredact_dictto verify it is called on the final payloadImpact it Made:
build_alert_payloadunder test coverage for the first timeNote: This task is being handled by tmdeveloper007 — please assign to that account when picking it up.