def test_file_hash(self): with patch.dict( roots.__opts__, { 'file_roots': self.master_opts['file_roots'], 'fileserver_ignoresymlinks': False, 'fileserver_followsymlinks': False, 'file_ignore_regex': False, 'file_ignore_glob': False, 'hash_type': self.master_opts['hash_type'], 'cachedir': self.master_opts['cachedir'] }): load = { 'saltenv': 'base', 'path': os.path.join(integration.FILES, 'file', 'base', 'testfile'), } fnd = { 'path': os.path.join(integration.FILES, 'file', 'base', 'testfile'), 'rel': 'testfile' } ret = roots.file_hash(load, fnd) self.assertDictEqual(ret, { 'hsum': '98aa509006628302ce38ce521a7f805f', 'hash_type': 'md5' })
def test_file_hash(self): with patch.dict(roots.__opts__, {'file_roots': self.master_opts['file_roots'], 'fileserver_ignoresymlinks': False, 'fileserver_followsymlinks': False, 'file_ignore_regex': False, 'file_ignore_glob': False, 'hash_type': self.master_opts['hash_type'], 'cachedir': self.master_opts['cachedir']}): load = { 'saltenv': 'base', 'path': os.path.join(integration.FILES, 'file', 'base', 'testfile'), } fnd = { 'path': os.path.join(integration.FILES, 'file', 'base', 'testfile'), 'rel': 'testfile' } ret = roots.file_hash(load, fnd) # Hashes are different in Windows. May be how git translates line # endings hsum = 'baba5791276eb99a7cc498fb1acfbc3b4bd96d24cfe984b4ed6b5be2418731df' if salt.utils.is_windows(): hsum = '754aa260e1f3e70f43aaf92149c7d1bad37f708c53304c37660e628d7553f687' self.assertDictEqual( ret, { 'hsum': hsum, 'hash_type': 'sha256' } )
def test_file_hash(self): with patch.dict( roots.__opts__, { 'file_roots': self.master_opts['file_roots'], 'fileserver_ignoresymlinks': False, 'fileserver_followsymlinks': False, 'file_ignore_regex': False, 'file_ignore_glob': False, 'hash_type': self.master_opts['hash_type'], 'cachedir': self.master_opts['cachedir'] }): load = { 'saltenv': 'base', 'path': os.path.join(integration.FILES, 'file', 'base', 'testfile'), } fnd = { 'path': os.path.join(integration.FILES, 'file', 'base', 'testfile'), 'rel': 'testfile' } ret = roots.file_hash(load, fnd) self.assertDictEqual( ret, { 'hsum': 'baba5791276eb99a7cc498fb1acfbc3b4bd96d24cfe984b4ed6b5be2418731df', 'hash_type': 'sha256' })
def test_file_hash(self): load = { "saltenv": "base", "path": os.path.join(self.tmp_dir, "testfile"), } fnd = {"path": os.path.join(self.tmp_dir, "testfile"), "rel": "testfile"} ret = roots.file_hash(load, fnd) # Hashes are different in Windows. May be how git translates line # endings with salt.utils.files.fopen( os.path.join(RUNTIME_VARS.BASE_FILES, 'testfile'), 'rb') as fp_: hsum = salt.utils.hashutils.sha256_digest(fp_.read()) self.assertDictEqual(ret, {"hsum": hsum, "hash_type": "sha256"})
def test_file_hash(self): with patch.dict( roots.__opts__, { "file_roots": self.master_opts["file_roots"], "fileserver_ignoresymlinks": False, "fileserver_followsymlinks": False, "file_ignore_regex": False, "file_ignore_glob": False, "hash_type": self.master_opts["hash_type"], "cachedir": self.master_opts["cachedir"], }, ): load = {"saltenv": "base", "path": os.path.join(integration.FILES, "file", "base", "testfile")} fnd = {"path": os.path.join(integration.FILES, "file", "base", "testfile"), "rel": "testfile"} ret = roots.file_hash(load, fnd) self.assertDictEqual(ret, {"hsum": "98aa509006628302ce38ce521a7f805f", "hash_type": "md5"})
def test_file_hash(self): load = { 'saltenv': 'base', 'path': os.path.join(self.tmp_dir, 'testfile'), } fnd = { 'path': os.path.join(self.tmp_dir, 'testfile'), 'rel': 'testfile' } ret = roots.file_hash(load, fnd) # Hashes are different in Windows. May be how git translates line # endings with salt.utils.files.fopen(os.path.join(BASE_FILES, 'testfile'), 'rb') as fp_: hsum = salt.utils.hashutils.sha256_digest(fp_.read()) self.assertDictEqual(ret, {'hsum': hsum, 'hash_type': 'sha256'})
def test_file_hash(self): with patch.dict(roots.__opts__, {'file_roots': self.master_opts['file_roots'], 'fileserver_ignoresymlinks': False, 'fileserver_followsymlinks': False, 'file_ignore_regex': False, 'file_ignore_glob': False, 'hash_type': self.master_opts['hash_type'], 'cachedir': self.master_opts['cachedir']}): load = { 'saltenv': 'base', 'path': os.path.join(integration.FILES, 'file', 'base', 'testfile'), } fnd = { 'path': os.path.join(integration.FILES, 'file', 'base', 'testfile'), 'rel': 'testfile' } ret = roots.file_hash(load, fnd) self.assertDictEqual(ret, {'hsum': '98aa509006628302ce38ce521a7f805f', 'hash_type': 'md5'})
def test_file_hash(self): load = { 'saltenv': 'base', 'path': os.path.join(FILES, 'file', 'base', 'testfile'), } fnd = { 'path': os.path.join(FILES, 'file', 'base', 'testfile'), 'rel': 'testfile' } ret = roots.file_hash(load, fnd) # Hashes are different in Windows. May be how git translates line # endings hsum = 'baba5791276eb99a7cc498fb1acfbc3b4bd96d24cfe984b4ed6b5be2418731df' if salt.utils.is_windows(): hsum = '754aa260e1f3e70f43aaf92149c7d1bad37f708c53304c37660e628d7553f687' self.assertDictEqual(ret, {'hsum': hsum, 'hash_type': 'sha256'})
def test_file_hash(self): with patch.dict(roots.__opts__, {'file_roots': self.master_opts['file_roots'], 'fileserver_ignoresymlinks': False, 'fileserver_followsymlinks': False, 'file_ignore_regex': False, 'file_ignore_glob': False, 'hash_type': self.master_opts['hash_type'], 'cachedir': self.master_opts['cachedir']}): load = { 'saltenv': 'base', 'path': os.path.join(integration.FILES, 'file', 'base', 'testfile'), } fnd = { 'path': os.path.join(integration.FILES, 'file', 'base', 'testfile'), 'rel': 'testfile' } ret = roots.file_hash(load, fnd) self.assertDictEqual( ret, { 'hsum': 'baba5791276eb99a7cc498fb1acfbc3b4bd96d24cfe984b4ed6b5be2418731df', 'hash_type': 'sha256' } )