Browse Source

use generic_test in FTP unittest

add coverage comment
refactor whitspaces
Jens Keim 6 năm trước cách đây
mục cha
commit
52d2471e6c
1 tập tin đã thay đổi với 9 bổ sung18 xóa
  1. 9 18
      code/Test/test_FTPWinaXeExploit.py

+ 9 - 18
code/Test/test_FTPWinaXeExploit.py

@@ -1,34 +1,25 @@
-import os
-import random
 import unittest
 import unittest.mock as mock
 
-from ID2TLib.Controller import *
-from Test.Lib import test_pcap, get_sha256
-
+from Test.GenericTest import GenericTest
 
 sha_one_attacker_ftp = 'd43ebfd5b0f3c9b6556e6a8d2ae4da4d334ed673881d67720eda16faab1b498e'
 
+"""
+Name                             Stmts   Miss  Cover   Missing
+--------------------------------------------------------------------------------------------
+Attack/FTPWinaXeExploit.py         141     14    90%   55, 66, 71, 121-122, 148-150, 208-214
+"""
 
 
-class UnitTestFTPWinaXeExploit(unittest.TestCase):
-
-    def clean_up(self, controller):
-        os.remove(controller.pcap_dest_path)
-        os.remove(controller.label_manager.label_file_path)
-
+class UnitTestFTPWinaXeExploit(GenericTest):
 
     @mock.patch('ID2TLib.Utility.get_rnd_x86_nop')
     @mock.patch('ID2TLib.Utility.get_rnd_bytes')
-    def test_one_attacker_ftp(self,mock_rnd_x86_nop,mock_rnd_bytes):
-        random.seed(5)
+    def test_one_attacker_ftp(self, mock_rnd_x86_nop, mock_rnd_bytes):
         mock_rnd_x86_nop.return_value = b''
         mock_rnd_bytes.return_value = b''
-        controller = Controller(pcap_file_path=test_pcap, do_extra_tests=False)
-        controller.load_pcap_statistics(False, False, False)
-        controller.process_attacks([['FTPWinaXeExploit' ]])
-        self.assertEqual(get_sha256(controller.pcap_dest_path), sha_one_attacker_ftp)
-        self.clean_up(controller)
+        self.generic_test([['FTPWinaXeExploit']], sha_one_attacker_ftp)
 
 
 if __name__ == '__main__':