Skip to content

Commit 3ae7148

Browse files
committed
Use dict so formatting better taken care of for json
1 parent 93dfb4d commit 3ae7148

File tree

1 file changed

+37
-39
lines changed

1 file changed

+37
-39
lines changed

test/unit/security_test.py

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,18 @@ def test_security_issue_title_template(self, expected, issue):
4646
(
4747
cleandoc(
4848
"""
49-
## Summary
50-
Random Multiline
51-
Description
52-
;)
53-
54-
CVE: CVE-2023-39410
55-
CWE: CWE-XYZ
56-
57-
## References
58-
- https://www.example.com
59-
- https://www.foobar.com
60-
"""
49+
## Summary
50+
Random Multiline
51+
Description
52+
;)
53+
54+
CVE: CVE-2023-39410
55+
CWE: CWE-XYZ
56+
57+
## References
58+
- https://www.example.com
59+
- https://www.foobar.com
60+
"""
6161
),
6262
security.Issue(
6363
cve="CVE-2023-39410",
@@ -275,34 +275,31 @@ def test_format_jsonl_removes_newline():
275275

276276

277277
@pytest.mark.parametrize(
278-
"json_file,expected",
278+
"json_input,expected",
279279
[
280280
(
281-
"""{
282-
"results": [
283-
{
284-
"code": "1 import subprocess\\n2 from typing import Iterable\\n3 \\n",
285-
"col_offset": 12,
286-
"end_col_offset": 17,
287-
"filename": "/home/test/python-toolbox/exasol/toolbox/git.py",
288-
"issue_confidence": "HIGH",
289-
"issue_cwe": {
290-
"id": 78,
291-
"link": "https://cwe.mitre.org/data/definitions/78.html"
292-
},
293-
"issue_severity": "LOW",
294-
"issue_text": "Consider possible security implications associated with the subprocess module.",
295-
"line_number": 53,
296-
"line_range": [
297-
1
298-
],
299-
"more_info": "https://bandit.readthedocs.io/en/1.7.10/blacklists/blacklist_imports.html#b404-import-subprocess",
300-
"test_id": "B404",
301-
"test_name": "blacklist"
302-
}
303-
]
304-
}
305-
""",
281+
{
282+
"results": [
283+
{
284+
"code": "1 import subprocess\\n2 from typing import Iterable\\n3 \\n",
285+
"col_offset": 12,
286+
"end_col_offset": 17,
287+
"filename": "/home/test/python-toolbox/exasol/toolbox/git.py",
288+
"issue_confidence": "HIGH",
289+
"issue_cwe": {
290+
"id": 78,
291+
"link": "https://cwe.mitre.org/data/definitions/78.html",
292+
},
293+
"issue_severity": "LOW",
294+
"issue_text": "Consider possible security implications associated with the subprocess module.",
295+
"line_number": 53,
296+
"line_range": [1],
297+
"more_info": "https://bandit.readthedocs.io/en/1.7.10/blacklists/blacklist_imports.html#b404-import-subprocess",
298+
"test_id": "B404",
299+
"test_name": "blacklist",
300+
}
301+
]
302+
},
306303
{
307304
"file_name": "exasol/toolbox/git.py",
308305
"line": 53,
@@ -318,7 +315,8 @@ def test_format_jsonl_removes_newline():
318315
)
319316
],
320317
)
321-
def test_from_json(json_file, expected):
318+
def test_from_json(json_input, expected):
319+
json_file = json.dumps(json_input)
322320
actual = security.from_json(json_file, pathlib.Path("/home/test/python-toolbox"))
323321
expected_issue = security.SecurityIssue(
324322
file_name=expected["file_name"],

0 commit comments

Comments
 (0)