Add regression test for issue 56131

This commit is contained in:
Daniel A. Wozniak 2020-02-21 07:15:59 +00:00
parent 9d23f55adc
commit 69b21e5e68
No known key found for this signature in database
GPG key ID: 166B9D2C06C82D61
3 changed files with 34 additions and 0 deletions

View file

@ -0,0 +1,10 @@
# archive-test
vault:
archive.extracted:
- name: {{ pillar['unzip_to'] }}
- source: salt://issue-56131.zip
- source_hash: sha256=4fc6f049d658a414aca066fb11c2109d05b59f082d707d5d6355b6c574d25720
- archive_format: zip
- enforce_toplevel: False
- unless:
- echo hello && 1

Binary file not shown.

View file

@ -2268,3 +2268,27 @@ class StateModuleTest(ModuleCase, SaltReturnAssertsMixin):
self.assertEqual(state_run[state_id]['comment'],
'Success!')
self.assertTrue(state_run[state_id]['result'])
def test_issue_56131(self):
module_path = os.path.join(RUNTIME_VARS.CODE_DIR, 'pip.py')
if six.PY3:
modulec_path = os.path.join(RUNTIME_VARS.CODE_DIR, '__pycache__', 'pip.pyc')
else:
modulec_path = os.path.join(RUNTIME_VARS.CODE_DIR, 'pip.pyc')
print('*' * 80)
print(module_path)
print('*' * 80)
unzip_path = os.path.join(RUNTIME_VARS.TMP, 'issue-56131.txt')
def clean_paths(paths):
for path in paths:
try:
os.remove(path)
except OSError:
log.warn("Path not found: %s", path)
with open(module_path, 'w') as fp:
fp.write('raise ImportError("No module named pip")')
self.addCleanup(clean_paths, [unzip_path, module_path, modulec_path])
assert not os.path.exists(unzip_path)
state_run = self.run_function('state.sls', mods='issue-56131', pillar={'unzip_to': RUNTIME_VARS.TMP}, timeout=30)
assert state_run is not False
assert os.path.exists(unzip_path)