Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2018.3] Ensure source_hash returned from get_source_sum is lowercase. #50906

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions salt/modules/file.py
Expand Up @@ -793,6 +793,7 @@ def _invalid_source_hash_format():
ret = extract_hash(hash_fn, '', file_name, source, source_hash_name)
if ret is None:
_invalid_source_hash_format()
ret['hsum'] = ret['hsum'].lower()
return ret
else:
# The source_hash is a hash expression
Expand Down Expand Up @@ -836,6 +837,7 @@ def _invalid_source_hash_format():
)
)

ret['hsum'] = ret['hsum'].lower()
return ret


Expand Down
13 changes: 13 additions & 0 deletions tests/integration/states/test_archive.py
Expand Up @@ -31,6 +31,7 @@
UNTAR_FILE = os.path.join(ARCHIVE_DIR, 'custom/README')
ARCHIVE_TAR_HASH = 'md5=7643861ac07c30fe7d2310e9f25ca514'
ARCHIVE_TAR_BAD_HASH = 'md5=d41d8cd98f00b204e9800998ecf8427e'
ARCHIVE_TAR_HASH_UPPER = 'md5=7643861AC07C30FE7D2310E9F25CA514'


class ArchiveTest(ModuleCase, SaltReturnAssertsMixin):
Expand Down Expand Up @@ -232,6 +233,18 @@ def test_local_archive_extracted_with_bad_source_hash(self):

self.assertSaltFalseReturn(ret)

def test_local_archive_extracted_with_uppercase_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_HASH_UPPER)

self.assertSaltTrueReturn(ret)

self._check_extracted(UNTAR_FILE)

def test_archive_extracted_with_non_base_saltenv(self):
'''
test archive.extracted with a saltenv other than `base`
Expand Down