forked from OWASP/SecureTea-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_gather_file.py
32 lines (28 loc) · 899 Bytes
/
test_gather_file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding: utf-8 -*-
import unittest
from securetea.lib.web_deface.gather_file import GatherFile
try:
# if python 3.x.x
from unittest.mock import patch
except ImportError: # python 2.x.x
from mock import patch
class TestGatherFile(unittest.TestCase):
"""
Test class for SecureTea Web Deface GatherFile.
"""
def setUp(self):
"""
Setup test class for TestGatherFile.
"""
# Create GatherFile object
self.gather_file_obj = GatherFile()
@patch("securetea.lib.web_deface.gather_file.os.walk")
def test_scan_dir(self, mck_os_wlk):
"""
Test scan_dir.
"""
# Mock OS return values
mck_os_wlk.return_value = [["root", "dir", ["file1", "file2"]]]
res = self.gather_file_obj.scan_dir()
found_files = ['root/file1', 'root/file2']
self.assertEqual(res, found_files)