123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- # coding: utf-8
- from __future__ import absolute_import, print_function, unicode_literals
- import pytest
- import salt.runner
- from tests.support.mixins import AdaptedConfigurationTestCaseMixin
- from tests.support.unit import TestCase, skipIf
- @pytest.mark.windows_whitelisted
- class RunnerModuleTest(TestCase, AdaptedConfigurationTestCaseMixin):
- # This is really an integration test since it needs a salt-master running
- eauth_creds = {
- "username": "saltdev_auto",
- "password": "saltdev",
- "eauth": "auto",
- }
- def setUp(self):
- """
- Configure an eauth user to test with
- """
- self.runner = salt.runner.RunnerClient(self.get_config("client_config"))
- @skipIf(True, "SLOWTEST skip")
- def test_eauth(self):
- """
- Test executing master_call with lowdata
- The choice of using error.error for this is arbitrary and should be
- changed to some mocked function that is more testing friendly.
- """
- low = {
- "client": "runner",
- "fun": "error.error",
- }
- low.update(self.eauth_creds)
- self.runner.master_call(**low)
- @skipIf(True, "SLOWTEST skip")
- def test_token(self):
- """
- Test executing master_call with lowdata
- The choice of using error.error for this is arbitrary and should be
- changed to some mocked function that is more testing friendly.
- """
- import salt.auth
- auth = salt.auth.LoadAuth(self.get_config("client_config"))
- token = auth.mk_token(self.eauth_creds)
- self.runner.master_call(
- **{"client": "runner", "fun": "error.error", "token": token["token"]}
- )
- @skipIf(True, "SLOWTEST skip")
- def test_cmd_sync(self):
- low = {
- "client": "runner",
- "fun": "error.error",
- }
- low.update(self.eauth_creds)
- self.runner.cmd_sync(low)
- @skipIf(True, "SLOWTEST skip")
- def test_cmd_async(self):
- low = {
- "client": "runner",
- "fun": "error.error",
- }
- low.update(self.eauth_creds)
- self.runner.cmd_async(low)
- @skipIf(True, "SLOWTEST skip")
- def test_cmd_sync_w_arg(self):
- low = {
- "fun": "test.arg",
- "foo": "Foo!",
- "bar": "Bar!",
- }
- low.update(self.eauth_creds)
- ret = self.runner.cmd_sync(low)
- self.assertEqual(ret["kwargs"]["foo"], "Foo!")
- self.assertEqual(ret["kwargs"]["bar"], "Bar!")
- @skipIf(True, "SLOWTEST skip")
- def test_wildcard_auth(self):
- low = {
- "username": "the_s0und_of_t3ch",
- "password": "willrockyou",
- "eauth": "auto",
- "fun": "test.arg",
- "foo": "Foo!",
- "bar": "Bar!",
- }
- self.runner.cmd_sync(low)
- @skipIf(True, "SLOWTEST skip")
- def test_full_return_kwarg(self):
- low = {"fun": "test.arg"}
- low.update(self.eauth_creds)
- ret = self.runner.cmd_sync(low, full_return=True)
- self.assertIn("success", ret["data"])
- @skipIf(True, "SLOWTEST skip")
- def test_cmd_sync_arg_kwarg_parsing(self):
- low = {
- "client": "runner",
- "fun": "test.arg",
- "arg": ["foo", "bar=off", "baz={qux: 123}"],
- "kwarg": {"quux": "Quux"},
- "quuz": "on",
- }
- low.update(self.eauth_creds)
- ret = self.runner.cmd_sync(low)
- self.assertEqual(
- ret,
- {
- "args": ["foo"],
- "kwargs": {
- "bar": False,
- "baz": {"qux": 123},
- "quux": "Quux",
- "quuz": "on",
- },
- },
- )
- @skipIf(True, "SLOWTEST skip")
- def test_invalid_kwargs_are_ignored(self):
- low = {
- "client": "runner",
- "fun": "test.metasyntactic",
- "thiskwargisbad": "justpretendimnothere",
- }
- low.update(self.eauth_creds)
- ret = self.runner.cmd_sync(low)
- self.assertEqual(ret[0], "foo")
|