Пример #1
0
    def test_file_hash_sha1(self):
        '''
        NOTE: This test requires that gitfs.find_file is executed to ensure
        that the file exists in the gitfs cache.
        '''
        target = 'testfile'
        with patch.dict(gitfs.__opts__, {'cachedir': self.master_opts['cachedir'],
                                         'gitfs_remotes': ['file://' + self.tmp_repo_dir],
                                         'sock_dir': self.master_opts['sock_dir']}):
            # This needs to be in its own patch because we are using a
            # different hash_type for this test (sha1) from the one the master
            # is using (md5), which will cause the find_file to fail when the
            # repo URI is hashed to determine the cachedir.
            gitfs.find_file(target)

        with patch.dict(gitfs.__opts__, {'cachedir': self.master_opts['cachedir'],
                                         'gitfs_remotes': ['file://' + self.tmp_repo_dir],
                                         'sock_dir': self.master_opts['sock_dir'],
                                         'hash_type': 'sha1'}):
            tmp_load = copy.deepcopy(LOAD)
            tmp_load['loc'] = 0
            tmp_load['path'] = target
            fnd = {'rel': target,
                   'path': os.path.join(gitfs.__opts__['cachedir'],
                                        'gitfs/refs',
                                        tmp_load['saltenv'],
                                        tmp_load['path'])}

            ret = gitfs.file_hash(tmp_load, fnd)
            self.assertDictEqual(
                {'hash_type': 'sha1',
                 'hsum': '6b18d04b61238ba13b5e4626b13ac5fb7432b5e2'},
                ret)
Пример #2
0
 def test_file_hash_sha1(self):
     with patch.dict(gitfs.__opts__, {'cachedir': self.master_opts['cachedir'],
                                      'gitfs_remotes': ['file://' + self.tmp_repo_git],
                                      'sock_dir': self.master_opts['sock_dir'],
                                      'hash_type': 'blob_sha1'}):
         tmp_load = load
         tmp_load['path'] = 'testfile'
         fnd = {'rel': 'testfile',
                'path': 'testfile'}
         ret = gitfs.file_hash(load, fnd)
         self.assertDictEqual({'hash_type': 'blob_sha1', 'hsum': '0d234303e6451128d756c5c259175de37d767742'}, ret)
Пример #3
0
 def test_file_hash_sha1(self):
     with patch.dict(gitfs.__opts__, {'cachedir': self.master_opts['cachedir'],
                                      'gitfs_remotes': ['file://' + self.tmp_repo_git],
                                      'sock_dir': self.master_opts['sock_dir'],
                                      'hash_type': 'blob_sha1'}):
         tmp_load = load
         tmp_load['path'] = 'testfile'
         fnd = {'rel': 'testfile',
                'path': 'testfile'}
         ret = gitfs.file_hash(load, fnd)
         self.assertDictEqual({'hash_type': 'blob_sha1', 'hsum': '0d234303e6451128d756c5c259175de37d767742'}, ret)
Пример #4
0
 def test_file_hash_md5(self):
     with patch.dict(gitfs.__opts__, {'cachedir': self.master_opts['cachedir'],
                                      'gitfs_remotes': ['file://' + self.tmp_repo_git],
                                      'sock_dir': self.master_opts['sock_dir'],
                                      'hash_type': 'md5'}):
         tmp_load = load
         tmp_load['path'] = 'testfile'
         fnd = {'rel': 'testfile',
                'path': 'testfile'}
         ret = gitfs.file_hash(load, fnd)
         self.assertDictEqual({'hash_type': 'md5', 'hsum': '98aa509006628302ce38ce521a7f805f'}, ret)
Пример #5
0
 def test_file_hash_sha1(self):
     with patch.dict(
             gitfs.__opts__, {
                 'cachedir': self.master_opts['cachedir'],
                 'gitfs_remotes': ['file://' + self.tmp_repo_git],
                 'sock_dir': self.master_opts['sock_dir'],
                 'hash_type': 'sha1'
             }):
         tmp_load = LOAD.copy()
         tmp_load['path'] = 'testfile'
         fnd = {'rel': 'testfile', 'path': 'testfile'}
         ret = gitfs.file_hash(tmp_load, fnd)
         self.assertDictEqual(
             {
                 'hash_type': 'sha1',
                 'hsum': '6b18d04b61238ba13b5e4626b13ac5fb7432b5e2'
             }, ret)
Пример #6
0
    def test_file_hash_sha1(self):
        '''
        NOTE: This test requires that gitfs.find_file is executed to ensure
        that the file exists in the gitfs cache.
        '''
        target = 'testfile'
        with patch.dict(
                gitfs.__opts__, {
                    'cachedir': self.master_opts['cachedir'],
                    'gitfs_remotes': ['file://' + self.tmp_repo_dir],
                    'sock_dir': self.master_opts['sock_dir']
                }):
            # This needs to be in its own patch because we are using a
            # different hash_type for this test (sha1) from the one the master
            # is using (md5), which will cause the find_file to fail when the
            # repo URI is hashed to determine the cachedir.
            gitfs.find_file(target)

        with patch.dict(
                gitfs.__opts__, {
                    'cachedir': self.master_opts['cachedir'],
                    'gitfs_remotes': ['file://' + self.tmp_repo_dir],
                    'sock_dir': self.master_opts['sock_dir'],
                    'hash_type': 'sha1'
                }):
            tmp_load = copy.deepcopy(LOAD)
            tmp_load['loc'] = 0
            tmp_load['path'] = target
            fnd = {
                'rel':
                target,
                'path':
                os.path.join(gitfs.__opts__['cachedir'], 'gitfs/refs',
                             tmp_load['saltenv'], tmp_load['path'])
            }

            ret = gitfs.file_hash(tmp_load, fnd)
            self.assertDictEqual(
                {
                    'hash_type': 'sha1',
                    'hsum': '6b18d04b61238ba13b5e4626b13ac5fb7432b5e2'
                }, ret)