2012-03-29 00:37:05 +00:00
|
|
|
import integration
|
2012-05-05 14:09:23 +00:00
|
|
|
|
2012-03-29 00:37:05 +00:00
|
|
|
|
|
|
|
class PublishModuleTest(integration.ModuleCase):
|
|
|
|
'''
|
|
|
|
Validate the publish module
|
|
|
|
'''
|
|
|
|
def test_publish(self):
|
|
|
|
'''
|
|
|
|
publish.publish
|
|
|
|
'''
|
|
|
|
ret = self.run_function('publish.publish', ['minion', 'test.ping'])
|
|
|
|
self.assertTrue(ret['minion'])
|
|
|
|
|
|
|
|
def test_full_data(self):
|
|
|
|
'''
|
|
|
|
publish.full_data
|
|
|
|
'''
|
|
|
|
ret = self.run_function(
|
|
|
|
'publish.full_data',
|
|
|
|
[
|
|
|
|
'minion',
|
|
|
|
'test.fib',
|
|
|
|
['40']
|
|
|
|
]
|
|
|
|
)
|
|
|
|
self.assertEqual(ret['minion']['ret'][0][-1], 34)
|
2012-05-05 14:09:23 +00:00
|
|
|
|
2012-04-01 19:29:23 +00:00
|
|
|
def test_kwarg(self):
|
|
|
|
'''
|
|
|
|
Verify that the pub data is making it to the minion functions
|
|
|
|
'''
|
|
|
|
ret = self.run_function(
|
|
|
|
'publish.full_data',
|
|
|
|
[
|
|
|
|
'minion',
|
|
|
|
'test.kwarg',
|
|
|
|
'cheese=spam',
|
|
|
|
]
|
|
|
|
)['minion']['ret']
|
2012-05-10 04:42:38 +00:00
|
|
|
check_true = (
|
|
|
|
'cheese',
|
|
|
|
'__pub_arg',
|
|
|
|
'__pub_fun',
|
|
|
|
'__pub_id',
|
|
|
|
'__pub_jid',
|
|
|
|
'__pub_ret',
|
|
|
|
'__pub_tgt',
|
|
|
|
'__pub_tgt_type',
|
|
|
|
)
|
|
|
|
for name in check_true:
|
|
|
|
self.assertTrue(name in ret)
|
|
|
|
|
2012-05-29 16:40:20 +00:00
|
|
|
self.assertEqual(ret['cheese'], 'spam')
|
2012-07-23 19:00:54 +00:00
|
|
|
self.assertEqual(ret['__pub_arg'], ['cheese=spam'])
|
2012-05-29 16:40:20 +00:00
|
|
|
self.assertEqual(ret['__pub_id'], 'minion')
|
2012-04-01 19:29:23 +00:00
|
|
|
self.assertEqual(ret['__pub_fun'], 'test.kwarg')
|
|
|
|
|
2012-03-29 00:47:10 +00:00
|
|
|
def test_reject_minion(self):
|
|
|
|
'''
|
|
|
|
Test bad authentication
|
|
|
|
'''
|
|
|
|
ret = self.run_function(
|
|
|
|
'publish.publish',
|
|
|
|
[
|
|
|
|
'minion',
|
|
|
|
'cmd.run',
|
|
|
|
['echo foo']
|
|
|
|
]
|
|
|
|
)
|
|
|
|
self.assertEqual(ret, {})
|
2012-05-05 14:09:23 +00:00
|
|
|
|
2012-07-20 06:21:01 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
from integration import run_tests
|
|
|
|
run_tests(PublishModuleTest)
|