Skip to content

Commit

Permalink
added isInJson tests
Browse files Browse the repository at this point in the history
  • Loading branch information
semphorin committed Dec 18, 2023
1 parent 6a4e05d commit 03421c1
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions salt/sensoroni/files/analyzers/malwarebazaar/malwarebazaar_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,36 @@ def test_main_success(self):
expected = '{"test": "val"}\n'
self.assertEqual(mock_cmd.getvalue(), expected)
mock.assert_called_once()

def isInJson_string_found_in_dict(self):
test_string = "helo"
input_json = {
"value":"test",
"test":"value",
"arr":["Foo", "Bar", "Hello"],
"dict1":{"helo":"val", "key":"val"}
}
self.assertEqual(malwarebazaar.isInJson(test_string), True)

def isInJson_string_found_in_arr(self):
test_string = "helo"
input_json = {
"value":"test",
"test":"value",
"arr":["Foo", "Bar", "helo"],
"dict1":{"Hello":"val", "key":"val"}
}
self.assertEqual(malwarebazaar.isInJson(test_string), True)

def isInJson_string_not_found(self):
test_string = "ValNotInJSON"
input_json = {
"value":"test",
"test":"value",
"arr":["Foo", "Bar", "helo"],
"dict1":{"Hello":"val", "key":"val"}
}
self.assertEqual(malwarebazaar.isInJson(test_string), False)

def test_analyze(self):
"""simulated sendReq and prepareResults with 2 mock objects and variables sendReqOutput and prepareResultOutput,
Expand Down

1 comment on commit 03421c1

@weslambert
Copy link
Contributor

@weslambert weslambert commented on 03421c1 Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like input_json is not being used here. I would think it would be something like the following, right? The tests aren't passing on my side, and won't be tested unless you add the test_ prefix.

self.assertEqual(malwarebazaar.isInJson(input_json, test_string, 1000), False)

Also, it looks like there might need to be some adjustment to comply with flake8. I wouldn't worry about it until after the test are passing, though.

Please sign in to comment.