예제 #1
0
    def test_add_user(self):
        """
        Test if it add a rabbitMQ user via rabbitmqctl
        user_add <user> <password>
        """
        mock_run = MagicMock(return_value={
            "retcode": 0,
            "stdout": "saltstack",
            "stderr": ""
        })
        with patch.dict(rabbitmq.__salt__, {"cmd.run_all": mock_run}):
            self.assertDictEqual(rabbitmq.add_user("saltstack"),
                                 {"Added": "saltstack"})

        mock_run = MagicMock(return_value="Error")
        with patch.dict(rabbitmq.__salt__, {"cmd.run_all": mock_run}):
            with patch.object(
                    rabbitmq,
                    "clear_password",
                    return_value={
                        "Error": "Error",
                        "retcode": 1
                    },
            ):
                self.assertRaises(CommandExecutionError, rabbitmq.add_user,
                                  "saltstack")
예제 #2
0
    def test_add_user(self):
        '''
        Test if it add a rabbitMQ user via rabbitmqctl
        user_add <user> <password>
        '''
        mock_run = MagicMock(return_value='saltstack')
        with patch.dict(rabbitmq.__salt__, {'cmd.run': mock_run}):
            self.assertDictEqual(rabbitmq.add_user('saltstack'),
                                 {'Added': 'saltstack'})

        mock_run = MagicMock(return_value='Error')
        with patch.dict(rabbitmq.__salt__, {'cmd.run': mock_run}):
            with patch.object(rabbitmq, 'clear_password',
                              return_value={'Error': 'Error', 'retcode': 1}):
                self.assertDictEqual(rabbitmq.add_user('saltstack'),
                                     {'Error': {'Error': 'Error',
                                                'retcode': 1}})
예제 #3
0
    def test_add_user(self):
        '''
        Test if it add a rabbitMQ user via rabbitmqctl
        user_add <user> <password>
        '''
        mock_run = MagicMock(return_value='saltstack')
        with patch.dict(rabbitmq.__salt__, {'cmd.run': mock_run}):
            self.assertDictEqual(rabbitmq.add_user('saltstack'),
                                 {'Added': 'saltstack'})

        mock_run = MagicMock(return_value='Error')
        with patch.dict(rabbitmq.__salt__, {'cmd.run': mock_run}):
            with patch.object(rabbitmq, 'clear_password',
                              return_value={'Error': 'Error', 'retcode': 1}):
                self.assertDictEqual(rabbitmq.add_user('saltstack'),
                                     {'Error': {'Error': 'Error',
                                                'retcode': 1}})
예제 #4
0
    def test_add_user(self):
        '''
        Test if it add a rabbitMQ user via rabbitmqctl
        user_add <user> <password>
        '''
        mock_run = MagicMock(return_value={'retcode': 0, 'stdout': 'saltstack', 'stderr': ''})
        with patch.dict(rabbitmq.__salt__, {'cmd.run_all': mock_run}):
            self.assertDictEqual(rabbitmq.add_user('saltstack'),
                                 {'Added': 'saltstack'})

        mock_run = MagicMock(return_value='Error')
        with patch.dict(rabbitmq.__salt__, {'cmd.run_all': mock_run}):
            with patch.object(rabbitmq, 'clear_password',
                              return_value={'Error': 'Error', 'retcode': 1}):
                self.assertRaises(CommandExecutionError, rabbitmq.add_user, 'saltstack')
예제 #5
0
    def test_add_user(self):
        '''
        Test if it add a rabbitMQ user via rabbitmqctl
        user_add <user> <password>
        '''
        mock_run = MagicMock(return_value={'retcode': 0, 'stdout': 'saltstack', 'stderr': ''})
        with patch.dict(rabbitmq.__salt__, {'cmd.run_all': mock_run}):
            self.assertDictEqual(rabbitmq.add_user('saltstack'),
                                 {'Added': 'saltstack'})

        mock_run = MagicMock(return_value='Error')
        with patch.dict(rabbitmq.__salt__, {'cmd.run_all': mock_run}):
            with patch.object(rabbitmq, 'clear_password',
                              return_value={'Error': 'Error', 'retcode': 1}):
                self.assertRaises(CommandExecutionError, rabbitmq.add_user, 'saltstack')