@@ -85,7 +85,63 @@ def test_submit_parser(
8585 },
8686 "creator" : {
8787 "author" : "test_author"
88- }
88+ },
89+ "validatedOnEmptyLogs" : False ,
90+ }, timeout = url .HTTP_REQUEST_TIMEOUT_IN_SECS )
91+
92+
93+ @mock .patch (
94+ "common.chronicle_auth.initialize_dataplane_http_session"
95+ )
96+ @mock .patch ("parsers.url.get_dataplane_url" )
97+ def test_submit_parser_skip_validation (
98+ mock_get_dataplane_url : mock .MagicMock ,
99+ mock_http_session : mock .MagicMock ,
100+ test_data_submit_parser : mock_test_utility .MockResponse ) -> None :
101+ """Test case to check success response.
102+
103+ Args:
104+ mock_get_dataplane_url (mock.MagicMock): Mock object
105+ mock_http_session (mock.MagicMock): Mock object
106+ test_data_submit_parser (mock_test_utility.MockResponse): Test input data
107+ """
108+ create_temp_config_file (TEMP_SUBMIT_CONF_FILE , "test_config" )
109+ mock_get_dataplane_url .return_value = SUBMIT_URL
110+ client = mock .Mock ()
111+ client .request .side_effect = [test_data_submit_parser ]
112+ mock_http_session .return_value = client
113+ result = runner .invoke (submit_parser_command .submit_parser , [
114+ "test_project" , "test_instance" , "test_log_type" ,
115+ TEMP_SUBMIT_CONF_FILE , "test_author" ,
116+ "--v2" , "--skip_validation_on_no_logs" ,
117+ "--env" , "PROD" , "--region" , "US" ])
118+ assert """Submitting Parser...
119+
120+ Parser Details:
121+ Parser ID: test_parser_id
122+ Log type: test_log_type
123+ State: INACTIVE
124+ Type: CUSTOM
125+ Author: test_author
126+ Validation Report ID: -
127+ Create Time: 2023-01-01T00:00:00.000000Z
128+
129+ ============================================================
130+
131+ """ == result .output
132+ mock_get_dataplane_url .assert_called_once_with (
133+ "US" , "submit_parser" , "prod" , RESOURCES )
134+ mock_http_session .return_value .request .assert_called_once_with (
135+ "POST" , SUBMIT_URL , json = {
136+ "cbn" : "dGVzdF9jb25maWc=" ,
137+ "type" : "CUSTOM" ,
138+ "changelogs" : {
139+ "entries" : []
140+ },
141+ "creator" : {
142+ "author" : "test_author"
143+ },
144+ "validatedOnEmptyLogs" : True ,
89145 }, timeout = url .HTTP_REQUEST_TIMEOUT_IN_SECS )
90146
91147
0 commit comments