1
0

test_config.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # -*- coding: utf-8 -*-
  2. """
  3. Validate the config system
  4. """
  5. from __future__ import absolute_import
  6. import pytest
  7. from tests.support.case import ModuleCase
  8. from tests.support.helpers import slowTest
  9. @pytest.mark.windows_whitelisted
  10. class ConfigTest(ModuleCase):
  11. """
  12. Test config routines
  13. """
  14. @slowTest
  15. def test_valid_file_proto(self):
  16. """
  17. test config.valid_file_proto
  18. """
  19. self.assertTrue(self.run_function("config.valid_fileproto", ["salt://"]))
  20. self.assertTrue(self.run_function("config.valid_fileproto", ["file://"]))
  21. self.assertTrue(self.run_function("config.valid_fileproto", ["http://"]))
  22. self.assertTrue(self.run_function("config.valid_fileproto", ["https://"]))
  23. self.assertTrue(self.run_function("config.valid_fileproto", ["ftp://"]))
  24. self.assertTrue(self.run_function("config.valid_fileproto", ["s3://"]))
  25. self.assertTrue(self.run_function("config.valid_fileproto", ["swift://"]))
  26. self.assertFalse(self.run_function("config.valid_fileproto", ["cheese://"]))
  27. @slowTest
  28. def test_backup_mode(self):
  29. """
  30. test config.backup_mode
  31. """
  32. self.assertEqual(self.run_function("config.backup_mode", ["minion"]), "minion")
  33. @slowTest
  34. def test_manage_mode(self):
  35. """
  36. test config.manage_mode
  37. """
  38. # This function is generally only used with cross calls, the yaml
  39. # interpreter is breaking it for remote calls
  40. # The correct standard is the four digit form.
  41. self.assertEqual(self.run_function("config.manage_mode", ['"775"']), "0775")
  42. self.assertEqual(self.run_function("config.manage_mode", ['"1775"']), "1775")
  43. self.assertEqual(self.run_function("config.manage_mode", ['"0775"']), "0775")
  44. self.assertEqual(self.run_function("config.manage_mode", ['"01775"']), "1775")
  45. self.assertEqual(self.run_function("config.manage_mode", ['"0"']), "0000")
  46. self.assertEqual(self.run_function("config.manage_mode", ["775"]), "0775")
  47. self.assertEqual(self.run_function("config.manage_mode", ["1775"]), "1775")
  48. self.assertEqual(self.run_function("config.manage_mode", ["0"]), "0000")
  49. @slowTest
  50. def test_option(self):
  51. """
  52. test config.option
  53. """
  54. # Minion opt
  55. self.assertEqual(
  56. self.run_function("config.option", ["master_port"]),
  57. self.get_config("minion")["master_port"],
  58. )
  59. # pillar conf opt
  60. self.assertEqual(self.run_function("config.option", ["ext_spam"]), "eggs")
  61. @slowTest
  62. def test_get(self):
  63. """
  64. Test option.get
  65. """
  66. # Check pillar get
  67. self.assertEqual(self.run_function("config.get", ["level1:level2"]), "foo")
  68. # Check master config
  69. self.assertEqual(
  70. self.run_function("config.get", ["config_opt:layer2"]), "kosher"
  71. )
  72. # Check minion config
  73. self.assertEqual(self.run_function("config.get", ["config_test:spam"]), "eggs")