test_client.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. # -*- coding: utf-8 -*-
  2. from __future__ import absolute_import, print_function, unicode_literals
  3. import pytest
  4. import salt.auth
  5. import salt.utils.platform
  6. import salt.wheel
  7. from tests.support.mixins import AdaptedConfigurationTestCaseMixin
  8. from tests.support.unit import TestCase, skipIf
  9. @pytest.mark.windows_whitelisted
  10. class WheelModuleTest(TestCase, AdaptedConfigurationTestCaseMixin):
  11. eauth_creds = {
  12. "username": "saltdev_auto",
  13. "password": "saltdev",
  14. "eauth": "auto",
  15. }
  16. def setUp(self):
  17. """
  18. Configure an eauth user to test with
  19. """
  20. self.wheel = salt.wheel.Wheel(dict(self.get_config("client_config")))
  21. def tearDown(self):
  22. del self.wheel
  23. @skipIf(True, "SLOWTEST skip")
  24. def test_master_call(self):
  25. """
  26. Test executing master_call with lowdata
  27. The choice of using key.list_all for this is arbitrary and should be
  28. changed to some mocked function that is more testing friendly.
  29. """
  30. low = {"client": "wheel", "fun": "key.list_all", "print_event": False}
  31. low.update(self.eauth_creds)
  32. self.wheel.master_call(**low)
  33. def test_token(self):
  34. """
  35. Test executing master_call with lowdata
  36. The choice of using key.list_all for this is arbitrary and should be
  37. changed to some mocked function that is more testing friendly.
  38. """
  39. auth = salt.auth.LoadAuth(dict(self.get_config("client_config")))
  40. token = auth.mk_token(self.eauth_creds)
  41. token = auth.mk_token(
  42. {"username": "saltdev_auto", "password": "saltdev", "eauth": "auto"}
  43. )
  44. self.wheel.master_call(
  45. **{
  46. "client": "wheel",
  47. "fun": "key.list_all",
  48. "token": token["token"],
  49. "print_event": False,
  50. }
  51. )
  52. @skipIf(True, "SLOWTEST skip")
  53. def test_cmd_sync(self):
  54. low = {
  55. "client": "wheel",
  56. "fun": "key.list_all",
  57. "print_event": False,
  58. }
  59. low.update(self.eauth_creds)
  60. self.wheel.cmd_sync(low)
  61. # Remove this skipIf when Issue #39616 is resolved
  62. # https://github.com/saltstack/salt/issues/39616
  63. @skipIf(
  64. salt.utils.platform.is_windows(),
  65. "Causes pickling error on Windows: Issue #39616",
  66. )
  67. def test_cmd_async(self):
  68. low = {
  69. "client": "wheel_async",
  70. "fun": "key.list_all",
  71. "print_event": False,
  72. }
  73. low.update(self.eauth_creds)
  74. self.wheel.cmd_async(low)
  75. @skipIf(True, "SLOWTEST skip")
  76. def test_cmd_sync_w_arg(self):
  77. low = {
  78. "fun": "key.finger",
  79. "match": "*",
  80. "print_event": False,
  81. }
  82. low.update(self.eauth_creds)
  83. ret = self.wheel.cmd_sync(low)
  84. self.assertIn("return", ret.get("data", {}))
  85. def test_wildcard_auth(self):
  86. low = {
  87. "username": "the_s0und_of_t3ch",
  88. "password": "willrockyou",
  89. "eauth": "auto",
  90. "fun": "key.list_all",
  91. "print_event": False,
  92. }
  93. self.wheel.cmd_sync(low)