Exemple #1
0
    def test_scan_when_ok(self):
        # Prepare data and mocks
        test_subject = Ssh(None)
        test_subject.check_protocol = MagicMock(return_value=True)

        # Run test scenario
        result = test_subject.scan()

        # Assertions
        test_subject.check_protocol.assert_called_once_with('/etc/ssh/sshd_config')
        self.assertEqual(result[0], ScanStatus.success)
Exemple #2
0
    def test_check_protocol_when_ok_no_protocol(self):
        # Prepare data and mocks
        with patch('builtins.open', mock_open(read_data='#	$OpenBSD: s\n\n# Host *\nSomeConfig')) as mock_file:
            test_subject = Ssh(None)

            # Run test scenario
            result = test_subject.check_protocol('/etc/ssh/sshd_config')

            # Assertions
            mock_file.assert_called_once_with('/etc/ssh/sshd_config')
            self.assertTrue(result)
Exemple #3
0
    def test_scan_when_ok(self):
        # Prepare data and mocks
        test_subject = Ssh(None)
        test_subject.check_protocol = MagicMock(return_value=True)

        # Run test scenario
        result = test_subject.scan()

        # Assertions
        test_subject.check_protocol.assert_called_once_with(
            '/etc/ssh/sshd_config')
        self.assertEqual(result[0], ScanStatus.success)
Exemple #4
0
    def test_check_protocol_when_ok_no_protocol(self):
        # Prepare data and mocks
        with patch(
                'builtins.open',
                mock_open(read_data='#	$OpenBSD: s\n\n# Host *\nSomeConfig')
        ) as mock_file:
            test_subject = Ssh(None)

            # Run test scenario
            result = test_subject.check_protocol('/etc/ssh/sshd_config')

            # Assertions
            mock_file.assert_called_once_with('/etc/ssh/sshd_config')
            self.assertTrue(result)