def test_perform_command_should_dispatch_to_icinga_if_handler_is_icinga(self, cmd, current_config):
        mock_config = Mock()
        mock_config.icinga_command_file = '/path/to/commandfile.cmd'
        current_config.return_value = mock_config

        perform_command('FOO;bar', None, 'icinga')

        cmd.assert_called_with('FOO;bar', '/path/to/commandfile.cmd', None)
    def test_perform_command_should_dispatch_to_livestatus_if_handler_is_livestatus(self, cmd, current_config):
        mock_config = Mock()
        mock_config.livestatus_socket = '/path/to/socket'
        current_config.return_value = mock_config

        perform_command('FOO;bar', None, 'livestatus')

        cmd.assert_called_with('FOO;bar', '/path/to/socket', None)
    def test_perform_command_should_dispatch_to_icinga_if_handler_is_icinga(
            self, cmd, current_config):
        mock_config = Mock()
        mock_config.icinga_command_file = '/path/to/commandfile.cmd'
        current_config.return_value = mock_config

        perform_command('FOO;bar', None, 'icinga')

        cmd.assert_called_with('FOO;bar', '/path/to/commandfile.cmd', None)
    def test_perform_command_should_dispatch_to_livestatus_if_handler_is_livestatus(
            self, cmd, current_config):
        mock_config = Mock()
        mock_config.livestatus_socket = '/path/to/socket'
        current_config.return_value = mock_config

        perform_command('FOO;bar', None, 'livestatus')

        cmd.assert_called_with('FOO;bar', '/path/to/socket', None)
예제 #5
0
    def test_perform_command_should_dispatch_to_icinga_if_handler_is_icinga(self):
        when(livestatus_service.dispatcher).perform_icinga_command(any_value(), any_value(), any_value()).thenReturn(None)
        mock_config = mock()
        mock_config.icinga_command_file = '/path/to/commandfile.cmd'
        when(livestatus_service.dispatcher).get_current_configuration().thenReturn(mock_config)

        perform_command('FOO;bar', None, 'icinga')

        verify(livestatus_service.dispatcher).perform_icinga_command('FOO;bar', '/path/to/commandfile.cmd', None)
예제 #6
0
    def test_perform_command_should_dispatch_to_livestatus_if_handler_is_livestatus(self):
        when(livestatus_service.dispatcher).perform_livestatus_command(any_value(), any_value(), any_value()).thenReturn(None)
        mock_config = mock()
        mock_config.livestatus_socket = '/path/to/socket'
        when(livestatus_service.dispatcher).get_current_configuration().thenReturn(mock_config)

        perform_command('FOO;bar', None, 'livestatus')

        verify(livestatus_service.dispatcher).perform_livestatus_command('FOO;bar', '/path/to/socket', None)
예제 #7
0
    def test_perform_command_should_dispatch_to_icinga_if_handler_is_icinga(self, cmd, current_config):
        mock_config = Mock()
        mock_config.icinga_command_file = '/path/to/commandfile.cmd'
        mock_config.admins = ["admin"]
        current_config.return_value = mock_config

        perform_command('FOO;bar', key=None, handler='icinga', auth="admin")

        cmd.assert_called_with('FOO;bar', '/path/to/commandfile.cmd', None, auth='admin')
예제 #8
0
    def test_perform_command_should_call_check_contact_permissions_if_not_admin(self, cmd, current_config, perm):
        mock_config = Mock()
        mock_config.livestatus_socket = '/path/to/socket'
        mock_config.admins = ["admin"]
        current_config.return_value = mock_config

        perform_command('FOO;bar', None, handler='livestatus', auth="admin")

        self.assertFalse(perm.called)
    def test_perform_command_should_call_check_contact_permissions_if_not_admin(
            self, cmd, current_config, perm):
        mock_config = Mock()
        mock_config.livestatus_socket = '/path/to/socket'
        mock_config.admins = ["admin"]
        current_config.return_value = mock_config

        perform_command('FOO;bar', None, handler='livestatus', auth="admin")

        self.assertFalse(perm.called)
예제 #10
0
    def test_perform_command_should_dispatch_to_icinga_if_handler_is_icinga(
            self):
        when(livestatus_service.dispatcher).perform_icinga_command(
            any_value(), any_value(), any_value()).thenReturn(None)
        mock_config = mock()
        mock_config.icinga_command_file = '/path/to/commandfile.cmd'
        when(livestatus_service.dispatcher).get_current_configuration(
        ).thenReturn(mock_config)

        perform_command('FOO;bar', None, 'icinga')

        verify(livestatus_service.dispatcher).perform_icinga_command(
            'FOO;bar', '/path/to/commandfile.cmd', None)
예제 #11
0
    def test_perform_command_should_dispatch_to_livestatus_if_handler_is_livestatus(
            self):
        when(livestatus_service.dispatcher).perform_livestatus_command(
            any_value(), any_value(), any_value()).thenReturn(None)
        mock_config = mock()
        mock_config.livestatus_socket = '/path/to/socket'
        when(livestatus_service.dispatcher).get_current_configuration(
        ).thenReturn(mock_config)

        perform_command('FOO;bar', None, 'livestatus')

        verify(livestatus_service.dispatcher).perform_livestatus_command(
            'FOO;bar', '/path/to/socket', None)
    def test_perform_command_should_dispatch_to_icinga_if_handler_is_icinga(
            self, cmd, current_config):
        mock_config = Mock()
        mock_config.icinga_command_file = '/path/to/commandfile.cmd'
        mock_config.admins = ["admin"]
        current_config.return_value = mock_config

        perform_command('FOO;bar', key=None, handler='icinga', auth="admin")

        cmd.assert_called_with('FOO;bar',
                               '/path/to/commandfile.cmd',
                               None,
                               auth='admin')