test_hgfs.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # -*- coding: utf-8 -*-
  2. # Import Python libs
  3. from __future__ import absolute_import, print_function, unicode_literals
  4. # Import Salt libs
  5. import salt.fileserver.hgfs as hgfs
  6. # Import Salt Testing libs
  7. from tests.support.mixins import LoaderModuleMockMixin
  8. from tests.support.mock import patch
  9. from tests.support.unit import TestCase
  10. class HgfsFileTest(TestCase, LoaderModuleMockMixin):
  11. def setup_loader_modules(self):
  12. return {hgfs: {}}
  13. def test_env_is_exposed(self):
  14. """
  15. test _env_is_exposed method when
  16. base is in whitelist
  17. """
  18. with patch.dict(
  19. hgfs.__opts__,
  20. {"hgfs_saltenv_whitelist": "base", "hgfs_saltenv_blacklist": ""},
  21. ):
  22. assert hgfs._env_is_exposed("base")
  23. def test_env_is_exposed_blacklist(self):
  24. """
  25. test _env_is_exposed method when
  26. base is in blacklist
  27. """
  28. with patch.dict(
  29. hgfs.__opts__,
  30. {"hgfs_saltenv_whitelist": "", "hgfs_saltenv_blacklist": "base"},
  31. ):
  32. assert not hgfs._env_is_exposed("base")