desc
stringlengths 3
26.7k
| decl
stringlengths 11
7.89k
| bodies
stringlengths 8
553k
|
---|---|---|
'Test creating an instance on ProfitBricks'
| def test_instance(self):
| try:
self.assertIn(INSTANCE_NAME, [i.strip() for i in self.run_cloud('-p profitbricks-test {0}'.format(INSTANCE_NAME), timeout=500)])
except AssertionError:
self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=500)
raise
try:
self.assertIn((INSTANCE_NAME + ':'), [i.strip() for i in self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=500)])
except AssertionError:
raise
|
'Clean up after tests'
| def tearDown(self):
| query = self.run_cloud('--query')
ret = ' {0}:'.format(INSTANCE_NAME)
if (ret in query):
self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=500)
|
'Sets up the test requirements'
| @expensiveTest
def setUp(self):
| super(VultrTest, self).setUp()
profile_str = 'vultr-config'
providers = self.run_cloud('--list-providers')
if ((profile_str + ':') not in providers):
self.skipTest('Configuration file for {0} was not found. Check {0}.conf files in tests/integration/files/conf/cloud.*.d/ to run these tests.'.format(PROVIDER_NAME))
config = cloud_providers_config(os.path.join(FILES, 'conf', 'cloud.providers.d', (PROVIDER_NAME + '.conf')))
api_key = config[profile_str][PROVIDER_NAME]['api_key']
ssh_file = config[profile_str][PROVIDER_NAME]['ssh_key_file']
ssh_name = config[profile_str][PROVIDER_NAME]['ssh_key_name']
if ((api_key == '') or (ssh_file == '') or (ssh_name == '')):
self.skipTest('An API key, an ssh key file, and an ssh key name must be provided to run these tests. Check tests/integration/files/conf/cloud.providers.d/{0}.conf'.format(PROVIDER_NAME))
|
'Tests the return of running the --list-images command for Vultr'
| def test_list_images(self):
| image_list = self.run_cloud('--list-images {0}'.format(PROVIDER_NAME))
self.assertIn('Debian 8 x64 (jessie)', [i.strip() for i in image_list])
|
'Tests the return of running the --list-locations command for Vultr'
| def test_list_locations(self):
| location_list = self.run_cloud('--list-locations {0}'.format(PROVIDER_NAME))
self.assertIn('New Jersey', [i.strip() for i in location_list])
|
'Tests the return of running the --list-sizes command for Vultr'
| def test_list_sizes(self):
| size_list = self.run_cloud('--list-sizes {0}'.format(PROVIDER_NAME))
self.assertIn('32768 MB RAM,110 GB SSD,40.00 TB BW', [i.strip() for i in size_list])
|
'Test creating an instance on Vultr'
| def test_instance(self):
| try:
create_vm = self.run_cloud('-p vultr-test {0}'.format(INSTANCE_NAME), timeout=500)
self.assertIn(INSTANCE_NAME, [i.strip() for i in create_vm])
self.assertNotIn('Failed to start', str(create_vm))
except AssertionError:
self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=500)
raise
time.sleep(420)
results = self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=500)
try:
self.assertIn('True', [i.strip() for i in results])
except AssertionError:
raise
ct = 0
while ((ct < 12) and (INSTANCE_NAME in [i.strip() for i in self.run_cloud('--query')])):
self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=500)
time.sleep(30)
ct = (ct + 1)
|
'Sets up the test requirements'
| @expensiveTest
def setUp(self):
| profile_str = 'vmware-config'
providers = self.run_cloud('--list-providers')
if ((profile_str + ':') not in providers):
self.skipTest('Configuration file for {0} was not found. Check {0}.conf files in tests/integration/files/conf/cloud.*.d/ to run these tests.'.format(PROVIDER_NAME))
config = cloud_providers_config(os.path.join(FILES, 'conf', 'cloud.providers.d', (PROVIDER_NAME + '.conf')))
user = config[profile_str][PROVIDER_NAME]['user']
password = config[profile_str][PROVIDER_NAME]['password']
url = config[profile_str][PROVIDER_NAME]['url']
conf_items = [user, password, url]
missing_conf_item = []
for item in conf_items:
if (item == ''):
missing_conf_item.append(item)
if missing_conf_item:
self.skipTest('A user, password, and url must be provided to run these tests.One or more of these elements is missing. Checktests/integration/files/conf/cloud.providers.d/{0}.conf'.format(PROVIDER_NAME))
|
'Tests creating and deleting an instance on vmware and installing salt'
| def test_instance(self):
| profile = os.path.join(FILES, 'conf', 'cloud.profiles.d', (PROVIDER_NAME + '.conf'))
profile_config = cloud_config(profile)
disk_datastore = profile_config['vmware-test']['devices']['disk']['Hard disk 2']['datastore']
instance = self.run_cloud('-p vmware-test {0}'.format(INSTANCE_NAME), timeout=TIMEOUT)
ret_str = '{0}:'.format(INSTANCE_NAME)
disk_datastore_str = ' [{0}] {1}/Hard disk 2-flat.vmdk'.format(disk_datastore, INSTANCE_NAME)
try:
self.assertIn(ret_str, instance)
self.assertIn(disk_datastore_str, instance, msg='Hard Disk 2 did not use the Datastore {0} '.format(disk_datastore))
except AssertionError:
self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=TIMEOUT)
raise
delete = self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=TIMEOUT)
ret_str = "{0}:', ' True".format(INSTANCE_NAME)
self.assertIn(ret_str, str(delete))
|
'Tests creating snapshot and creating vm with --no-deploy'
| def test_snapshot(self):
| instance = self.run_cloud('-p vmware-test {0} --no-deploy'.format(INSTANCE_NAME), timeout=TIMEOUT)
ret_str = '{0}:'.format(INSTANCE_NAME)
try:
self.assertIn(ret_str, instance)
except AssertionError:
self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=TIMEOUT)
raise
create_snapshot = self.run_cloud("-a create_snapshot {0} snapshot_name='Test Cloud' memdump=True -y".format(INSTANCE_NAME), timeout=TIMEOUT)
s_ret_str = 'Snapshot created successfully'
self.assertIn(s_ret_str, str(create_snapshot))
delete = self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=TIMEOUT)
ret_str = "{0}:', ' True".format(INSTANCE_NAME)
self.assertIn(ret_str, str(delete))
|
'Clean up after tests'
| def tearDown(self):
| query = self.run_cloud('--query')
ret_str = ' {0}:'.format(INSTANCE_NAME)
if (ret_str in query):
self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=TIMEOUT)
|
'Sets up the test requirements'
| @expensiveTest
def setUp(self):
| super(GCETest, self).setUp()
profile_str = 'gce-config:'
provider = 'gce'
providers = self.run_cloud('--list-providers')
self.INSTANCE_NAME = generate_random_name('CLOUD-TEST-')
if (profile_str not in providers):
self.skipTest('Configuration file for {0} was not found. Check {0}.conf files in tests/integration/files/conf/cloud.*.d/ to run these tests.'.format(provider))
path = os.path.join(FILES, 'conf', 'cloud.providers.d', (provider + '.conf'))
config = cloud_providers_config(path)
project = config['gce-config']['gce']['project']
service_account_email_address = config['gce-config']['gce']['service_account_email_address']
service_account_private_key = config['gce-config']['gce']['service_account_private_key']
conf_items = [project, service_account_email_address, service_account_private_key]
missing_conf_item = []
for item in conf_items:
if (item == ''):
missing_conf_item.append(item)
if missing_conf_item:
self.skipTest('An project, service_account_email_address, service_account_private_key must be provided to run these tests. One or more of these elements is missing. Check tests/integration/files/conf/cloud.providers.d/{0}.conf'.format(provider))
|
'Tests creating and deleting an instance on GCE'
| def test_instance(self):
| instance = self.run_cloud('-p gce-test {0}'.format(self.INSTANCE_NAME), timeout=TIMEOUT)
ret_str = '{0}:'.format(self.INSTANCE_NAME)
try:
self.assertIn(ret_str, instance)
except AssertionError:
self.run_cloud('-d {0} --assume-yes'.format(self.INSTANCE_NAME), timeout=TIMEOUT)
raise
delete = self.run_cloud('-d {0} --assume-yes'.format(self.INSTANCE_NAME), timeout=TIMEOUT)
delete_str = ''.join(delete)
try:
self.assertIn(self.INSTANCE_NAME, delete_str)
self.assertIn('True', delete_str)
except AssertionError:
raise
|
'Tests creating and deleting an instance on GCE'
| def test_instance_extra(self):
| instance = self.run_cloud('-p gce-test-extra {0}'.format(self.INSTANCE_NAME), timeout=TIMEOUT)
ret_str = '{0}:'.format(self.INSTANCE_NAME)
try:
self.assertIn(ret_str, instance)
except AssertionError:
self.run_cloud('-d {0} --assume-yes'.format(self.INSTANCE_NAME), timeout=TIMEOUT)
raise
delete = self.run_cloud('-d {0} --assume-yes'.format(self.INSTANCE_NAME), timeout=TIMEOUT)
delete_str = ''.join(delete)
try:
self.assertIn(self.INSTANCE_NAME, delete_str)
self.assertIn('True', delete_str)
except AssertionError:
raise
|
'Clean up after tests'
| def tearDown(self):
| query = self.run_cloud('--query')
ret_str = ' {0}:'.format(self.INSTANCE_NAME)
if (ret_str in query):
self.run_cloud('-d {0} --assume-yes'.format(self.INSTANCE_NAME), timeout=TIMEOUT)
|
'Sets up the test requirements'
| @expensiveTest
def setUp(self):
| super(AzureTest, self).setUp()
provider_str = 'azure-config'
providers = self.run_cloud('--list-providers')
if ((provider_str + ':') not in providers):
self.skipTest('Configuration file for {0} was not found. Check {0}.conf files in tests/integration/files/conf/cloud.*.d/ to run these tests.'.format(PROVIDER_NAME))
provider_config = cloud_providers_config(os.path.join(FILES, 'conf', 'cloud.providers.d', (PROVIDER_NAME + '.conf')))
sub_id = provider_config[provider_str][PROVIDER_NAME]['subscription_id']
cert_path = provider_config[provider_str][PROVIDER_NAME]['certificate_path']
if ((sub_id == '') or (cert_path == '')):
self.skipTest('A subscription_id and certificate_path must be provided to run these tests. Check tests/integration/files/conf/cloud.providers.d/{0}.conf'.format(PROVIDER_NAME))
ssh_user = provider_config[provider_str][PROVIDER_NAME]['ssh_username']
ssh_pass = provider_config[provider_str][PROVIDER_NAME]['ssh_password']
media_link = provider_config[provider_str][PROVIDER_NAME]['media_link']
if ((ssh_user == '') or (ssh_pass == '') or (media_link == '')):
self.skipTest('An ssh_username, ssh_password, and media_link must be provided to run these tests. One or more of these elements is missing. Check tests/integration/files/conf/cloud.profiles.d/{0}.conf'.format(PROVIDER_NAME))
|
'Test creating an instance on Azure'
| def test_instance(self):
| try:
self.assertIn(INSTANCE_NAME, [i.strip() for i in self.run_cloud('-p {0} {1}'.format(PROFILE_NAME, INSTANCE_NAME), timeout=TIMEOUT)])
except AssertionError:
self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=TIMEOUT)
raise
try:
self.assertIn((INSTANCE_NAME + ':'), [i.strip() for i in self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=TIMEOUT)])
except AssertionError:
raise
|
'Clean up after tests'
| def tearDown(self):
| query = self.run_cloud('--query')
ret_str = ' {0}:'.format(INSTANCE_NAME)
if (ret_str in query):
self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=TIMEOUT)
|
'Execute salt-cloud with json output and try to interpret it
@return:
@rtype: dict'
| def run_cloud(self, arg_str, catch_stderr=False, timeout=None):
| config_path = os.path.join(FILES, 'conf')
arg_str = '--out=json -c {0} {1}'.format(config_path, arg_str)
log.debug('running salt-cloud with %s', arg_str)
output = self.run_script('salt-cloud', arg_str, catch_stderr, timeout=timeout)
if (isinstance(output, tuple) and (len(output) == 2)):
output = output[0]
valid_initial_chars = ['{', '[', '"']
for line in output[:]:
if ((len(line) == 0) or (line[0] not in valid_initial_chars)):
output.pop(0)
else:
break
if (len(output) is 0):
return dict()
else:
return json.loads(''.join(output))
|
'A helper to call `salt-cloud -f function provider`
@param function:
@type function:
@param kw_function_args: Keyword arguments for the argument string in the commandline
@type dict:
@param kwargs: For the `run_cloud` function
@type kwargs:
@return:
@rtype: dict'
| def run_cloud_function(self, function, kw_function_args=None, **kwargs):
| args = []
if kw_function_args:
args = ["{0}='{1}'".format(key, value) for (key, value) in six.iteritems(kw_function_args)]
output = self.run_cloud('-f {0} {1} {2}'.format(function, CONFIG_NAME, ' '.join(args)), **kwargs)
return output.get(CONFIG_NAME, {}).get(PROVIDER_NAME, {})
|
'A helper to call `salt-cloud -a action instance_name`
@param action:
@type action: str
@param instance_name:
@type instance_name: str
@return:
@rtype: dict'
| def run_cloud_action(self, action, instance_name, **kwargs):
| output = self.run_cloud('-a {0} {1} --assume-yes'.format(action, instance_name), **kwargs)
return output.get(CONFIG_NAME, {}).get(PROVIDER_NAME, {})
|
'setup docker.call tests'
| @with_random_name
def setUp(self, name):
| self.random_name = name
self.tmp_build_dir = tempfile.mkdtemp(dir=TMP)
self.run_state('file.managed', source='salt://docker_non_root/Dockerfile', name='{0}/Dockerfile'.format(self.tmp_build_dir))
self.run_state('docker_image.present', build=self.tmp_build_dir, name=self.random_name)
self.run_state('docker_container.running', name=self.random_name, image=self.random_name)
|
'teardown docker.call tests'
| def tearDown(self):
| self.run_state('file.absent', name=self.tmp_build_dir)
self.run_state('docker_container.absent', name=self.random_name, force=True)
self.run_state('docker_image.absent', images=[self.random_name, 'docker.io/opensuse/python:latest'], force=True)
|
'check that docker.call works, and works with a container not running as root'
| def test_docker_call(self):
| ret = self.run_function('docker.call', [self.random_name, 'test.ping'])
self.assertTrue(ret)
|
'test config.valid_file_proto'
| def test_valid_file_proto(self):
| self.assertTrue(self.run_function('config.valid_fileproto', ['salt://']))
self.assertTrue(self.run_function('config.valid_fileproto', ['http://']))
self.assertTrue(self.run_function('config.valid_fileproto', ['https://']))
self.assertTrue(self.run_function('config.valid_fileproto', ['ftp://']))
self.assertFalse(self.run_function('config.valid_fileproto', ['cheese://']))
|
'test config.backup_mode'
| def test_backup_mode(self):
| self.assertEqual(self.run_function('config.backup_mode', ['minion']), 'minion')
|
'test config.manage_mode'
| def test_manage_mode(self):
| self.assertEqual(self.run_function('config.manage_mode', ['"775"']), '0775')
self.assertEqual(self.run_function('config.manage_mode', ['"1775"']), '1775')
self.assertEqual(self.run_function('config.manage_mode', ['"0775"']), '0775')
self.assertEqual(self.run_function('config.manage_mode', ['"01775"']), '1775')
self.assertEqual(self.run_function('config.manage_mode', ['"0"']), '0000')
self.assertEqual(self.run_function('config.manage_mode', ['775']), '0775')
self.assertEqual(self.run_function('config.manage_mode', ['1775']), '1775')
self.assertEqual(self.run_function('config.manage_mode', ['0']), '0000')
|
'test config.option'
| def test_option(self):
| self.assertEqual(self.run_function('config.option', ['master_port']), 64506)
self.assertEqual(self.run_function('config.option', ['ext_spam']), 'eggs')
|
'Test option.get'
| def test_get(self):
| self.assertEqual(self.run_function('config.get', ['level1:level2']), 'foo')
self.assertEqual(self.run_function('config.get', ['config_opt:layer2']), 'kosher')
self.assertEqual(self.run_function('config.get', ['config_test:spam']), 'eggs')
|
'cmd.run'
| def test_run(self):
| shell = os.environ.get('SHELL')
if (shell is None):
self.skipTest('Unable to get the SHELL environment variable')
self.assertTrue(self.run_function('cmd.run', ['echo $SHELL']))
self.assertEqual(self.run_function('cmd.run', ['echo $SHELL', 'shell={0}'.format(shell)], python_shell=True).rstrip(), shell)
self.assertEqual(self.run_function('cmd.run', ['ls / | grep etc'], python_shell=True), 'etc')
self.assertEqual(self.run_function('cmd.run', ['echo {{grains.id}} | awk "{print $1}"'], template='jinja', python_shell=True), 'minion')
self.assertEqual(self.run_function('cmd.run', ['grep f'], stdin='one\ntwo\nthree\nfour\nfive\n'), 'four\nfive')
self.assertEqual(self.run_function('cmd.run', ['echo "a=b" | sed -e s/=/:/g'], python_shell=True), 'a:b')
|
'cmd.run_stdout'
| def test_stdout(self):
| self.assertEqual(self.run_function('cmd.run_stdout', ['echo "cheese"']).rstrip(), 'cheese')
|
'cmd.run_stderr'
| def test_stderr(self):
| if sys.platform.startswith(('freebsd', 'openbsd')):
shell = '/bin/sh'
else:
shell = '/bin/bash'
self.assertEqual(self.run_function('cmd.run_stderr', ['echo "cheese" 1>&2', 'shell={0}'.format(shell)], python_shell=True).rstrip(), 'cheese')
|
'cmd.run_all'
| def test_run_all(self):
| if sys.platform.startswith(('freebsd', 'openbsd')):
shell = '/bin/sh'
else:
shell = '/bin/bash'
ret = self.run_function('cmd.run_all', ['echo "cheese" 1>&2', 'shell={0}'.format(shell)], python_shell=True)
self.assertTrue(('pid' in ret))
self.assertTrue(('retcode' in ret))
self.assertTrue(('stdout' in ret))
self.assertTrue(('stderr' in ret))
self.assertTrue(isinstance(ret.get('pid'), int))
self.assertTrue(isinstance(ret.get('retcode'), int))
self.assertTrue(isinstance(ret.get('stdout'), six.string_types))
self.assertTrue(isinstance(ret.get('stderr'), six.string_types))
self.assertEqual(ret.get('stderr').rstrip(), 'cheese')
|
'cmd.retcode'
| def test_retcode(self):
| self.assertEqual(self.run_function('cmd.retcode', ['exit 0'], python_shell=True), 0)
self.assertEqual(self.run_function('cmd.retcode', ['exit 1'], python_shell=True), 1)
|
'cmd_blacklist_glob'
| def test_blacklist_glob(self):
| self.assertEqual(self.run_function('cmd.run', ['bad_command --foo']).rstrip(), 'ERROR: This shell command is not permitted: "bad_command --foo"')
|
'cmd.script'
| def test_script(self):
| args = 'saltines crackers biscuits=yes'
script = 'salt://script.py'
ret = self.run_function('cmd.script', [script, args])
self.assertEqual(ret['stdout'], args)
|
'cmd.script_retcode'
| def test_script_retcode(self):
| script = 'salt://script.py'
ret = self.run_function('cmd.script_retcode', [script])
self.assertEqual(ret, 0)
|
'cmd.tty'
| @destructiveTest
def test_tty(self):
| for tty in ('tty0', 'pts3'):
if os.path.exists(os.path.join('/dev', tty)):
ret = self.run_function('cmd.tty', [tty, 'apply salt liberally'])
self.assertTrue(('Success' in ret))
|
'cmd.which'
| @skip_if_binaries_missing(['which'])
def test_which(self):
| self.assertEqual(self.run_function('cmd.which', ['cat']).rstrip(), self.run_function('cmd.run', ['which cat']).rstrip())
|
'cmd.which_bin'
| @skip_if_binaries_missing(['which'])
def test_which_bin(self):
| cmds = ['pip3', 'pip2', 'pip', 'pip-python']
ret = self.run_function('cmd.which_bin', [cmds])
self.assertTrue((os.path.split(ret)[1] in cmds))
|
'cmd.has_exec'
| def test_has_exec(self):
| self.assertTrue(self.run_function('cmd.has_exec', [AVAILABLE_PYTHON_EXECUTABLE]))
self.assertFalse(self.run_function('cmd.has_exec', ['alllfsdfnwieulrrh9123857ygf']))
|
'cmd.exec_code'
| def test_exec_code(self):
| code = textwrap.dedent(" import sys\n sys.stdout.write('cheese')")
self.assertEqual(self.run_function('cmd.exec_code', [AVAILABLE_PYTHON_EXECUTABLE, code]).rstrip(), 'cheese')
|
'cmd.run with quoted command'
| def test_quotes(self):
| cmd = 'echo \'SELECT * FROM foo WHERE bar="baz"\' '
expected_result = 'SELECT * FROM foo WHERE bar="baz"'
result = self.run_function('cmd.run_stdout', [cmd]).strip()
self.assertEqual(result, expected_result)
|
'cmd.run with quoted command'
| @skip_if_not_root
def test_quotes_runas(self):
| cmd = 'echo \'SELECT * FROM foo WHERE bar="baz"\' '
expected_result = 'SELECT * FROM foo WHERE bar="baz"'
try:
runas = os.getlogin()
except:
import pwd
runas = pwd.getpwuid(os.getuid())[0]
result = self.run_function('cmd.run_stdout', [cmd], runas=runas).strip()
self.assertEqual(result, expected_result)
|
'cmd.run trigger timeout'
| def test_timeout(self):
| out = self.run_function('cmd.run', ['sleep 2 && echo hello'], f_timeout=1, python_shell=True)
self.assertTrue(('Timed out' in out))
|
'cmd.run sufficient timeout to succeed'
| def test_timeout_success(self):
| out = self.run_function('cmd.run', ['sleep 1 && echo hello'], f_timeout=2, python_shell=True)
self.assertEqual(out, 'hello')
|
'gem.install
gem.uninstall'
| def test_install_uninstall(self):
| if self.run_function('gem.list', [GEM]):
self.run_function('gem.uninstall', [GEM])
self.run_function('gem.install', [GEM])
gem_list = self.run_function('gem.list', [GEM])
self.assertIn(GEM, gem_list)
self.run_function('gem.uninstall', [GEM])
self.assertFalse(self.run_function('gem.list', [GEM]))
|
'gem.install rake version=11.1.2'
| def test_install_version(self):
| if self.run_function('gem.list', [GEM]):
self.run_function('gem.uninstall', [GEM])
self.run_function('gem.install', [GEM], version=GEM_VER)
gem_list = self.run_function('gem.list', [GEM])
self.assertIn(GEM, gem_list)
self.assertIn(GEM_VER, gem_list[GEM])
self.run_function('gem.uninstall', [GEM])
self.assertFalse(self.run_function('gem.list', [GEM]))
|
'gem.list'
| def test_list(self):
| self.run_function('gem.install', [' '.join(GEM_LIST)])
all_ret = self.run_function('gem.list')
for gem in GEM_LIST:
self.assertIn(gem, all_ret)
single_ret = self.run_function('gem.list', [GEM])
self.assertIn(GEM, single_ret)
self.run_function('gem.uninstall', [' '.join(GEM_LIST)])
|
'gem.list_upgrades'
| def test_list_upgrades(self):
| self.run_function('gem.install', [OLD_GEM], version=OLD_VERSION)
ret = self.run_function('gem.list_upgrades')
self.assertIn(OLD_GEM, ret)
self.run_function('gem.uninstall', [OLD_GEM])
|
'gem.sources_add
gem.sources_remove'
| def test_sources_add_remove(self):
| source = 'http://gems.github.com'
self.run_function('gem.sources_add', [source])
sources_list = self.run_function('gem.sources_list')
self.assertIn(source, sources_list)
self.run_function('gem.sources_remove', [source])
sources_list = self.run_function('gem.sources_list')
self.assertNotIn(source, sources_list)
|
'gem.update'
| def test_update(self):
| if self.run_function('gem.list', [OLD_GEM]):
self.run_function('gem.uninstall', [OLD_GEM])
self.run_function('gem.install', [OLD_GEM], version=OLD_VERSION)
gem_list = self.run_function('gem.list', [OLD_GEM])
self.assertEqual({'thor': ['0.17.0']}, gem_list)
self.run_function('gem.update', [OLD_GEM])
gem_list = self.run_function('gem.list', [OLD_GEM])
self.assertEqual({'thor': ['0.19.4', '0.17.0']}, gem_list)
self.run_function('gem.uninstall', [OLD_GEM])
self.assertFalse(self.run_function('gem.list', [OLD_GEM]))
|
'gem.udpate_system'
| def test_udpate_system(self):
| ret = self.run_function('gem.update_system')
self.assertTrue(ret)
|
'verify that packages are installed'
| def test_list(self):
| ret = self.run_function('pkg.list_pkgs')
self.assertNotEqual(len(ret.keys()), 0)
|
'test package version comparison on supported platforms'
| @requires_salt_modules('pkg.version_cmp')
def test_version_cmp(self):
| func = 'pkg.version_cmp'
os_family = self.run_function('grains.item', ['os_family'])['os_family']
if (os_family == 'Debian'):
lt = ['0.2.4-0ubuntu1', '0.2.4.1-0ubuntu1']
eq = ['0.2.4-0ubuntu1', '0.2.4-0ubuntu1']
gt = ['0.2.4.1-0ubuntu1', '0.2.4-0ubuntu1']
self.assertEqual(self.run_function(func, lt), (-1))
self.assertEqual(self.run_function(func, eq), 0)
self.assertEqual(self.run_function(func, gt), 1)
elif (os_family == 'Suse'):
lt = ['2.3.0-1', '2.3.1-15.1']
eq = ['2.3.1-15.1', '2.3.1-15.1']
gt = ['2.3.2-15.1', '2.3.1-15.1']
self.assertEqual(self.run_function(func, lt), (-1))
self.assertEqual(self.run_function(func, eq), 0)
self.assertEqual(self.run_function(func, gt), 1)
else:
self.skipTest('{0} is unavailable on {1}'.format(func, os_family))
|
'test modifying and deleting a software repository'
| @requires_salt_modules('pkg.mod_repo', 'pkg.del_repo')
@requires_network()
@destructiveTest
def test_mod_del_repo(self):
| os_grain = self.run_function('grains.item', ['os'])['os']
try:
repo = None
if (os_grain == 'Ubuntu'):
repo = 'ppa:otto-kesselgulasch/gimp-edge'
uri = 'http://ppa.launchpad.net/otto-kesselgulasch/gimp-edge/ubuntu'
ret = self.run_function('pkg.mod_repo', [repo, 'comps=main'])
self.assertNotEqual(ret, {})
ret = self.run_function('pkg.get_repo', [repo])
self.assertEqual(ret['uri'], uri)
elif (os_grain == 'CentOS'):
major_release = int(self.run_function('grains.item', ['osmajorrelease'])['osmajorrelease'])
repo = 'saltstack'
name = 'SaltStack repo for RHEL/CentOS {0}'.format(major_release)
baseurl = 'http://repo.saltstack.com/yum/redhat/{0}/x86_64/latest/'.format(major_release)
gpgkey = 'https://repo.saltstack.com/yum/rhel{0}/SALTSTACK-GPG-KEY.pub'.format(major_release)
gpgcheck = 1
enabled = 1
ret = self.run_function('pkg.mod_repo', [repo], name=name, baseurl=baseurl, gpgkey=gpgkey, gpgcheck=gpgcheck, enabled=enabled)
self.assertNotEqual(ret, {})
repo_info = ret[next(iter(ret))]
self.assertIn(repo, repo_info)
self.assertEqual(repo_info[repo]['baseurl'], baseurl)
ret = self.run_function('pkg.get_repo', [repo])
self.assertEqual(ret['baseurl'], baseurl)
finally:
if (repo is not None):
self.run_function('pkg.del_repo', [repo])
|
'test finding the package owning a file'
| @requires_salt_modules('pkg.owner')
def test_owner(self):
| func = 'pkg.owner'
available = self.run_function('sys.doc', [func])
if available:
ret = self.run_function(func, ['/bin/ls'])
self.assertNotEqual(len(ret), 0)
else:
os_grain = self.run_function('grains.item', ['os'])['os']
self.skipTest('{0} is unavailable on {1}'.format(func, os_grain))
|
'successfully install and uninstall a package'
| @requires_network()
@destructiveTest
def test_install_remove(self):
| os_grain = self.run_function('grains.item', ['os'])['os']
os_release = self.run_function('grains.item', ['osrelease'])['osrelease']
pkg = 'htop'
if (os_grain == 'Windows'):
pkg = 'putty'
version = self.run_function('pkg.version', [pkg])
if (os_grain == 'Ubuntu'):
if os_release.startswith('12.'):
self.skipTest('pkg.install and pkg.remove do not work on ubuntu 12 when run from the test suite')
def test_install():
install_ret = self.run_function('pkg.install', [pkg])
self.assertIn(pkg, install_ret)
def test_remove():
remove_ret = self.run_function('pkg.remove', [pkg])
self.assertIn(pkg, remove_ret)
if (version and isinstance(version, dict)):
version = version[pkg]
if version:
test_remove()
test_install()
else:
test_install()
test_remove()
|
'test holding and unholding a package'
| @requires_salt_modules('pkg.hold', 'pkg.unhold')
@requires_network()
@destructiveTest
def test_hold_unhold(self):
| pkg = 'htop'
os_family = self.run_function('grains.item', ['os_family'])['os_family']
os_major_release = self.run_function('grains.item', ['osmajorrelease'])['osmajorrelease']
available = self.run_function('sys.doc', ['pkg.hold'])
if (os_family == 'RedHat'):
if (os_major_release == '5'):
self.skipTest('`yum versionlock` does not seem to work on RHEL/CentOS 5')
if available:
if (os_family == 'RedHat'):
lock_pkg = ('yum-versionlock' if (os_major_release == '5') else 'yum-plugin-versionlock')
versionlock = self.run_function('pkg.version', [lock_pkg])
if (not versionlock):
self.run_function('pkg.install', [lock_pkg])
hold_ret = self.run_function('pkg.hold', [pkg])
self.assertIn(pkg, hold_ret)
self.assertTrue(hold_ret[pkg]['result'])
unhold_ret = self.run_function('pkg.unhold', [pkg])
self.assertIn(pkg, unhold_ret)
self.assertTrue(hold_ret[pkg]['result'])
if (os_family == 'RedHat'):
if (not versionlock):
self.run_function('pkg.remove', [lock_pkg])
else:
os_grain = self.run_function('grains.item', ['os'])['os']
self.skipTest('{0} is unavailable on {1}'.format('pkg.hold', os_grain))
|
'test refreshing the package database'
| @requires_network()
@destructiveTest
def test_refresh_db(self):
| func = 'pkg.refresh_db'
os_family = self.run_function('grains.item', ['os_family'])['os_family']
rtag = salt.utils.pkg.rtag(self.minion_opts)
salt.utils.pkg.write_rtag(self.minion_opts)
self.assertTrue(os.path.isfile(rtag))
if (os_family == 'RedHat'):
ret = self.run_function(func)
self.assertIn(ret, (True, None))
elif (os_family == 'Suse'):
ret = self.run_function(func)
if (not isinstance(ret, dict)):
self.skipTest('Upstream repo did not return coherent results. Skipping test.')
self.assertNotEqual(ret, {})
elif (os_family == 'Debian'):
ret = self.run_function(func)
if (not isinstance(ret, dict)):
self.skipTest('{0} encountered an error: {1}'.format(func, ret))
self.assertNotEqual(ret, {})
if (not isinstance(ret, dict)):
self.skipTest('Upstream repo did not return coherent results. Skipping test.')
for (source, state) in ret.items():
self.assertIn(state, (True, False, None))
else:
os_grain = self.run_function('grains.item', ['os'])['os']
self.skipTest('{0} is unavailable on {1}'.format(func, os_grain))
self.assertFalse(os.path.isfile(rtag))
|
'Test returning useful information on Ubuntu systems.'
| @requires_salt_modules('pkg.info_installed')
def test_pkg_info(self):
| func = 'pkg.info_installed'
os_family = self.run_function('grains.item', ['os_family'])['os_family']
if (os_family == 'Debian'):
ret = self.run_function(func, ['bash-completion', 'dpkg'])
keys = ret.keys()
self.assertIn('bash-completion', keys)
self.assertIn('dpkg', keys)
elif (os_family == 'RedHat'):
ret = self.run_function(func, ['rpm', 'yum'])
keys = ret.keys()
self.assertIn('rpm', keys)
self.assertIn('yum', keys)
elif (os_family == 'Suse'):
ret = self.run_function(func, ['less', 'zypper'])
keys = ret.keys()
self.assertIn('less', keys)
self.assertIn('zypper', keys)
|
'Test running a system upgrade when there are packages that need upgrading'
| @requires_network()
@destructiveTest
@skipIf(salt.utils.platform.is_windows(), 'pkg.upgrade not available on Windows')
def test_pkg_upgrade_has_pending_upgrades(self):
| func = 'pkg.upgrade'
os_family = self.run_function('grains.item', ['os_family'])['os_family']
self.run_function('pkg.refresh_db')
if (os_family == 'Suse'):
vim_version_dict = self.run_function('pkg.latest_version', ['vim'])
vim_info = self.run_function('pkg.info_available', ['vim'])['vim']
if (vim_version_dict == {}):
vim_version = ('version=<' + vim_info['version'])
else:
vim_version = ('version=<' + vim_version_dict)
if ('out-of-date' not in vim_info['status']):
ret = self.run_function('pkg.install', ['vim', vim_version])
if (not isinstance(ret, dict)):
if ret.startswith('ERROR'):
self.skipTest('Could not install earlier vim to complete test.')
else:
self.assertNotEqual(ret, {})
ret = self.run_function(func)
if ('changes' in ret):
self.assertIn('vim', ret['changes'])
else:
self.assertIn('vim', ret)
else:
ret = self.run_function('pkg.list_upgrades')
if ((ret == '') or (ret == {})):
self.skipTest('No updates available for this machine. Skipping pkg.upgrade test.')
else:
ret = self.run_function(func)
if ('Problem encountered' in ret):
self.skipTest('A problem was encountered when running pkg.upgrade. This test is meant to catch no-ops or problems with the salt function itself, not problems with actual package installation. Skipping.')
self.assertNotEqual(ret, {})
if ('changes' in ret):
self.assertNotEqual(ret['changes'], {})
|
'Get current settings'
| def setUp(self):
| self.run_function('user.add', [TEST_USER])
|
'Reset to original settings'
| def tearDown(self):
| self.run_function('user.delete', [TEST_USER])
|
'Test shadow.info'
| def test_info(self):
| ret = self.run_function('shadow.info', [TEST_USER])
self.assertEqual(ret['name'], TEST_USER)
ret = self.run_function('shadow.info', [NO_USER])
self.assertEqual(ret['name'], '')
|
'Test shadow.get_account_created'
| @destructiveTest
def test_get_account_created(self):
| text_date = self.run_function('shadow.get_account_created', [TEST_USER])
self.assertNotEqual(text_date, 'Invalid Timestamp')
obj_date = datetime.datetime.strptime(text_date, '%Y-%m-%d %H:%M:%S')
self.assertIsInstance(obj_date, datetime.date)
self.assertEqual(self.run_function('shadow.get_account_created', [NO_USER]), 'ERROR: User not found: {0}'.format(NO_USER))
|
'Test shadow.get_last_change'
| @destructiveTest
def test_get_last_change(self):
| text_date = self.run_function('shadow.get_last_change', [TEST_USER])
self.assertNotEqual(text_date, 'Invalid Timestamp')
obj_date = datetime.datetime.strptime(text_date, '%Y-%m-%d %H:%M:%S')
self.assertIsInstance(obj_date, datetime.date)
self.assertEqual(self.run_function('shadow.get_last_change', [NO_USER]), 'ERROR: User not found: {0}'.format(NO_USER))
|
'Test shadow.get_login_failed_last'
| @destructiveTest
def test_get_login_failed_last(self):
| text_date = self.run_function('shadow.get_login_failed_last', [TEST_USER])
self.assertNotEqual(text_date, 'Invalid Timestamp')
obj_date = datetime.datetime.strptime(text_date, '%Y-%m-%d %H:%M:%S')
self.assertIsInstance(obj_date, datetime.date)
self.assertEqual(self.run_function('shadow.get_login_failed_last', [NO_USER]), 'ERROR: User not found: {0}'.format(NO_USER))
|
'Test shadow.get_login_failed_count'
| @destructiveTest
def test_get_login_failed_count(self):
| self.assertEqual(self.run_function('shadow.get_login_failed_count', [TEST_USER]), '0')
self.assertEqual(self.run_function('shadow.get_login_failed_count', [NO_USER]), 'ERROR: User not found: {0}'.format(NO_USER))
|
'Test shadow.get_maxdays
Test shadow.set_maxdays'
| @destructiveTest
def test_get_set_maxdays(self):
| self.assertTrue(self.run_function('shadow.set_maxdays', [TEST_USER, 20]))
self.assertEqual(self.run_function('shadow.get_maxdays', [TEST_USER]), 20)
self.assertEqual(self.run_function('shadow.set_maxdays', [NO_USER, 7]), 'ERROR: User not found: {0}'.format(NO_USER))
self.assertEqual(self.run_function('shadow.get_maxdays', [NO_USER]), 'ERROR: User not found: {0}'.format(NO_USER))
|
'Test shadow.get_change
Test shadow.set_change'
| @destructiveTest
def test_get_set_change(self):
| self.assertTrue(self.run_function('shadow.set_change', [TEST_USER, '02/11/2011']))
self.assertEqual(self.run_function('shadow.get_change', [TEST_USER]), '02/11/2011')
self.assertEqual(self.run_function('shadow.set_change', [NO_USER, '02/11/2012']), 'ERROR: User not found: {0}'.format(NO_USER))
self.assertEqual(self.run_function('shadow.get_change', [NO_USER]), 'ERROR: User not found: {0}'.format(NO_USER))
|
'Test shadow.get_expire
Test shadow.set_expire'
| @destructiveTest
def test_get_set_expire(self):
| self.assertTrue(self.run_function('shadow.set_expire', [TEST_USER, '02/11/2011']))
self.assertEqual(self.run_function('shadow.get_expire', [TEST_USER]), '02/11/2011')
self.assertEqual(self.run_function('shadow.set_expire', [NO_USER, '02/11/2012']), 'ERROR: User not found: {0}'.format(NO_USER))
self.assertEqual(self.run_function('shadow.get_expire', [NO_USER]), 'ERROR: User not found: {0}'.format(NO_USER))
|
'Test shadow.del_password'
| @destructiveTest
def test_del_password(self):
| self.assertTrue(self.run_function('shadow.del_password', [TEST_USER]))
self.assertEqual(self.run_function('shadow.info', [TEST_USER])['passwd'], '*')
self.assertEqual(self.run_function('shadow.del_password', [NO_USER]), 'ERROR: User not found: {0}'.format(NO_USER))
|
'Test shadow.set_password'
| @destructiveTest
def test_set_password(self):
| self.assertTrue(self.run_function('shadow.set_password', [TEST_USER, 'Pa$$W0rd']))
self.assertEqual(self.run_function('shadow.set_password', [NO_USER, 'P@SSw0rd']), 'ERROR: User not found: {0}'.format(NO_USER))
|
'Sets up test requirements'
| def setUp(self):
| os_grain = self.run_function('grains.item', ['kernel'])
if (os_grain['kernel'] not in 'Darwin'):
self.skipTest("Test not applicable to '{kernel}' kernel".format(**os_grain))
|
'Tests the add group function'
| def test_mac_group_add(self):
| try:
self.run_function('group.add', [ADD_GROUP, 3456])
group_info = self.run_function('group.info', [ADD_GROUP])
self.assertEqual(group_info['name'], ADD_GROUP)
except CommandExecutionError:
self.run_function('group.delete', [ADD_GROUP])
raise
|
'Tests the delete group function'
| def test_mac_group_delete(self):
| if (self.run_function('group.add', [DEL_GROUP, 4567]) is not True):
self.run_function('group.delete', [DEL_GROUP])
self.skipTest('Failed to create a group to delete')
try:
ret = self.run_function('group.delete', [DEL_GROUP])
self.assertTrue(ret)
except CommandExecutionError:
raise
|
'Tests changing the group id'
| def test_mac_group_chgid(self):
| if (self.run_function('group.add', [CHANGE_GROUP, 5678]) is not True):
self.run_function('group.delete', [CHANGE_GROUP])
self.skipTest('Failed to create a group to manipulate')
try:
self.run_function('group.chgid', [CHANGE_GROUP, 6789])
group_info = self.run_function('group.info', [CHANGE_GROUP])
self.assertEqual(group_info['gid'], 6789)
except AssertionError:
self.run_function('group.delete', [CHANGE_GROUP])
raise
|
'Tests adding user to the group'
| def test_mac_adduser(self):
| if (self.run_function('group.add', [ADD_GROUP, 5678]) is not True):
self.run_function('group.delete', [ADD_GROUP])
self.skipTest('Failed to create a group to manipulate')
try:
self.run_function('group.adduser', [ADD_GROUP, ADD_USER])
group_info = self.run_function('group.info', [ADD_GROUP])
self.assertEqual(ADD_USER, ''.join(group_info['members']))
except AssertionError:
self.run_function('group.delete', [ADD_GROUP])
raise
|
'Test deleting user from a group'
| def test_mac_deluser(self):
| if (self.run_function('group.add', [ADD_GROUP, 5678]) and (self.run_function('group.adduser', [ADD_GROUP, ADD_USER]) is not True)):
self.run_function('group.delete', [ADD_GROUP])
self.skipTest('Failed to create a group to manipulate')
delusr = self.run_function('group.deluser', [ADD_GROUP, ADD_USER])
self.assertTrue(delusr)
group_info = self.run_function('group.info', [ADD_GROUP])
self.assertNotIn(ADD_USER, ''.join(group_info['members']))
|
'Test replacing members of a group'
| def test_mac_members(self):
| if (self.run_function('group.add', [ADD_GROUP, 5678]) and (self.run_function('group.adduser', [ADD_GROUP, ADD_USER]) is not True)):
self.run_function('group.delete', [ADD_GROUP])
self.skipTest('Failed to create the {0} group or add user {1} to group to manipulate'.format(ADD_GROUP, ADD_USER))
rep_group_mem = self.run_function('group.members', [ADD_GROUP, REP_USER_GROUP])
self.assertTrue(rep_group_mem)
group_info = self.run_function('group.info', [ADD_GROUP])
self.assertIn(REP_USER_GROUP, str(group_info['members']))
self.assertNotIn(ADD_USER, str(group_info['members']))
|
'Test returning info on all groups'
| def test_mac_getent(self):
| if (self.run_function('group.add', [ADD_GROUP, 5678]) and (self.run_function('group.adduser', [ADD_GROUP, ADD_USER]) is not True)):
self.run_function('group.delete', [ADD_GROUP])
self.skipTest('Failed to create the {0} group or add user {1} to group to manipulate'.format(ADD_GROUP, ADD_USER))
getinfo = self.run_function('group.getent')
self.assertTrue(getinfo)
self.assertIn(ADD_GROUP, str(getinfo))
self.assertIn(ADD_USER, str(getinfo))
|
'Clean up after tests'
| def tearDown(self):
| add_info = self.run_function('group.info', [ADD_GROUP])
if add_info:
self.run_function('group.delete', [ADD_GROUP])
del_info = self.run_function('group.info', [DEL_GROUP])
if del_info:
self.run_function('group.delete', [DEL_GROUP])
change_info = self.run_function('group.info', [CHANGE_GROUP])
if change_info:
self.run_function('group.delete', [CHANGE_GROUP])
|
'Get current settings'
| def setUp(self):
| os_grain = self.run_function('grains.item', ['os_family'])
if (os_grain['os_family'] != 'NILinuxRT'):
self.skipTest('Tests applicable only to NILinuxRT')
super(Nilrt_ipModuleTest, self).setUp()
self.run_function('file.copy', ['/var/lib/connman', '/tmp/connman', 'recurse=True', 'remove_existing=True'])
|
'Reset to original settings'
| def tearDown(self):
| self.run_function('file.copy', ['/tmp/connman', '/var/lib/connman', 'recurse=True', 'remove_existing=True'])
self.run_function('service.restart', ['connman'])
time.sleep(10)
interfaces = self.__interfaces()
for interface in interfaces:
self.run_function('ip.up', [interface])
|
'Get current settings'
| def setUp(self):
| super(ShadowModuleTest, self).setUp()
os_grain = self.run_function('grains.item', ['kernel'])
if (os_grain['kernel'] not in 'Linux'):
self.skipTest("Test not applicable to '{kernel}' kernel".format(**os_grain))
|
'Reset to original settings'
| def tearDown(self):
| self.run_function('user.delete', [self._test_user])
|
'Generates a random username'
| def __random_string(self, size=6):
| return ('tu-' + ''.join((random.choice((string.ascii_lowercase + string.digits)) for x in range(size))))
|
'Test shadow.info'
| @destructiveTest
def test_info(self):
| self.run_function('user.add', [self._test_user])
ret = self.run_function('shadow.info', [self._test_user])
self.assertEqual(ret['name'], self._test_user)
ret = self.run_function('shadow.info', [self._no_user])
self.assertEqual(ret['name'], '')
|
'Test shadow.del_password'
| @destructiveTest
def test_del_password(self):
| self.run_function('user.add', [self._test_user])
self.assertTrue(self.run_function('shadow.del_password', [self._test_user]))
self.assertEqual(self.run_function('shadow.info', [self._test_user])['passwd'], '')
self.assertFalse(self.run_function('shadow.del_password', [self._no_user]))
|
'Test shadow.set_password'
| @destructiveTest
def test_set_password(self):
| self.run_function('user.add', [self._test_user])
self.assertTrue(self.run_function('shadow.set_password', [self._test_user, self._password]))
self.assertFalse(self.run_function('shadow.set_password', [self._no_user, self._password]))
|
'Test shadow.set_inactdays'
| @destructiveTest
def test_set_inactdays(self):
| self.run_function('user.add', [self._test_user])
self.assertTrue(self.run_function('shadow.set_inactdays', [self._test_user, 12]))
self.assertFalse(self.run_function('shadow.set_inactdays', [self._no_user, 12]))
|
'Test shadow.set_maxdays'
| @destructiveTest
def test_set_maxdays(self):
| self.run_function('user.add', [self._test_user])
self.assertTrue(self.run_function('shadow.set_maxdays', [self._test_user, 12]))
self.assertFalse(self.run_function('shadow.set_maxdays', [self._no_user, 12]))
|
'Test shadow.set_mindays'
| @destructiveTest
def test_set_mindays(self):
| self.run_function('user.add', [self._test_user])
self.assertTrue(self.run_function('shadow.set_mindays', [self._test_user, 12]))
self.assertFalse(self.run_function('shadow.set_mindays', [self._no_user, 12]))
|
'Test shadow.lock_password'
| @destructiveTest
def test_lock_password(self):
| self.run_function('user.add', [self._test_user])
self.run_function('shadow.set_password', [self._test_user, self._password])
self.assertTrue(self.run_function('shadow.lock_password', [self._test_user]))
self.assertFalse(self.run_function('shadow.lock_password', [self._no_user]))
|
'Test shadow.lock_password'
| @destructiveTest
def test_unlock_password(self):
| self.run_function('user.add', [self._test_user])
self.run_function('shadow.set_password', [self._test_user, self._password])
self.assertTrue(self.run_function('shadow.unlock_password', [self._test_user]))
self.assertFalse(self.run_function('shadow.unlock_password', [self._no_user]))
|
'Test shadow.set_warndays'
| @destructiveTest
def test_set_warndays(self):
| self.run_function('user.add', [self._test_user])
self.assertTrue(self.run_function('shadow.set_warndays', [self._test_user, 12]))
self.assertFalse(self.run_function('shadow.set_warndays', [self._no_user, 12]))
|
'Test shadow.set_date'
| @destructiveTest
def test_set_date(self):
| self.run_function('user.add', [self._test_user])
self.assertTrue(self.run_function('shadow.set_date', [self._test_user, '2016-08-19']))
self.assertFalse(self.run_function('shadow.set_date', [self._no_user, '2016-08-19']))
|
'Test shadow.set_exipre'
| @destructiveTest
def test_set_expire(self):
| self.run_function('user.add', [self._test_user])
self.assertTrue(self.run_function('shadow.set_expire', [self._test_user, '2016-08-25']))
self.assertFalse(self.run_function('shadow.set_expire', [self._no_user, '2016-08-25']))
|
'Test set/del password for root'
| @destructiveTest
def test_set_del_root_password(self):
| if (not os.access('/etc/shadow', (os.R_OK | os.W_OK))):
self.skipTest('Could not save initial state of /etc/shadow')
with salt.utils.files.fopen('/etc/shadow', 'r') as sFile:
shadow = sFile.read()
self.assertTrue(self.run_function('shadow.set_password', ['root', self._password]))
self.assertEqual(self.run_function('shadow.info', ['root'])['passwd'], self._password)
self.assertTrue(self.run_function('shadow.del_password', ['root']))
self.assertEqual(self.run_function('shadow.info', ['root'])['passwd'], '')
with salt.utils.files.fopen('/etc/shadow', 'w') as sFile:
sFile.write(shadow)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.