55import pytest
66from c42eventextractor .extractors import FileEventExtractor
77from py42 .sdk .queries .fileevents .file_event_query import FileEventQuery
8+ from py42 .sdk .queries .fileevents .filters .file_filter import FileCategory
89from tests .cmds .conftest import filter_term_is_in_call_args
910from tests .cmds .conftest import get_filter_value_from_json
1011from tests .cmds .conftest import get_mark_for_search_and_send_to
@@ -650,7 +651,7 @@ def test_search_and_send_to_when_given_file_path_uses_file_path_filter(
650651def test_search_and_send_to_when_given_file_category_uses_file_category_filter (
651652 runner , cli_state , file_event_extractor , command
652653):
653- file_category = " IMAGE"
654+ file_category = FileCategory . IMAGE
654655 command = [* command , "--begin" , "1h" , "--file-category" , file_category ]
655656 runner .invoke (
656657 cli , command , obj = cli_state ,
@@ -659,6 +660,44 @@ def test_search_and_send_to_when_given_file_category_uses_file_category_filter(
659660 assert str (f .FileCategory .is_in ([file_category ])) in filter_strings
660661
661662
663+ @pytest .mark .parametrize (
664+ "category_choice" ,
665+ [
666+ ("AUDIO" , FileCategory .AUDIO ),
667+ ("DOCUMENT" , FileCategory .DOCUMENT ),
668+ ("EXECUTABLE" , FileCategory .EXECUTABLE ),
669+ ("IMAGE" , FileCategory .IMAGE ),
670+ ("PDF" , FileCategory .PDF ),
671+ ("PRESENTATION" , FileCategory .PRESENTATION ),
672+ ("SCRIPT" , FileCategory .SCRIPT ),
673+ ("SOURCE_CODE" , FileCategory .SOURCE_CODE ),
674+ ("SPREADSHEET" , FileCategory .SPREADSHEET ),
675+ ("VIDEO" , FileCategory .VIDEO ),
676+ ("VIRTUAL_DISK_IMAGE" , FileCategory .VIRTUAL_DISK_IMAGE ),
677+ ("ARCHIVE" , FileCategory .ZIP ),
678+ ("ZIP" , FileCategory .ZIP ),
679+ ("Zip" , FileCategory .ZIP ),
680+ ],
681+ )
682+ def test_all_caps_file_category_choices_convert_to_filecategory_constant (
683+ runner , cli_state , file_event_extractor , category_choice
684+ ):
685+ ALL_CAPS_VALUE , camelCaseValue = category_choice
686+ command = [
687+ "security-data" ,
688+ "search" ,
689+ "--begin" ,
690+ "1h" ,
691+ "--file-category" ,
692+ ALL_CAPS_VALUE ,
693+ ]
694+ runner .invoke (
695+ cli , command , obj = cli_state ,
696+ )
697+ filter_strings = [str (arg ) for arg in file_event_extractor .extract .call_args [0 ]]
698+ assert str (f .FileCategory .is_in ([camelCaseValue ])) in filter_strings
699+
700+
662701@search_and_send_to_test
663702def test_search_and_send_to_when_given_process_owner_uses_process_owner_filter (
664703 runner , cli_state , file_event_extractor , command
0 commit comments