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 Testing libs
  5. from tests.support.mixins import LoaderModuleMockMixin
  6. from tests.support.unit import TestCase
  7. from tests.support.mock import patch
  8. # Import Salt libs
  9. import salt.fileserver.hgfs as hgfs
  10. class HgfsFileTest(TestCase, LoaderModuleMockMixin):
  11. def setup_loader_modules(self):
  12. return {
  13. hgfs: {}
  14. }
  15. def test_env_is_exposed(self):
  16. '''
  17. test _env_is_exposed method when
  18. base is in whitelist
  19. '''
  20. with patch.dict(hgfs.__opts__,
  21. {'hgfs_saltenv_whitelist': 'base',
  22. 'hgfs_saltenv_blacklist': ''}):
  23. assert hgfs._env_is_exposed('base')
  24. def test_env_is_exposed_blacklist(self):
  25. '''
  26. test _env_is_exposed method when
  27. base is in blacklist
  28. '''
  29. with patch.dict(hgfs.__opts__,
  30. {'hgfs_saltenv_whitelist': '',
  31. 'hgfs_saltenv_blacklist': 'base'}):
  32. assert not hgfs._env_is_exposed('base')