예제 #1
0
 def test_list_users(self):
     '''
     Test if it return a list of users based off of rabbitmqctl user_list.
     '''
     mock_run = MagicMock(return_value='saltstack')
     with patch.dict(rabbitmq.__salt__, {'cmd.run': mock_run}):
         self.assertDictEqual(rabbitmq.list_users(), {})
예제 #2
0
 def test_list_users(self):
     '''
     Test if it return a list of users based off of rabbitmqctl user_list.
     '''
     mock_run = MagicMock(return_value='Listing users ...\nguest\t[administrator]\n')
     with patch.dict(rabbitmq.__salt__, {'cmd.run': mock_run}):
         self.assertDictEqual(rabbitmq.list_users(), {'guest': set(['administrator'])})
예제 #3
0
 def test_list_users(self):
     '''
     Test if it return a list of users based off of rabbitmqctl user_list.
     '''
     mock_run = MagicMock(return_value='saltstack')
     with patch.dict(rabbitmq.__salt__, {'cmd.run': mock_run}):
         self.assertDictEqual(rabbitmq.list_users(), {})
예제 #4
0
 def test_list_users(self):
     '''
     Test if it return a list of users based off of rabbitmqctl user_list.
     '''
     mock_run = MagicMock(return_value='Listing users ...\nguest\t[administrator]\n')
     with patch.dict(rabbitmq.__salt__, {'cmd.run': mock_run}):
         self.assertDictEqual(rabbitmq.list_users(), {'guest': set(['administrator'])})
예제 #5
0
 def test_list_users_rabbitmq3(self):
     '''
     Test if it return a list of users based off of rabbitmqctl user_list.
     '''
     mock_run = MagicMock(return_value={'retcode': 0, 'stdout': 'Listing users ...\nguest\t[administrator user]\n', 'stderr': ''})
     with patch.dict(rabbitmq.__salt__, {'cmd.run_all': mock_run}):
         self.assertDictEqual(rabbitmq.list_users(), {'guest': ['administrator', 'user']})
예제 #6
0
 def test_list_users_rabbitmq3(self):
     '''
     Test if it return a list of users based off of rabbitmqctl user_list.
     '''
     mock_run = MagicMock(return_value={
         'retcode': 0,
         'stdout': 'guest\t[administrator user]\r\nother\t[a b]\r\n',
         'stderr': ''
     })
     with patch.dict(rabbitmq.__salt__, {'cmd.run_all': mock_run}):
         self.assertDictEqual(rabbitmq.list_users(), {'guest': ['administrator', 'user'], 'other': ['a', 'b']})
예제 #7
0
 def test_list_users_with_warning(self):
     '''
     Test if having a leading WARNING returns the user_list anyway.
     '''
     rtn_val = '\n'.join([
         'WARNING: ignoring /etc/rabbitmq/rabbitmq.conf -- location has moved to /etc/rabbitmq/rabbitmq-env.conf',
         'Listing users ...',
         'guest\t[administrator]\n',
     ])
     mock_run = MagicMock(return_value=rtn_val)
     with patch.dict(rabbitmq.__salt__, {'cmd.run': mock_run}):
         self.assertDictEqual(rabbitmq.list_users(), {'guest': set(['administrator'])})
예제 #8
0
 def test_list_users_with_warning_rabbitmq3(self):
     '''
     Test if having a leading WARNING returns the user_list anyway.
     '''
     rtn_stdout = '\n'.join([
         'WARNING: ignoring /etc/rabbitmq/rabbitmq.conf -- location has moved to /etc/rabbitmq/rabbitmq-env.conf',
         'Listing users ...',
         'guest\t[administrator user]\n',
     ])
     mock_run = MagicMock(return_value={'retcode': 0, 'stdout': rtn_stdout, 'stderr': ''})
     with patch.dict(rabbitmq.__salt__, {'cmd.run_all': mock_run}):
         self.assertDictEqual(rabbitmq.list_users(), {'guest': ['administrator', 'user']})
