예제 #1
0
 def test_symlink_detection_size(self):
     self.generate_test_dir(True)
     hasher = FileDirectoryListHasher(hashfunc="sha256",
                                      use_relative_paths=False,
                                      hash_directory_names=True,
                                      hash_file_names=True,
                                      followlinks=True,
                                      max_characters_paths=100)
     exception_thrown = False
     try:
         hash = hasher.hash([self.temp_dir])
     except OSError as e:
         if "Walking through too many directories." in str(e):
             exception_thrown = True
     assert exception_thrown
 def _generate_build_context_hash(self):
     files_directories_list_hasher = \
         FileDirectoryListHasher(followlinks=True,
                                 hashfunc="sha256",
                                 hash_file_names=True,
                                 hash_directory_names=True,
                                 hash_permissions=True,
                                 use_relative_paths=True)
     files_directories_to_hash = list(self.image_description.mapping_of_build_files_and_directories.values()) + \
                                 [str(self.image_description.dockerfile)]
     self.logger.debug("files_directories_list_hasher %s",
                       files_directories_to_hash)
     hash_of_build_context = files_directories_list_hasher.hash(
         files_directories_to_hash)
     self.logger.debug("hash_of_build_context %s",
                       self._encode_hash(hash_of_build_context))
     return hash_of_build_context
예제 #3
0
 def test_directory_file_names_not_equal_to_dir_names(self):
     hasher_content_only = \
         FileDirectoryListHasher(hashfunc="sha256",
                                 use_relative_paths=True,
                                 hash_directory_names=False,
                                 hash_file_names=True)
     hasher_with_paths = \
         FileDirectoryListHasher(hashfunc="sha256",
                                 use_relative_paths=True,
                                 hash_directory_names=True,
                                 hash_file_names=False)
     hash1_content_only = hasher_content_only.hash([self.test_dir1])
     hash2_with_paths = hasher_with_paths.hash([self.test_dir2])
     ascii_hash1_content_only = base64.b32encode(hash1_content_only).decode("ASCII")
     ascii_hash2_with_paths = base64.b32encode(hash2_with_paths).decode("ASCII")
     self.assertNotEqual(ascii_hash1_content_only, ascii_hash2_with_paths)