@@ -89,6 +89,60 @@ def test_sample_from_url(self, requests_mock):
89
89
files = None
90
90
)
91
91
92
+ def test_sample_from_file (self ):
93
+ with pytest .raises (WrongInputError , match = r"file_source parameter must be a file open in 'rb' mode." ):
94
+ self .a1000 .upload_sample_from_file (file_source = "/path/to/file" )
95
+
96
+ def test_file_status (self , requests_mock ):
97
+ self .a1000 .file_analysis_status (sample_hashes = [SHA1 , SHA1 ], sample_status = "MALICIOUS" )
98
+
99
+ expected_url = f"{ self .host } /api/samples/status/"
100
+
101
+ requests_mock .post .assert_called_with (
102
+ url = expected_url ,
103
+ verify = True ,
104
+ proxies = None ,
105
+ headers = {"User-Agent" : DEFAULT_USER_AGENT , "Authorization" : f"Token { self .token } " },
106
+ params = {"status" : "MALICIOUS" },
107
+ json = None ,
108
+ data = {"hash_values" : [SHA1 , SHA1 ]},
109
+ files = None
110
+ )
111
+
112
+ def test_url_status (self , requests_mock ):
113
+ self .a1000 .check_submitted_url_status (task_id = "aaa" )
114
+
115
+ expected_url = f"{ self .host } /api/uploads/v2/url-samples/aaa"
116
+
117
+ requests_mock .get .assert_called_with (
118
+ url = expected_url ,
119
+ verify = True ,
120
+ proxies = None ,
121
+ headers = {"User-Agent" : DEFAULT_USER_AGENT , "Authorization" : f"Token { self .token } " },
122
+ params = None
123
+ )
124
+
125
+ def test_url_report (self , requests_mock ):
126
+ with pytest .raises (WrongInputError , match = r"task_id parameter must be a string." ):
127
+ self .a1000 .get_submitted_url_report (task_id = 123 , retry = False )
128
+
129
+ def test_detailed_report (self , requests_mock ):
130
+ with pytest .raises (WrongInputError , match = r"fields parameter must be a list of strings." ):
131
+ self .a1000 .get_detailed_report_v2 (sample_hashes = SHA1 , fields = "field1,field2" )
132
+
133
+ def test_download_sample (self , requests_mock ):
134
+ self .a1000 .download_sample (sample_hash = SHA1 )
135
+
136
+ expected_url = f"{ self .host } /api/samples/{ SHA1 } /download/"
137
+
138
+ requests_mock .get .assert_called_with (
139
+ url = expected_url ,
140
+ verify = True ,
141
+ proxies = None ,
142
+ headers = {"User-Agent" : DEFAULT_USER_AGENT , "Authorization" : f"Token { self .token } " },
143
+ params = None
144
+ )
145
+
92
146
def test_wrong_id (self , requests_mock ):
93
147
with pytest .raises (WrongInputError , match = r"task_id parameter must be a string." ):
94
148
self .a1000 .get_submitted_url_report (task_id = 123 , retry = False )
@@ -304,6 +358,9 @@ def test_start_yara_retro(self, requests_mock):
304
358
files = None
305
359
)
306
360
361
+ def test_yara_retro_status (self , requests_mock ):
362
+ pass
363
+
307
364
def test_wrong_operation (self , requests_mock ):
308
365
with pytest .raises (WrongInputError , match = r"operation parameter must be either 'START' or 'STOP'" ):
309
366
self .a1000 .start_or_stop_yara_local_retro_scan ("BEGIN" )
@@ -343,7 +400,7 @@ def test_list_containers(self, requests_mock):
343
400
files = None
344
401
)
345
402
346
- def test_network_report (self , requests_mock ):
403
+ def test_domain_report (self , requests_mock ):
347
404
domain = "some.test.domain"
348
405
349
406
self .a1000 .network_domain_report (domain )
@@ -357,3 +414,25 @@ def test_network_report(self, requests_mock):
357
414
headers = {"User-Agent" : DEFAULT_USER_AGENT , "Authorization" : f"Token { self .token } " },
358
415
params = None
359
416
)
417
+
418
+ def test_ip_to_domain (self , requests_mock ):
419
+ self .a1000 .network_ip_to_domain ("1.2.3.4" )
420
+
421
+ params = {
422
+ "page" : None ,
423
+ "page_size" : 500
424
+ }
425
+
426
+ expected_url = f"{ self .host } /api/network-threat-intel/ip/1.2.3.4/resolutions/"
427
+
428
+ requests_mock .get .assert_called_with (
429
+ url = expected_url ,
430
+ verify = True ,
431
+ proxies = None ,
432
+ headers = {"User-Agent" : DEFAULT_USER_AGENT , "Authorization" : f"Token { self .token } " },
433
+ params = params
434
+ )
435
+
436
+ def test_files_from_ip (self , requests_mock ):
437
+ with pytest .raises (WrongInputError , match = r"is allowed as the classification input" ):
438
+ self .a1000 .network_files_from_ip (ip_addr = "1.2.3.4" , classification = "KNOWN" )
0 commit comments