mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Why do need the system grains here?! This is an expensive call.
This commit is contained in:
parent
f82fa73fd7
commit
104f7a71f2
@ -16,16 +16,15 @@ from salt.exceptions import CommandExecutionError
|
|||||||
# Import Salt Testing Libs
|
# Import Salt Testing Libs
|
||||||
import tests.integration as integration
|
import tests.integration as integration
|
||||||
from tests.support.unit import skipIf
|
from tests.support.unit import skipIf
|
||||||
from tests.support.helpers import (
|
from tests.support.helpers import destructiveTest
|
||||||
destructiveTest,
|
|
||||||
requires_system_grains
|
|
||||||
)
|
|
||||||
|
|
||||||
# Module Variables
|
# Module Variables
|
||||||
ASSIGN_CMD = 'net.inet.icmp.icmplim'
|
ASSIGN_CMD = 'net.inet.icmp.icmplim'
|
||||||
CONFIG = '/etc/sysctl.conf'
|
CONFIG = '/etc/sysctl.conf'
|
||||||
|
|
||||||
|
|
||||||
|
@destructiveTest
|
||||||
|
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
|
||||||
class DarwinSysctlModuleTest(integration.ModuleCase):
|
class DarwinSysctlModuleTest(integration.ModuleCase):
|
||||||
'''
|
'''
|
||||||
Integration tests for the darwin_sysctl module
|
Integration tests for the darwin_sysctl module
|
||||||
@ -58,10 +57,7 @@ class DarwinSysctlModuleTest(integration.ModuleCase):
|
|||||||
raise CommandExecutionError(msg.format(CONFIG))
|
raise CommandExecutionError(msg.format(CONFIG))
|
||||||
os.remove(CONFIG)
|
os.remove(CONFIG)
|
||||||
|
|
||||||
@destructiveTest
|
def test_assign(self):
|
||||||
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
|
|
||||||
@requires_system_grains
|
|
||||||
def test_assign(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests assigning a single sysctl parameter
|
Tests assigning a single sysctl parameter
|
||||||
'''
|
'''
|
||||||
@ -80,10 +76,7 @@ class DarwinSysctlModuleTest(integration.ModuleCase):
|
|||||||
self.run_function('sysctl.assign', [ASSIGN_CMD, self.val])
|
self.run_function('sysctl.assign', [ASSIGN_CMD, self.val])
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@destructiveTest
|
def test_persist_new_file(self):
|
||||||
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
|
|
||||||
@requires_system_grains
|
|
||||||
def test_persist_new_file(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests assigning a sysctl value to a system without a sysctl.conf file
|
Tests assigning a sysctl value to a system without a sysctl.conf file
|
||||||
'''
|
'''
|
||||||
@ -102,10 +95,7 @@ class DarwinSysctlModuleTest(integration.ModuleCase):
|
|||||||
os.remove(CONFIG)
|
os.remove(CONFIG)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@destructiveTest
|
def test_persist_already_set(self):
|
||||||
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
|
|
||||||
@requires_system_grains
|
|
||||||
def test_persist_already_set(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests assigning a sysctl value that is already set in sysctl.conf file
|
Tests assigning a sysctl value that is already set in sysctl.conf file
|
||||||
'''
|
'''
|
||||||
@ -123,10 +113,7 @@ class DarwinSysctlModuleTest(integration.ModuleCase):
|
|||||||
os.remove(CONFIG)
|
os.remove(CONFIG)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@destructiveTest
|
def test_persist_apply_change(self):
|
||||||
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
|
|
||||||
@requires_system_grains
|
|
||||||
def test_persist_apply_change(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests assigning a sysctl value and applying the change to system
|
Tests assigning a sysctl value and applying the change to system
|
||||||
'''
|
'''
|
||||||
@ -190,10 +177,7 @@ class DarwinSysctlModuleTest(integration.ModuleCase):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@destructiveTest
|
def tearDown(self):
|
||||||
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
|
|
||||||
@requires_system_grains
|
|
||||||
def tearDown(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Clean up after tests
|
Clean up after tests
|
||||||
'''
|
'''
|
||||||
|
@ -8,7 +8,6 @@ import tests.integration as integration
|
|||||||
from tests.support.unit import skipIf
|
from tests.support.unit import skipIf
|
||||||
from tests.support.helpers import (
|
from tests.support.helpers import (
|
||||||
requires_salt_modules,
|
requires_salt_modules,
|
||||||
requires_system_grains,
|
|
||||||
destructiveTest,
|
destructiveTest,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -25,22 +24,19 @@ def _find_new_locale(current_locale):
|
|||||||
@skipIf(salt.utils.is_windows(), 'minion is windows')
|
@skipIf(salt.utils.is_windows(), 'minion is windows')
|
||||||
@requires_salt_modules('locale')
|
@requires_salt_modules('locale')
|
||||||
class LocaleModuleTest(integration.ModuleCase):
|
class LocaleModuleTest(integration.ModuleCase):
|
||||||
@requires_system_grains
|
def test_get_locale(self):
|
||||||
def test_get_locale(self, grains):
|
|
||||||
locale = self.run_function('locale.get_locale')
|
locale = self.run_function('locale.get_locale')
|
||||||
self.assertNotEqual(None, locale)
|
self.assertNotEqual(None, locale)
|
||||||
|
|
||||||
@destructiveTest
|
@destructiveTest
|
||||||
@requires_system_grains
|
def test_gen_locale(self):
|
||||||
def test_gen_locale(self, grains):
|
|
||||||
locale = self.run_function('locale.get_locale')
|
locale = self.run_function('locale.get_locale')
|
||||||
new_locale = _find_new_locale(locale)
|
new_locale = _find_new_locale(locale)
|
||||||
ret = self.run_function('locale.gen_locale', [new_locale])
|
ret = self.run_function('locale.gen_locale', [new_locale])
|
||||||
self.assertEqual(True, ret)
|
self.assertEqual(True, ret)
|
||||||
|
|
||||||
@destructiveTest
|
@destructiveTest
|
||||||
@requires_system_grains
|
def test_set_locale(self):
|
||||||
def test_set_locale(self, grains):
|
|
||||||
original_locale = self.run_function('locale.get_locale')
|
original_locale = self.run_function('locale.get_locale')
|
||||||
locale_to_set = _find_new_locale(original_locale)
|
locale_to_set = _find_new_locale(original_locale)
|
||||||
self.run_function('locale.gen_locale', [locale_to_set])
|
self.run_function('locale.gen_locale', [locale_to_set])
|
||||||
|
@ -10,10 +10,7 @@ import os
|
|||||||
# Import Salt Testing Libs
|
# Import Salt Testing Libs
|
||||||
import tests.integration as integration
|
import tests.integration as integration
|
||||||
from tests.support.unit import skipIf
|
from tests.support.unit import skipIf
|
||||||
from tests.support.helpers import (
|
from tests.support.helpers import destructiveTest
|
||||||
destructiveTest,
|
|
||||||
requires_system_grains
|
|
||||||
)
|
|
||||||
|
|
||||||
OSA_SCRIPT = '/usr/bin/osascript'
|
OSA_SCRIPT = '/usr/bin/osascript'
|
||||||
|
|
||||||
@ -54,8 +51,7 @@ class MacAssistiveTest(integration.ModuleCase):
|
|||||||
if smile_bundle_present:
|
if smile_bundle_present:
|
||||||
self.run_function('assistive.remove', [smile_bundle])
|
self.run_function('assistive.remove', [smile_bundle])
|
||||||
|
|
||||||
@requires_system_grains
|
def test_install_and_remove(self):
|
||||||
def test_install_and_remove(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests installing and removing a bundled ID or command to use assistive access.
|
Tests installing and removing a bundled ID or command to use assistive access.
|
||||||
'''
|
'''
|
||||||
@ -67,8 +63,7 @@ class MacAssistiveTest(integration.ModuleCase):
|
|||||||
self.run_function('assistive.remove', [new_bundle])
|
self.run_function('assistive.remove', [new_bundle])
|
||||||
)
|
)
|
||||||
|
|
||||||
@requires_system_grains
|
def test_installed(self):
|
||||||
def test_installed(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests the True and False return of assistive.installed.
|
Tests the True and False return of assistive.installed.
|
||||||
'''
|
'''
|
||||||
@ -83,8 +78,7 @@ class MacAssistiveTest(integration.ModuleCase):
|
|||||||
self.run_function('assistive.installed', [OSA_SCRIPT])
|
self.run_function('assistive.installed', [OSA_SCRIPT])
|
||||||
)
|
)
|
||||||
|
|
||||||
@requires_system_grains
|
def test_enable(self):
|
||||||
def test_enable(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests setting the enabled status of a bundled ID or command.
|
Tests setting the enabled status of a bundled ID or command.
|
||||||
'''
|
'''
|
||||||
@ -106,8 +100,7 @@ class MacAssistiveTest(integration.ModuleCase):
|
|||||||
self.run_function('assistive.enabled', [OSA_SCRIPT])
|
self.run_function('assistive.enabled', [OSA_SCRIPT])
|
||||||
)
|
)
|
||||||
|
|
||||||
@requires_system_grains
|
def test_enabled(self):
|
||||||
def test_enabled(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests if a bundled ID or command is listed in assistive access returns True.
|
Tests if a bundled ID or command is listed in assistive access returns True.
|
||||||
'''
|
'''
|
||||||
|
@ -10,16 +10,15 @@ import os
|
|||||||
# Import Salt Testing Libs
|
# Import Salt Testing Libs
|
||||||
import tests.integration as integration
|
import tests.integration as integration
|
||||||
from tests.support.unit import skipIf
|
from tests.support.unit import skipIf
|
||||||
from tests.support.helpers import (
|
from tests.support.helpers import destructiveTest
|
||||||
destructiveTest,
|
|
||||||
requires_system_grains
|
|
||||||
)
|
|
||||||
|
|
||||||
DEFAULT_DOMAIN = 'com.apple.AppleMultitouchMouse'
|
DEFAULT_DOMAIN = 'com.apple.AppleMultitouchMouse'
|
||||||
DEFAULT_KEY = 'MouseHorizontalScroll'
|
DEFAULT_KEY = 'MouseHorizontalScroll'
|
||||||
DEFAULT_VALUE = '0'
|
DEFAULT_VALUE = '0'
|
||||||
|
|
||||||
|
|
||||||
|
@destructiveTest
|
||||||
|
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
|
||||||
class MacDefaultsModuleTest(integration.ModuleCase):
|
class MacDefaultsModuleTest(integration.ModuleCase):
|
||||||
'''
|
'''
|
||||||
Integration tests for the mac_default module
|
Integration tests for the mac_default module
|
||||||
@ -37,10 +36,7 @@ class MacDefaultsModuleTest(integration.ModuleCase):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@destructiveTest
|
def test_macdefaults_write_read(self):
|
||||||
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
|
|
||||||
@requires_system_grains
|
|
||||||
def test_macdefaults_write_read(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests that writes and reads macdefaults
|
Tests that writes and reads macdefaults
|
||||||
'''
|
'''
|
||||||
|
@ -10,12 +10,10 @@ import os
|
|||||||
# Import Salt Testing Libs
|
# Import Salt Testing Libs
|
||||||
import tests.integration as integration
|
import tests.integration as integration
|
||||||
from tests.support.unit import skipIf
|
from tests.support.unit import skipIf
|
||||||
from tests.support.helpers import (
|
from tests.support.helpers import destructiveTest
|
||||||
destructiveTest,
|
|
||||||
requires_system_grains
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
@destructiveTest
|
||||||
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
|
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
|
||||||
class MacDesktopTestCase(integration.ModuleCase):
|
class MacDesktopTestCase(integration.ModuleCase):
|
||||||
'''
|
'''
|
||||||
@ -34,17 +32,14 @@ class MacDesktopTestCase(integration.ModuleCase):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@requires_system_grains
|
def test_get_output_volume(self):
|
||||||
def test_get_output_volume(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests the return of get_output_volume.
|
Tests the return of get_output_volume.
|
||||||
'''
|
'''
|
||||||
ret = self.run_function('desktop.get_output_volume')
|
ret = self.run_function('desktop.get_output_volume')
|
||||||
self.assertIsNotNone(ret)
|
self.assertIsNotNone(ret)
|
||||||
|
|
||||||
@destructiveTest
|
def test_set_output_volume(self):
|
||||||
@requires_system_grains
|
|
||||||
def test_set_output_volume(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests the return of set_output_volume.
|
Tests the return of set_output_volume.
|
||||||
'''
|
'''
|
||||||
@ -59,9 +54,7 @@ class MacDesktopTestCase(integration.ModuleCase):
|
|||||||
# Set volume back to what it was before
|
# Set volume back to what it was before
|
||||||
self.run_function('desktop.set_output_volume', [current_vol])
|
self.run_function('desktop.set_output_volume', [current_vol])
|
||||||
|
|
||||||
@destructiveTest
|
def test_screensaver(self):
|
||||||
@requires_system_grains
|
|
||||||
def test_screensaver(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests the return of the screensaver function.
|
Tests the return of the screensaver function.
|
||||||
'''
|
'''
|
||||||
@ -69,9 +62,7 @@ class MacDesktopTestCase(integration.ModuleCase):
|
|||||||
self.run_function('desktop.screensaver')
|
self.run_function('desktop.screensaver')
|
||||||
)
|
)
|
||||||
|
|
||||||
@destructiveTest
|
def test_lock(self):
|
||||||
@requires_system_grains
|
|
||||||
def test_lock(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests the return of the lock function.
|
Tests the return of the lock function.
|
||||||
'''
|
'''
|
||||||
@ -79,9 +70,7 @@ class MacDesktopTestCase(integration.ModuleCase):
|
|||||||
self.run_function('desktop.lock')
|
self.run_function('desktop.lock')
|
||||||
)
|
)
|
||||||
|
|
||||||
@destructiveTest
|
def test_say(self):
|
||||||
@requires_system_grains
|
|
||||||
def test_say(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests the return of the say function.
|
Tests the return of the say function.
|
||||||
'''
|
'''
|
||||||
|
@ -12,10 +12,7 @@ import string
|
|||||||
# Import Salt Testing Libs
|
# Import Salt Testing Libs
|
||||||
import tests.integration as integration
|
import tests.integration as integration
|
||||||
from tests.support.unit import skipIf
|
from tests.support.unit import skipIf
|
||||||
from tests.support.helpers import (
|
from tests.support.helpers import destructiveTest
|
||||||
destructiveTest,
|
|
||||||
requires_system_grains
|
|
||||||
)
|
|
||||||
|
|
||||||
# Import Salt Libs
|
# Import Salt Libs
|
||||||
from salt.exceptions import CommandExecutionError
|
from salt.exceptions import CommandExecutionError
|
||||||
@ -41,6 +38,8 @@ ADD_USER = __random_string()
|
|||||||
REP_USER_GROUP = __random_string()
|
REP_USER_GROUP = __random_string()
|
||||||
|
|
||||||
|
|
||||||
|
@destructiveTest
|
||||||
|
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
|
||||||
class MacGroupModuleTest(integration.ModuleCase):
|
class MacGroupModuleTest(integration.ModuleCase):
|
||||||
'''
|
'''
|
||||||
Integration tests for the mac_group module
|
Integration tests for the mac_group module
|
||||||
@ -58,10 +57,7 @@ class MacGroupModuleTest(integration.ModuleCase):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@destructiveTest
|
def test_mac_group_add(self):
|
||||||
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
|
|
||||||
@requires_system_grains
|
|
||||||
def test_mac_group_add(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests the add group function
|
Tests the add group function
|
||||||
'''
|
'''
|
||||||
@ -73,10 +69,7 @@ class MacGroupModuleTest(integration.ModuleCase):
|
|||||||
self.run_function('group.delete', [ADD_GROUP])
|
self.run_function('group.delete', [ADD_GROUP])
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@destructiveTest
|
def test_mac_group_delete(self):
|
||||||
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
|
|
||||||
@requires_system_grains
|
|
||||||
def test_mac_group_delete(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests the delete group function
|
Tests the delete group function
|
||||||
'''
|
'''
|
||||||
@ -92,10 +85,7 @@ class MacGroupModuleTest(integration.ModuleCase):
|
|||||||
except CommandExecutionError:
|
except CommandExecutionError:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@destructiveTest
|
def test_mac_group_chgid(self):
|
||||||
@skipIf(os.getuid() != 0, 'You must be logged in as root to run this test')
|
|
||||||
@requires_system_grains
|
|
||||||
def test_mac_group_chgid(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests changing the group id
|
Tests changing the group id
|
||||||
'''
|
'''
|
||||||
@ -112,10 +102,7 @@ class MacGroupModuleTest(integration.ModuleCase):
|
|||||||
self.run_function('group.delete', [CHANGE_GROUP])
|
self.run_function('group.delete', [CHANGE_GROUP])
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@destructiveTest
|
def test_mac_adduser(self):
|
||||||
@skipIf(os.getuid() != 0, 'You must be logged in as root to run this test')
|
|
||||||
@requires_system_grains
|
|
||||||
def test_mac_adduser(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests adding user to the group
|
Tests adding user to the group
|
||||||
'''
|
'''
|
||||||
@ -132,10 +119,7 @@ class MacGroupModuleTest(integration.ModuleCase):
|
|||||||
self.run_function('group.delete', [ADD_GROUP])
|
self.run_function('group.delete', [ADD_GROUP])
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@destructiveTest
|
def test_mac_deluser(self):
|
||||||
@skipIf(os.getuid() != 0, 'You must be logged in as root to run this test')
|
|
||||||
@requires_system_grains
|
|
||||||
def test_mac_deluser(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Test deleting user from a group
|
Test deleting user from a group
|
||||||
'''
|
'''
|
||||||
@ -151,10 +135,7 @@ class MacGroupModuleTest(integration.ModuleCase):
|
|||||||
group_info = self.run_function('group.info', [ADD_GROUP])
|
group_info = self.run_function('group.info', [ADD_GROUP])
|
||||||
self.assertNotIn(ADD_USER, ''.join(group_info['members']))
|
self.assertNotIn(ADD_USER, ''.join(group_info['members']))
|
||||||
|
|
||||||
@destructiveTest
|
def test_mac_members(self):
|
||||||
@skipIf(os.getuid() != 0, 'You must be logged in as root to run this test')
|
|
||||||
@requires_system_grains
|
|
||||||
def test_mac_members(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Test replacing members of a group
|
Test replacing members of a group
|
||||||
'''
|
'''
|
||||||
@ -174,10 +155,7 @@ class MacGroupModuleTest(integration.ModuleCase):
|
|||||||
self.assertIn(REP_USER_GROUP, str(group_info['members']))
|
self.assertIn(REP_USER_GROUP, str(group_info['members']))
|
||||||
self.assertNotIn(ADD_USER, str(group_info['members']))
|
self.assertNotIn(ADD_USER, str(group_info['members']))
|
||||||
|
|
||||||
@destructiveTest
|
def test_mac_getent(self):
|
||||||
@skipIf(os.getuid() != 0, 'You must be logged in as root to run this test')
|
|
||||||
@requires_system_grains
|
|
||||||
def test_mac_getent(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Test returning info on all groups
|
Test returning info on all groups
|
||||||
'''
|
'''
|
||||||
@ -193,10 +171,7 @@ class MacGroupModuleTest(integration.ModuleCase):
|
|||||||
self.assertIn(ADD_GROUP, str(getinfo))
|
self.assertIn(ADD_GROUP, str(getinfo))
|
||||||
self.assertIn(ADD_USER, str(getinfo))
|
self.assertIn(ADD_USER, str(getinfo))
|
||||||
|
|
||||||
@destructiveTest
|
def tearDown(self):
|
||||||
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
|
|
||||||
@requires_system_grains
|
|
||||||
def tearDown(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Clean up after tests
|
Clean up after tests
|
||||||
'''
|
'''
|
||||||
|
@ -10,10 +10,7 @@ import os
|
|||||||
# Import Salt Testing Libs
|
# Import Salt Testing Libs
|
||||||
import tests.integration as integration
|
import tests.integration as integration
|
||||||
from tests.support.unit import skipIf
|
from tests.support.unit import skipIf
|
||||||
from tests.support.helpers import (
|
from tests.support.helpers import destructiveTest
|
||||||
destructiveTest,
|
|
||||||
requires_system_grains
|
|
||||||
)
|
|
||||||
|
|
||||||
# Import Salt Libs
|
# Import Salt Libs
|
||||||
from salt.exceptions import CommandExecutionError
|
from salt.exceptions import CommandExecutionError
|
||||||
@ -57,8 +54,7 @@ class MacKeychainModuleTest(integration.ModuleCase):
|
|||||||
if CERT_ALIAS in certs_list:
|
if CERT_ALIAS in certs_list:
|
||||||
self.run_function('keychain.uninstall', [CERT_ALIAS])
|
self.run_function('keychain.uninstall', [CERT_ALIAS])
|
||||||
|
|
||||||
@requires_system_grains
|
def test_mac_keychain_install(self):
|
||||||
def test_mac_keychain_install(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests that attempts to install a certificate
|
Tests that attempts to install a certificate
|
||||||
'''
|
'''
|
||||||
@ -69,8 +65,7 @@ class MacKeychainModuleTest(integration.ModuleCase):
|
|||||||
certs_list = self.run_function('keychain.list_certs')
|
certs_list = self.run_function('keychain.list_certs')
|
||||||
self.assertIn(CERT_ALIAS, certs_list)
|
self.assertIn(CERT_ALIAS, certs_list)
|
||||||
|
|
||||||
@requires_system_grains
|
def test_mac_keychain_uninstall(self):
|
||||||
def test_mac_keychain_uninstall(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Tests that attempts to uninstall a certificate
|
Tests that attempts to uninstall a certificate
|
||||||
'''
|
'''
|
||||||
@ -91,8 +86,7 @@ class MacKeychainModuleTest(integration.ModuleCase):
|
|||||||
except CommandExecutionError:
|
except CommandExecutionError:
|
||||||
self.run_function('keychain.uninstall', [CERT_ALIAS])
|
self.run_function('keychain.uninstall', [CERT_ALIAS])
|
||||||
|
|
||||||
@requires_system_grains
|
def test_mac_keychain_get_friendly_name(self):
|
||||||
def test_mac_keychain_get_friendly_name(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Test that attempts to get friendly name of a cert
|
Test that attempts to get friendly name of a cert
|
||||||
'''
|
'''
|
||||||
@ -105,8 +99,7 @@ class MacKeychainModuleTest(integration.ModuleCase):
|
|||||||
get_name = self.run_function('keychain.get_friendly_name', [CERT, PASSWD])
|
get_name = self.run_function('keychain.get_friendly_name', [CERT, PASSWD])
|
||||||
self.assertEqual(get_name, CERT_ALIAS)
|
self.assertEqual(get_name, CERT_ALIAS)
|
||||||
|
|
||||||
@requires_system_grains
|
def test_mac_keychain_get_default_keychain(self):
|
||||||
def test_mac_keychain_get_default_keychain(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Test that attempts to get the default keychain
|
Test that attempts to get the default keychain
|
||||||
'''
|
'''
|
||||||
@ -115,8 +108,7 @@ class MacKeychainModuleTest(integration.ModuleCase):
|
|||||||
['security default-keychain -d user'])
|
['security default-keychain -d user'])
|
||||||
self.assertEqual(salt_get_keychain, sys_get_keychain)
|
self.assertEqual(salt_get_keychain, sys_get_keychain)
|
||||||
|
|
||||||
@requires_system_grains
|
def test_mac_keychain_list_certs(self):
|
||||||
def test_mac_keychain_list_certs(self, grains=None):
|
|
||||||
'''
|
'''
|
||||||
Test that attempts to list certs
|
Test that attempts to list certs
|
||||||
'''
|
'''
|
||||||
|
@ -12,10 +12,7 @@ import string
|
|||||||
# Import Salt Testing Libs
|
# Import Salt Testing Libs
|
||||||
import tests.integration as integration
|
import tests.integration as integration
|
||||||
from tests.support.unit import skipIf
|
from tests.support.unit import skipIf
|
||||||
from tests.support.helpers import (
|
from tests.support.helpers import destructiveTest
|
||||||
destructiveTest,
|
|
||||||
requires_system_grains
|
|
||||||
)
|
|
||||||
|
|
||||||
# Import Salt Libs
|
# Import Salt Libs
|
||||||
from salt.exceptions import CommandExecutionError
|
from salt.exceptions import CommandExecutionError
|
||||||
@ -42,7 +39,6 @@ CHANGE_USER = __random_string()
|
|||||||
|
|
||||||
@destructiveTest
|
@destructiveTest
|
||||||
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
|
@skipIf(os.geteuid() != 0, 'You must be logged in as root to run this test')
|
||||||
@requires_system_grains
|
|
||||||
class MacUserModuleTest(integration.ModuleCase):
|
class MacUserModuleTest(integration.ModuleCase):
|
||||||
'''
|
'''
|
||||||
Integration tests for the mac_user module
|
Integration tests for the mac_user module
|
||||||
@ -61,7 +57,7 @@ class MacUserModuleTest(integration.ModuleCase):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_mac_user_add(self, grains=None):
|
def test_mac_user_add(self):
|
||||||
'''
|
'''
|
||||||
Tests the add function
|
Tests the add function
|
||||||
'''
|
'''
|
||||||
@ -73,7 +69,7 @@ class MacUserModuleTest(integration.ModuleCase):
|
|||||||
self.run_function('user.delete', [ADD_USER])
|
self.run_function('user.delete', [ADD_USER])
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def test_mac_user_delete(self, grains=None):
|
def test_mac_user_delete(self):
|
||||||
'''
|
'''
|
||||||
Tests the delete function
|
Tests the delete function
|
||||||
'''
|
'''
|
||||||
@ -90,7 +86,7 @@ class MacUserModuleTest(integration.ModuleCase):
|
|||||||
except CommandExecutionError:
|
except CommandExecutionError:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def test_mac_user_primary_group(self, grains=None):
|
def test_mac_user_primary_group(self):
|
||||||
'''
|
'''
|
||||||
Tests the primary_group function
|
Tests the primary_group function
|
||||||
'''
|
'''
|
||||||
@ -110,7 +106,7 @@ class MacUserModuleTest(integration.ModuleCase):
|
|||||||
self.run_function('user.delete', [PRIMARY_GROUP_USER])
|
self.run_function('user.delete', [PRIMARY_GROUP_USER])
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def test_mac_user_changes(self, grains=None):
|
def test_mac_user_changes(self):
|
||||||
'''
|
'''
|
||||||
Tests mac_user functions that change user properties
|
Tests mac_user functions that change user properties
|
||||||
'''
|
'''
|
||||||
@ -154,7 +150,7 @@ class MacUserModuleTest(integration.ModuleCase):
|
|||||||
self.run_function('user.delete', [CHANGE_USER])
|
self.run_function('user.delete', [CHANGE_USER])
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def tearDown(self, grains=None):
|
def tearDown(self):
|
||||||
'''
|
'''
|
||||||
Clean up after tests
|
Clean up after tests
|
||||||
'''
|
'''
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
# Import python libs
|
# Import python libs
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import os
|
|
||||||
import string
|
import string
|
||||||
import random
|
import random
|
||||||
|
|
||||||
@ -11,6 +10,7 @@ import tests.integration as integration
|
|||||||
from tests.support.unit import skipIf
|
from tests.support.unit import skipIf
|
||||||
from tests.support.helpers import (
|
from tests.support.helpers import (
|
||||||
destructiveTest,
|
destructiveTest,
|
||||||
|
skip_if_not_root,
|
||||||
requires_system_grains
|
requires_system_grains
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,21 +20,10 @@ import salt.utils
|
|||||||
# Import 3rd-party libs
|
# Import 3rd-party libs
|
||||||
from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin
|
from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin
|
||||||
|
|
||||||
IS_ADMIN = False
|
|
||||||
if salt.utils.is_windows():
|
|
||||||
import salt.utils.win_functions
|
|
||||||
current_user = salt.utils.win_functions.get_current_user()
|
|
||||||
if current_user == 'SYSTEM':
|
|
||||||
IS_ADMIN = True
|
|
||||||
else:
|
|
||||||
IS_ADMIN = salt.utils.win_functions.is_admin(current_user)
|
|
||||||
else:
|
|
||||||
IS_ADMIN = os.geteuid() == 0
|
|
||||||
|
|
||||||
|
|
||||||
@destructiveTest
|
@destructiveTest
|
||||||
@skipIf(not salt.utils.is_linux(), 'These tests can only be run on linux')
|
@skipIf(not salt.utils.is_linux(), 'These tests can only be run on linux')
|
||||||
@skipIf(not IS_ADMIN, 'You must be root to run these tests')
|
@skip_if_not_root
|
||||||
class UseraddModuleTestLinux(integration.ModuleCase):
|
class UseraddModuleTestLinux(integration.ModuleCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -54,7 +43,7 @@ class UseraddModuleTestLinux(integration.ModuleCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@requires_system_grains
|
@requires_system_grains
|
||||||
def test_groups_includes_primary(self, grains=None):
|
def test_groups_includes_primary(self, grains):
|
||||||
# Let's create a user, which usually creates the group matching the
|
# Let's create a user, which usually creates the group matching the
|
||||||
# name
|
# name
|
||||||
uname = self.__random_string()
|
uname = self.__random_string()
|
||||||
@ -96,7 +85,7 @@ class UseraddModuleTestLinux(integration.ModuleCase):
|
|||||||
self.run_function('user.delete', [uname, True, True])
|
self.run_function('user.delete', [uname, True, True])
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def test_user_primary_group(self, grains=None):
|
def test_user_primary_group(self):
|
||||||
'''
|
'''
|
||||||
Tests the primary_group function
|
Tests the primary_group function
|
||||||
'''
|
'''
|
||||||
@ -120,7 +109,7 @@ class UseraddModuleTestLinux(integration.ModuleCase):
|
|||||||
|
|
||||||
@destructiveTest
|
@destructiveTest
|
||||||
@skipIf(not salt.utils.is_windows(), 'These tests can only be run on Windows')
|
@skipIf(not salt.utils.is_windows(), 'These tests can only be run on Windows')
|
||||||
@skipIf(not IS_ADMIN, 'You must be Administrator to run these tests')
|
@skip_if_not_root
|
||||||
class UseraddModuleTestWindows(integration.ModuleCase):
|
class UseraddModuleTestWindows(integration.ModuleCase):
|
||||||
|
|
||||||
def __random_string(self, size=6):
|
def __random_string(self, size=6):
|
||||||
|
Loading…
Reference in New Issue
Block a user