Skip to content

Commit

Permalink
Risk tracker tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pritchyspritch committed May 16, 2024
1 parent 741e9f6 commit ba6a430
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions produce_risk_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def print_yaml(risk_dict: dict):
def build_risk(risk_dict: dict):
template_file = open("yaml-templates/risks_template.yaml")
template_str = template_file.read()
template_file.close()
risk_template = Template(template_str)
risk_yaml = risk_template.render(risk_dict)

Expand Down
30 changes: 30 additions & 0 deletions tests/test_produce_risk_tracker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import unittest

from produce_risk_tracker import build_risk


class TestRiskBuilder(unittest.TestCase):

def test_build_risk(self):
risk_dict = {
"name": "test_asset@test_test",
"status": "mitigated",
"justification": "Because security.",
"ticket": "XXX-YYY",
"date": "2024-05-16",
"checked_by": "pritchyspritch",
}
risk_yaml = build_risk(risk_dict)

expected_yaml = """ test_asset@test_test: # wildcards "*" between the @ characters are possible
status: mitigated # values: unchecked, in-discussion, accepted, in-progress, mitigated, false-positive
justification: Because security.
ticket: XXX-YYY
date: 2024-05-16
checked_by: pritchyspritch"""

self.assertEqual(expected_yaml, risk_yaml)


if __name__ == "__main__":
unittest.main()

0 comments on commit ba6a430

Please sign in to comment.