Esempio n. 1
0
class FileMockTests(BaseTestCase):

    def before(self):
        self.mock = FileMock(DEFAULT_CONTENT)

    def test_file_mock_is_iterable(self):
        counter = 0
        for line in self.mock:
            assert_that(line, equal_to(DEFAULT_CONTENT[counter]))
            counter += 1

    def test_file_mock_is_readable_as_a_file(self):
        expected_output = "".join(DEFAULT_CONTENT)

        assert_that(self.mock.read(), equal_to(expected_output))
        self.mock.close()
Esempio n. 2
0
    def test_target_service_scans_nmap_output_file(self):
        file_lines = [
            "Host: 127.0.0.1\tPorts: 7/filtered/tcp//echo//, 80/open/tcp//http/Microsoft IIS\t\n"
        ]
        flexmock(self.scanner)
        self.scanner.should_receive("open_file").and_return(
            FileMock(file_lines))

        self.scanner.target_service("nmap_file", "service")
Esempio n. 3
0
 def _stub_open_file(self, args, file_lines):
     returned_file = FileMock(file_lines)
     self.scanner.should_receive("open_file").with_args(args).and_return(
         returned_file)
Esempio n. 4
0
 def before(self):
     self.mock = FileMock(DEFAULT_CONTENT)