2016-07-07 20:42:27 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
'''
|
2016-08-30 21:43:28 +00:00
|
|
|
Tests for the archive state
|
2016-07-07 20:42:27 +00:00
|
|
|
'''
|
Use explicit unicode strings + break up salt.utils
This PR is part of what will be an ongoing effort to use explicit
unicode strings in Salt. Because Python 3 does not suport Python 2's raw
unicode string syntax (i.e. `ur'\d+'`), we must use
`salt.utils.locales.sdecode()` to ensure that the raw string is unicode.
However, because of how `salt/utils/__init__.py` has evolved into the
hulking monstrosity it is today, this means importing a large module in
places where it is not needed, which could negatively impact
performance. For this reason, this PR also breaks out some of the
functions from `salt/utils/__init__.py` into new/existing modules under
`salt/utils/`. The long term goal will be that the modules within this
directory do not depend on importing `salt.utils`.
A summary of the changes in this PR is as follows:
* Moves the following functions from `salt.utils` to new locations
(including a deprecation warning if invoked from `salt.utils`):
`to_bytes`, `to_str`, `to_unicode`, `str_to_num`, `is_quoted`,
`dequote`, `is_hex`, `is_bin_str`, `rand_string`,
`contains_whitespace`, `clean_kwargs`, `invalid_kwargs`, `which`,
`which_bin`, `path_join`, `shlex_split`, `rand_str`, `is_windows`,
`is_proxy`, `is_linux`, `is_darwin`, `is_sunos`, `is_smartos`,
`is_smartos_globalzone`, `is_smartos_zone`, `is_freebsd`, `is_netbsd`,
`is_openbsd`, `is_aix`
* Moves the functions already deprecated by @rallytime to the bottom of
`salt/utils/__init__.py` for better organization, so we can keep the
deprecated ones separate from the ones yet to be deprecated as we
continue to break up `salt.utils`
* Updates `salt/*.py` and all files under `salt/client/` to use explicit
unicode string literals.
* Gets rid of implicit imports of `salt.utils` (e.g. `from salt.utils
import foo` becomes `import salt.utils.foo as foo`).
* Renames the `test.rand_str` function to `test.random_hash` to more
accurately reflect what it does
* Modifies `salt.utils.stringutils.random()` (née `salt.utils.rand_string()`)
such that it returns a string matching the passed size. Previously
this function would get `size` bytes from `os.urandom()`,
base64-encode it, and return the result, which would in most cases not
be equal to the passed size.
2017-07-25 01:47:15 +00:00
|
|
|
# Import Python libs
|
2016-07-07 20:42:27 +00:00
|
|
|
from __future__ import absolute_import
|
2016-12-15 03:57:14 +00:00
|
|
|
import errno
|
|
|
|
import logging
|
2016-07-07 20:42:27 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
# Import Salt Testing libs
|
2017-04-03 16:04:09 +00:00
|
|
|
from tests.support.case import ModuleCase
|
2017-04-21 20:35:51 +00:00
|
|
|
from tests.support.helpers import skip_if_not_root, Webserver
|
2017-04-02 16:09:47 +00:00
|
|
|
from tests.support.mixins import SaltReturnAssertsMixin
|
2017-06-28 16:48:37 +00:00
|
|
|
from tests.support.paths import FILES
|
2016-07-07 20:42:27 +00:00
|
|
|
|
Use explicit unicode strings + break up salt.utils
This PR is part of what will be an ongoing effort to use explicit
unicode strings in Salt. Because Python 3 does not suport Python 2's raw
unicode string syntax (i.e. `ur'\d+'`), we must use
`salt.utils.locales.sdecode()` to ensure that the raw string is unicode.
However, because of how `salt/utils/__init__.py` has evolved into the
hulking monstrosity it is today, this means importing a large module in
places where it is not needed, which could negatively impact
performance. For this reason, this PR also breaks out some of the
functions from `salt/utils/__init__.py` into new/existing modules under
`salt/utils/`. The long term goal will be that the modules within this
directory do not depend on importing `salt.utils`.
A summary of the changes in this PR is as follows:
* Moves the following functions from `salt.utils` to new locations
(including a deprecation warning if invoked from `salt.utils`):
`to_bytes`, `to_str`, `to_unicode`, `str_to_num`, `is_quoted`,
`dequote`, `is_hex`, `is_bin_str`, `rand_string`,
`contains_whitespace`, `clean_kwargs`, `invalid_kwargs`, `which`,
`which_bin`, `path_join`, `shlex_split`, `rand_str`, `is_windows`,
`is_proxy`, `is_linux`, `is_darwin`, `is_sunos`, `is_smartos`,
`is_smartos_globalzone`, `is_smartos_zone`, `is_freebsd`, `is_netbsd`,
`is_openbsd`, `is_aix`
* Moves the functions already deprecated by @rallytime to the bottom of
`salt/utils/__init__.py` for better organization, so we can keep the
deprecated ones separate from the ones yet to be deprecated as we
continue to break up `salt.utils`
* Updates `salt/*.py` and all files under `salt/client/` to use explicit
unicode string literals.
* Gets rid of implicit imports of `salt.utils` (e.g. `from salt.utils
import foo` becomes `import salt.utils.foo as foo`).
* Renames the `test.rand_str` function to `test.random_hash` to more
accurately reflect what it does
* Modifies `salt.utils.stringutils.random()` (née `salt.utils.rand_string()`)
such that it returns a string matching the passed size. Previously
this function would get `size` bytes from `os.urandom()`,
base64-encode it, and return the result, which would in most cases not
be equal to the passed size.
2017-07-25 01:47:15 +00:00
|
|
|
# Import Salt libs
|
2017-07-18 16:48:54 +00:00
|
|
|
import salt.utils.files
|
Use explicit unicode strings + break up salt.utils
This PR is part of what will be an ongoing effort to use explicit
unicode strings in Salt. Because Python 3 does not suport Python 2's raw
unicode string syntax (i.e. `ur'\d+'`), we must use
`salt.utils.locales.sdecode()` to ensure that the raw string is unicode.
However, because of how `salt/utils/__init__.py` has evolved into the
hulking monstrosity it is today, this means importing a large module in
places where it is not needed, which could negatively impact
performance. For this reason, this PR also breaks out some of the
functions from `salt/utils/__init__.py` into new/existing modules under
`salt/utils/`. The long term goal will be that the modules within this
directory do not depend on importing `salt.utils`.
A summary of the changes in this PR is as follows:
* Moves the following functions from `salt.utils` to new locations
(including a deprecation warning if invoked from `salt.utils`):
`to_bytes`, `to_str`, `to_unicode`, `str_to_num`, `is_quoted`,
`dequote`, `is_hex`, `is_bin_str`, `rand_string`,
`contains_whitespace`, `clean_kwargs`, `invalid_kwargs`, `which`,
`which_bin`, `path_join`, `shlex_split`, `rand_str`, `is_windows`,
`is_proxy`, `is_linux`, `is_darwin`, `is_sunos`, `is_smartos`,
`is_smartos_globalzone`, `is_smartos_zone`, `is_freebsd`, `is_netbsd`,
`is_openbsd`, `is_aix`
* Moves the functions already deprecated by @rallytime to the bottom of
`salt/utils/__init__.py` for better organization, so we can keep the
deprecated ones separate from the ones yet to be deprecated as we
continue to break up `salt.utils`
* Updates `salt/*.py` and all files under `salt/client/` to use explicit
unicode string literals.
* Gets rid of implicit imports of `salt.utils` (e.g. `from salt.utils
import foo` becomes `import salt.utils.foo as foo`).
* Renames the `test.rand_str` function to `test.random_hash` to more
accurately reflect what it does
* Modifies `salt.utils.stringutils.random()` (née `salt.utils.rand_string()`)
such that it returns a string matching the passed size. Previously
this function would get `size` bytes from `os.urandom()`,
base64-encode it, and return the result, which would in most cases not
be equal to the passed size.
2017-07-25 01:47:15 +00:00
|
|
|
import salt.utils.platform
|
2016-07-07 20:42:27 +00:00
|
|
|
|
2016-12-15 03:57:14 +00:00
|
|
|
# Setup logging
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
Use explicit unicode strings + break up salt.utils
This PR is part of what will be an ongoing effort to use explicit
unicode strings in Salt. Because Python 3 does not suport Python 2's raw
unicode string syntax (i.e. `ur'\d+'`), we must use
`salt.utils.locales.sdecode()` to ensure that the raw string is unicode.
However, because of how `salt/utils/__init__.py` has evolved into the
hulking monstrosity it is today, this means importing a large module in
places where it is not needed, which could negatively impact
performance. For this reason, this PR also breaks out some of the
functions from `salt/utils/__init__.py` into new/existing modules under
`salt/utils/`. The long term goal will be that the modules within this
directory do not depend on importing `salt.utils`.
A summary of the changes in this PR is as follows:
* Moves the following functions from `salt.utils` to new locations
(including a deprecation warning if invoked from `salt.utils`):
`to_bytes`, `to_str`, `to_unicode`, `str_to_num`, `is_quoted`,
`dequote`, `is_hex`, `is_bin_str`, `rand_string`,
`contains_whitespace`, `clean_kwargs`, `invalid_kwargs`, `which`,
`which_bin`, `path_join`, `shlex_split`, `rand_str`, `is_windows`,
`is_proxy`, `is_linux`, `is_darwin`, `is_sunos`, `is_smartos`,
`is_smartos_globalzone`, `is_smartos_zone`, `is_freebsd`, `is_netbsd`,
`is_openbsd`, `is_aix`
* Moves the functions already deprecated by @rallytime to the bottom of
`salt/utils/__init__.py` for better organization, so we can keep the
deprecated ones separate from the ones yet to be deprecated as we
continue to break up `salt.utils`
* Updates `salt/*.py` and all files under `salt/client/` to use explicit
unicode string literals.
* Gets rid of implicit imports of `salt.utils` (e.g. `from salt.utils
import foo` becomes `import salt.utils.foo as foo`).
* Renames the `test.rand_str` function to `test.random_hash` to more
accurately reflect what it does
* Modifies `salt.utils.stringutils.random()` (née `salt.utils.rand_string()`)
such that it returns a string matching the passed size. Previously
this function would get `size` bytes from `os.urandom()`,
base64-encode it, and return the result, which would in most cases not
be equal to the passed size.
2017-07-25 01:47:15 +00:00
|
|
|
ARCHIVE_DIR = os.path.join('c:/', 'tmp') \
|
|
|
|
if salt.utils.platform.is_windows() \
|
|
|
|
else '/tmp/archive'
|
2016-07-22 23:51:41 +00:00
|
|
|
|
2017-06-26 16:08:47 +00:00
|
|
|
ARCHIVE_NAME = 'custom.tar.gz'
|
2017-06-28 16:48:37 +00:00
|
|
|
ARCHIVE_TAR_SOURCE = 'http://localhost:{0}/{1}'.format(9999, ARCHIVE_NAME)
|
|
|
|
ARCHIVE_LOCAL_TAR_SOURCE = 'file://{0}'.format(os.path.join(FILES, 'file', 'base', ARCHIVE_NAME))
|
2016-12-15 03:57:14 +00:00
|
|
|
UNTAR_FILE = os.path.join(ARCHIVE_DIR, 'custom/README')
|
2016-08-30 21:43:28 +00:00
|
|
|
ARCHIVE_TAR_HASH = 'md5=7643861ac07c30fe7d2310e9f25ca514'
|
2017-06-26 16:08:47 +00:00
|
|
|
ARCHIVE_TAR_BAD_HASH = 'md5=d41d8cd98f00b204e9800998ecf8427e'
|
2017-01-18 18:03:55 +00:00
|
|
|
|
2016-08-30 21:43:28 +00:00
|
|
|
|
2017-04-03 16:04:09 +00:00
|
|
|
class ArchiveTest(ModuleCase, SaltReturnAssertsMixin):
|
2016-08-30 21:43:28 +00:00
|
|
|
'''
|
2016-09-12 21:43:06 +00:00
|
|
|
Validate the archive state
|
2016-08-30 21:43:28 +00:00
|
|
|
'''
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
2017-04-21 20:35:51 +00:00
|
|
|
cls.webserver = Webserver()
|
|
|
|
cls.webserver.start()
|
|
|
|
cls.archive_tar_source = cls.webserver.url('custom.tar.gz')
|
2016-07-07 20:42:27 +00:00
|
|
|
|
2016-08-30 21:43:28 +00:00
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
2017-04-21 20:35:51 +00:00
|
|
|
cls.webserver.stop()
|
2016-08-30 21:43:28 +00:00
|
|
|
|
2016-12-15 03:57:14 +00:00
|
|
|
def setUp(self):
|
|
|
|
self._clear_archive_dir()
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
self._clear_archive_dir()
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _clear_archive_dir():
|
|
|
|
try:
|
2017-07-18 16:48:54 +00:00
|
|
|
salt.utils.files.rm_rf(ARCHIVE_DIR)
|
2016-12-15 03:57:14 +00:00
|
|
|
except OSError as exc:
|
|
|
|
if exc.errno != errno.ENOENT:
|
|
|
|
raise
|
|
|
|
|
|
|
|
def _check_extracted(self, path):
|
2016-07-07 20:42:27 +00:00
|
|
|
'''
|
|
|
|
function to check if file was extracted
|
|
|
|
'''
|
2016-12-15 03:57:14 +00:00
|
|
|
log.debug('Checking for extracted file: %s', path)
|
|
|
|
self.assertTrue(os.path.isfile(path))
|
2016-07-07 20:42:27 +00:00
|
|
|
|
|
|
|
def test_archive_extracted_skip_verify(self):
|
|
|
|
'''
|
|
|
|
test archive.extracted with skip_verify
|
|
|
|
'''
|
|
|
|
ret = self.run_state('archive.extracted', name=ARCHIVE_DIR,
|
2017-03-11 16:00:28 +00:00
|
|
|
source=self.archive_tar_source, archive_format='tar',
|
2016-07-07 20:42:27 +00:00
|
|
|
skip_verify=True)
|
2016-12-15 03:57:14 +00:00
|
|
|
log.debug('ret = %s', ret)
|
2016-11-16 16:23:39 +00:00
|
|
|
if 'Timeout' in ret:
|
|
|
|
self.skipTest('Timeout talking to local tornado server.')
|
2016-07-07 20:42:27 +00:00
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
|
2016-12-15 03:57:14 +00:00
|
|
|
self._check_extracted(UNTAR_FILE)
|
2016-07-07 20:42:27 +00:00
|
|
|
|
|
|
|
def test_archive_extracted_with_source_hash(self):
|
|
|
|
'''
|
|
|
|
test archive.extracted without skip_verify
|
2016-07-22 23:51:41 +00:00
|
|
|
only external resources work to check to
|
|
|
|
ensure source_hash is verified correctly
|
2016-07-07 20:42:27 +00:00
|
|
|
'''
|
|
|
|
ret = self.run_state('archive.extracted', name=ARCHIVE_DIR,
|
2017-03-11 16:00:28 +00:00
|
|
|
source=self.archive_tar_source, archive_format='tar',
|
2016-07-07 20:42:27 +00:00
|
|
|
source_hash=ARCHIVE_TAR_HASH)
|
2016-12-15 03:57:14 +00:00
|
|
|
log.debug('ret = %s', ret)
|
2016-11-16 16:23:39 +00:00
|
|
|
if 'Timeout' in ret:
|
|
|
|
self.skipTest('Timeout talking to local tornado server.')
|
|
|
|
|
2016-07-07 20:42:27 +00:00
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
|
2016-12-15 03:57:14 +00:00
|
|
|
self._check_extracted(UNTAR_FILE)
|
2016-07-07 20:42:27 +00:00
|
|
|
|
2017-04-04 17:57:27 +00:00
|
|
|
@skip_if_not_root
|
2016-11-30 19:11:41 +00:00
|
|
|
def test_archive_extracted_with_root_user_and_group(self):
|
|
|
|
'''
|
2016-12-15 03:57:14 +00:00
|
|
|
test archive.extracted with user and group set to "root"
|
2016-11-30 19:11:41 +00:00
|
|
|
'''
|
2017-06-05 21:16:54 +00:00
|
|
|
r_group = 'root'
|
Use explicit unicode strings + break up salt.utils
This PR is part of what will be an ongoing effort to use explicit
unicode strings in Salt. Because Python 3 does not suport Python 2's raw
unicode string syntax (i.e. `ur'\d+'`), we must use
`salt.utils.locales.sdecode()` to ensure that the raw string is unicode.
However, because of how `salt/utils/__init__.py` has evolved into the
hulking monstrosity it is today, this means importing a large module in
places where it is not needed, which could negatively impact
performance. For this reason, this PR also breaks out some of the
functions from `salt/utils/__init__.py` into new/existing modules under
`salt/utils/`. The long term goal will be that the modules within this
directory do not depend on importing `salt.utils`.
A summary of the changes in this PR is as follows:
* Moves the following functions from `salt.utils` to new locations
(including a deprecation warning if invoked from `salt.utils`):
`to_bytes`, `to_str`, `to_unicode`, `str_to_num`, `is_quoted`,
`dequote`, `is_hex`, `is_bin_str`, `rand_string`,
`contains_whitespace`, `clean_kwargs`, `invalid_kwargs`, `which`,
`which_bin`, `path_join`, `shlex_split`, `rand_str`, `is_windows`,
`is_proxy`, `is_linux`, `is_darwin`, `is_sunos`, `is_smartos`,
`is_smartos_globalzone`, `is_smartos_zone`, `is_freebsd`, `is_netbsd`,
`is_openbsd`, `is_aix`
* Moves the functions already deprecated by @rallytime to the bottom of
`salt/utils/__init__.py` for better organization, so we can keep the
deprecated ones separate from the ones yet to be deprecated as we
continue to break up `salt.utils`
* Updates `salt/*.py` and all files under `salt/client/` to use explicit
unicode string literals.
* Gets rid of implicit imports of `salt.utils` (e.g. `from salt.utils
import foo` becomes `import salt.utils.foo as foo`).
* Renames the `test.rand_str` function to `test.random_hash` to more
accurately reflect what it does
* Modifies `salt.utils.stringutils.random()` (née `salt.utils.rand_string()`)
such that it returns a string matching the passed size. Previously
this function would get `size` bytes from `os.urandom()`,
base64-encode it, and return the result, which would in most cases not
be equal to the passed size.
2017-07-25 01:47:15 +00:00
|
|
|
if salt.utils.platform.is_darwin():
|
2017-06-05 21:16:54 +00:00
|
|
|
r_group = 'wheel'
|
2016-11-30 19:11:41 +00:00
|
|
|
ret = self.run_state('archive.extracted', name=ARCHIVE_DIR,
|
2017-03-11 16:00:28 +00:00
|
|
|
source=self.archive_tar_source, archive_format='tar',
|
2016-11-30 19:11:41 +00:00
|
|
|
source_hash=ARCHIVE_TAR_HASH,
|
2017-06-05 21:16:54 +00:00
|
|
|
user='root', group=r_group)
|
2016-12-15 03:57:14 +00:00
|
|
|
log.debug('ret = %s', ret)
|
|
|
|
if 'Timeout' in ret:
|
|
|
|
self.skipTest('Timeout talking to local tornado server.')
|
|
|
|
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
|
|
|
|
self._check_extracted(UNTAR_FILE)
|
|
|
|
|
|
|
|
def test_archive_extracted_with_strip_in_options(self):
|
|
|
|
'''
|
|
|
|
test archive.extracted with --strip in options
|
|
|
|
'''
|
|
|
|
ret = self.run_state('archive.extracted', name=ARCHIVE_DIR,
|
2017-03-11 16:00:28 +00:00
|
|
|
source=self.archive_tar_source,
|
2016-12-15 03:57:14 +00:00
|
|
|
source_hash=ARCHIVE_TAR_HASH,
|
|
|
|
options='--strip=1',
|
|
|
|
enforce_toplevel=False)
|
|
|
|
log.debug('ret = %s', ret)
|
2016-11-30 19:11:41 +00:00
|
|
|
if 'Timeout' in ret:
|
|
|
|
self.skipTest('Timeout talking to local tornado server.')
|
|
|
|
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
|
2016-12-15 03:57:14 +00:00
|
|
|
self._check_extracted(os.path.join(ARCHIVE_DIR, 'README'))
|
|
|
|
|
|
|
|
def test_archive_extracted_with_strip_components_in_options(self):
|
|
|
|
'''
|
|
|
|
test archive.extracted with --strip-components in options
|
|
|
|
'''
|
|
|
|
ret = self.run_state('archive.extracted', name=ARCHIVE_DIR,
|
2017-03-11 16:00:28 +00:00
|
|
|
source=self.archive_tar_source,
|
2016-12-15 03:57:14 +00:00
|
|
|
source_hash=ARCHIVE_TAR_HASH,
|
|
|
|
options='--strip-components=1',
|
|
|
|
enforce_toplevel=False)
|
|
|
|
log.debug('ret = %s', ret)
|
|
|
|
if 'Timeout' in ret:
|
|
|
|
self.skipTest('Timeout talking to local tornado server.')
|
|
|
|
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
|
|
|
|
self._check_extracted(os.path.join(ARCHIVE_DIR, 'README'))
|
|
|
|
|
|
|
|
def test_archive_extracted_without_archive_format(self):
|
|
|
|
'''
|
|
|
|
test archive.extracted with no archive_format option
|
|
|
|
'''
|
|
|
|
ret = self.run_state('archive.extracted', name=ARCHIVE_DIR,
|
2017-03-11 16:00:28 +00:00
|
|
|
source=self.archive_tar_source,
|
2016-12-15 03:57:14 +00:00
|
|
|
source_hash=ARCHIVE_TAR_HASH)
|
|
|
|
log.debug('ret = %s', ret)
|
|
|
|
if 'Timeout' in ret:
|
|
|
|
self.skipTest('Timeout talking to local tornado server.')
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
|
|
|
|
self._check_extracted(UNTAR_FILE)
|
2016-11-30 19:11:41 +00:00
|
|
|
|
2017-03-27 16:32:27 +00:00
|
|
|
def test_archive_extracted_with_cmd_unzip_false(self):
|
|
|
|
'''
|
|
|
|
test archive.extracted using use_cmd_unzip argument as false
|
|
|
|
'''
|
|
|
|
|
|
|
|
ret = self.run_state('archive.extracted', name=ARCHIVE_DIR,
|
2017-03-29 15:11:46 +00:00
|
|
|
source=self.archive_tar_source,
|
2017-03-27 16:32:27 +00:00
|
|
|
source_hash=ARCHIVE_TAR_HASH,
|
|
|
|
use_cmd_unzip=False,
|
|
|
|
archive_format='tar')
|
|
|
|
log.debug('ret = %s', ret)
|
|
|
|
if 'Timeout' in ret:
|
|
|
|
self.skipTest('Timeout talking to local tornado server.')
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
|
|
|
|
self._check_extracted(UNTAR_FILE)
|
|
|
|
|
2017-06-26 16:08:47 +00:00
|
|
|
def test_local_archive_extracted(self):
|
|
|
|
'''
|
|
|
|
test archive.extracted with local file
|
|
|
|
'''
|
|
|
|
ret = self.run_state('archive.extracted', name=ARCHIVE_DIR,
|
|
|
|
source=ARCHIVE_LOCAL_TAR_SOURCE, archive_format='tar')
|
|
|
|
log.debug('ret = %s', ret)
|
|
|
|
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
|
|
|
|
self._check_extracted(UNTAR_FILE)
|
|
|
|
|
|
|
|
def test_local_archive_extracted_skip_verify(self):
|
|
|
|
'''
|
|
|
|
test archive.extracted with local file, bad hash and skip_verify
|
|
|
|
'''
|
|
|
|
ret = self.run_state('archive.extracted', name=ARCHIVE_DIR,
|
|
|
|
source=ARCHIVE_LOCAL_TAR_SOURCE, archive_format='tar',
|
|
|
|
source_hash=ARCHIVE_TAR_BAD_HASH, skip_verify=True)
|
|
|
|
log.debug('ret = %s', ret)
|
|
|
|
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
|
|
|
|
self._check_extracted(UNTAR_FILE)
|
|
|
|
|
|
|
|
def test_local_archive_extracted_with_source_hash(self):
|
|
|
|
'''
|
|
|
|
test archive.extracted with local file and valid hash
|
|
|
|
'''
|
|
|
|
ret = self.run_state('archive.extracted', name=ARCHIVE_DIR,
|
|
|
|
source=ARCHIVE_LOCAL_TAR_SOURCE, archive_format='tar',
|
|
|
|
source_hash=ARCHIVE_TAR_HASH)
|
|
|
|
log.debug('ret = %s', ret)
|
|
|
|
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
|
|
|
|
self._check_extracted(UNTAR_FILE)
|
|
|
|
|
|
|
|
def test_local_archive_extracted_with_bad_source_hash(self):
|
|
|
|
'''
|
|
|
|
test archive.extracted with local file and bad hash
|
|
|
|
'''
|
|
|
|
ret = self.run_state('archive.extracted', name=ARCHIVE_DIR,
|
|
|
|
source=ARCHIVE_LOCAL_TAR_SOURCE, archive_format='tar',
|
|
|
|
source_hash=ARCHIVE_TAR_BAD_HASH)
|
|
|
|
log.debug('ret = %s', ret)
|
|
|
|
|
|
|
|
self.assertSaltFalseReturn(ret)
|