Skip to content

Commit 2ec73a6

Browse files
author
izar tarandach
committed
test: Update threat count assertion and add test for multiple threat files
1 parent 370ccb6 commit 2ec73a6

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

tests/test_private_func.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def test_kwargs(self):
4949

5050
def test_load_threats(self):
5151
tm = TM("TM")
52-
self.assertNotEqual(len(TM._threats), 0)
52+
self.assertNotEqual(len(TM._threats), 1)
5353
with self.assertRaises(UIError):
5454
tm.threatsFile = "threats.json"
5555

tests/test_pytmfunc.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,23 @@ def test_json_loads(self):
414414
[f.name for f in tm._flows], ["Request", "Insert", "Select", "Response"]
415415
)
416416

417+
def test_threat_files(self):
418+
dir_path = os.path.dirname(os.path.realpath(__file__))
419+
foo_file = f"{dir_path}/1.json"
420+
bar_file = f"{dir_path}/2.json"
421+
threat_files = [os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
422+
+ "/pytm/threatlib/threats.json", foo_file, bar_file]
423+
424+
TM.reset()
425+
tm = TM("testing multiple threat library files",
426+
description="aaa",
427+
threatsFile=threat_files)
428+
ctr = 0
429+
for t in TM._threats:
430+
if t.id == "FOO" or t.id == "BAR":
431+
ctr += 1
432+
self.assertTrue(ctr == 2)
433+
417434
def test_report(self):
418435
random.seed(0)
419436
dir_path = os.path.dirname(os.path.realpath(__file__))

0 commit comments

Comments
 (0)