2013-11-27 11:19:24 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2012-10-19 10:42:01 +00:00
|
|
|
'''
|
|
|
|
Tests for the rabbitmq state
|
|
|
|
'''
|
2013-06-27 12:47:53 +00:00
|
|
|
# Import python libs
|
2014-11-21 19:05:13 +00:00
|
|
|
from __future__ import absolute_import
|
2012-10-19 10:42:01 +00:00
|
|
|
import os
|
2013-06-25 08:24:45 +00:00
|
|
|
|
2013-06-27 12:47:53 +00:00
|
|
|
# Import Salt Testing libs
|
2017-02-27 15:59:04 +00:00
|
|
|
import tests.integration as integration
|
2017-04-02 16:09:47 +00:00
|
|
|
from tests.support.mixins import SaltReturnAssertsMixin
|
2012-10-19 10:42:01 +00:00
|
|
|
|
|
|
|
|
2017-04-02 16:09:47 +00:00
|
|
|
class RabbitUserTestCase(integration.ModuleCase, SaltReturnAssertsMixin):
|
2012-10-19 10:42:01 +00:00
|
|
|
'''
|
2012-10-19 15:07:31 +00:00
|
|
|
Validate the rabbitmq user states.
|
2012-10-19 10:42:01 +00:00
|
|
|
'''
|
|
|
|
def setUp(self):
|
|
|
|
super(RabbitUserTestCase, self).setUp()
|
|
|
|
rabbit_installed = self.run_function('cmd.has_exec', ['rabbitmqctl'])
|
|
|
|
|
|
|
|
if not rabbit_installed:
|
|
|
|
self.skipTest('rabbitmq-server not installed')
|
|
|
|
if os.geteuid() != 0:
|
|
|
|
self.skipTest('You must be root to run this test')
|
|
|
|
|
2012-10-19 14:05:35 +00:00
|
|
|
def test_present(self):
|
2012-10-19 10:42:01 +00:00
|
|
|
'''
|
2012-10-19 15:07:31 +00:00
|
|
|
rabbitmq_user.present null_name
|
2012-10-19 10:42:01 +00:00
|
|
|
'''
|
2012-10-19 15:28:38 +00:00
|
|
|
ret = self.run_state(
|
2012-12-07 17:01:31 +00:00
|
|
|
'rabbitmq_user.present', name='null_name', test=True
|
|
|
|
)
|
2012-12-07 19:05:19 +00:00
|
|
|
self.assertSaltFalseReturn(ret)
|
2016-07-28 14:37:37 +00:00
|
|
|
self.assertInSaltComment('User \'null_name\' is set to be created', ret)
|
2012-10-19 15:07:31 +00:00
|
|
|
|
|
|
|
def absent(self):
|
|
|
|
'''
|
|
|
|
rabbitmq_user.absent null_name
|
|
|
|
'''
|
2012-10-19 15:28:38 +00:00
|
|
|
ret = self.run_state(
|
2012-12-07 17:01:31 +00:00
|
|
|
'rabbitmq_user.absent', name='null_name', test=True
|
|
|
|
)
|
|
|
|
self.assertSaltFalseReturn(ret)
|