Update Malwarebazaar test and comply with flake8

This commit is contained in:
Wes
2023-12-19 02:57:35 +00:00
parent 5e715036fb
commit 614589153b
2 changed files with 181 additions and 158 deletions

View File

@@ -23,6 +23,18 @@ class TestMalwarebazaarMethods(unittest.TestCase):
self.assertEqual(mock_cmd.getvalue(), expected)
mock.assert_called_once()
def test_isInJson_tail_greater_than_max_depth(self):
max_depth = 1000
tail = 2000
test_string = "helo"
input_json = {
"value": "test",
"test": "value",
"arr": ["Foo", "Bar", "Hello"],
"dict1": {"key1": "val", "key2": "helo"}
}
self.assertEqual(malwarebazaar.isInJson(input_json, test_string, max_depth, tail), False)
def test_isInJson_string_found_in_dict(self):
test_string = "helo"
input_json = {
@@ -33,6 +45,18 @@ class TestMalwarebazaarMethods(unittest.TestCase):
}
self.assertEqual(malwarebazaar.isInJson(input_json, test_string), True)
def test_isInJson_dict_in_list(self):
max_depth = 1000
tail = 1
test_string = "helo"
input_json = {
"key1": "test",
"key2": "value",
"key3": ["Foo", "Bar", "Hello"],
"nested_list": [{"key1": "val", "key2": "helo"}]
}
self.assertEqual(malwarebazaar.isInJson(input_json, test_string, max_depth, tail), True)
def test_isInJson_string_found_in_arr(self):
test_string = "helo"
input_json = {
@@ -51,8 +75,7 @@ class TestMalwarebazaarMethods(unittest.TestCase):
"arr": ["Foo", "Bar", "helo"],
"dict1": {"Hello": "val", "key": "val"}
}
self.assertEqual(malwarebazaar.isInJson(
input_json, test_string), False)
self.assertEqual(malwarebazaar.isInJson(input_json, test_string), False)
def test_analyze(self):
"""simulated sendReq and prepareResults with 2 mock objects