예제 #9
0
 def test_list_users_rabbitmq2(self):
     '''
     Test if it return a list of users based off of rabbitmqctl user_list.
     '''
     mock_run = MagicMock(return_value={
         'retcode': 0,
         'stdout': 'Listing users ...\nguest\t[administrator, user]\njustAnAdmin\t[administrator]\n',
         'stderr': '',
     })
     with patch.dict(rabbitmq.__salt__, {'cmd.run_all': mock_run}):
         self.assertDictEqual(rabbitmq.list_users(),
                              {'guest': ['administrator', 'user'], 'justAnAdmin': ['administrator']})
예제 #10
0
 def test_list_users_with_warning_rabbitmq3(self):
     '''
     Test if having a leading WARNING returns the user_list anyway.
     '''
     rtn_stdout = '\n'.join([
         'WARNING: ignoring /etc/rabbitmq/rabbitmq.conf -- location has moved to /etc/rabbitmq/rabbitmq-env.conf',
         'Listing users ...',
         'guest\t[administrator user]\n',
     ])
     mock_run = MagicMock(return_value={'retcode': 0, 'stdout': rtn_stdout, 'stderr': ''})
     with patch.dict(rabbitmq.__salt__, {'cmd.run_all': mock_run}):
         self.assertDictEqual(rabbitmq.list_users(), {'guest': ['administrator', 'user']})
예제 #11
0
 def test_list_users_with_warning(self):
     '''
     Test if having a leading WARNING returns the user_list anyway.
     '''
     rtn_val = '\n'.join([
         'WARNING: ignoring /etc/rabbitmq/rabbitmq.conf -- location has moved to /etc/rabbitmq/rabbitmq-env.conf',
         'Listing users ...',
         'guest\t[administrator]\n',
     ])
     mock_run = MagicMock(return_value=rtn_val)
     with patch.dict(rabbitmq.__salt__, {'cmd.run': mock_run}):
         self.assertDictEqual(rabbitmq.list_users(),
                              {'guest': set(['administrator'])})
예제 #12
0
def test_list_users_rabbitmq3():
    """
    Test if it return a list of users based off of rabbitmqctl user_list.
    """
    mock_run = MagicMock(
        return_value={
            "retcode": 0,
            "stdout": "guest\t[administrator user]\r\nother\t[a b]\r\n",
            "stderr": "",
        })
    with patch.dict(rabbitmq.__salt__, {"cmd.run_all": mock_run}):
        assert rabbitmq.list_users() == {
            "guest": ["administrator", "user"],
            "other": ["a", "b"],
        }
예제 #13
0
def test_list_users_with_warning_rabbitmq3():
    """
    Test if having a leading WARNING returns the user_list anyway.
    """
    rtn_stdout = "\n".join([
        "WARNING: ignoring /etc/rabbitmq/rabbitmq.conf -- location has moved to /etc/rabbitmq/rabbitmq-env.conf",
        "Listing users ...",
        "guest\t[administrator user]\n",
    ])
    mock_run = MagicMock(return_value={
        "retcode": 0,
        "stdout": rtn_stdout,
        "stderr": ""
    })
    with patch.dict(rabbitmq.__salt__, {"cmd.run_all": mock_run}):
        assert rabbitmq.list_users() == {"guest": ["administrator", "user"]}
예제 #14
0
def test_list_users_rabbitmq2():
    """
    Test if it return a list of users based off of rabbitmqctl user_list.
    """
    mock_run = MagicMock(
        return_value={
            "retcode": 0,
            "stdout":
            "Listing users ...\nguest\t[administrator, user]\njustAnAdmin\t[administrator]\n",
            "stderr": "",
        })
    with patch.dict(rabbitmq.__salt__, {"cmd.run_all": mock_run}):
        assert rabbitmq.list_users() == {
            "guest": ["administrator", "user"],
            "justAnAdmin": ["administrator"],
        }