test_config.py 3.2 KB

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