mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
Add some coverage for repository_tool.py
This commit is contained in:
parent
d3f34bb563
commit
5e8bef7c72
2 changed files with 20 additions and 4 deletions
|
|
@ -381,11 +381,16 @@ def test_get_filepaths_in_directory(self):
|
|||
'snapshot.json', 'snapshot.json.gz', 'timestamp.json',
|
||||
'timestamp.json.gz', 'role1.json', 'role1.json.gz',
|
||||
'role2.json', 'role2.json.gz']
|
||||
|
||||
basenames = []
|
||||
for filepath in metadata_files:
|
||||
basenames.append(os.path.basename(filepath))
|
||||
self.assertEqual(sorted(expected_files), sorted(basenames))
|
||||
|
||||
# Test when 'recursive_walk' is True.
|
||||
metadata_files = repo.get_filepaths_in_directory(metadata_directory,
|
||||
recursive_walk=True)
|
||||
|
||||
# Test improperly formatted arguments.
|
||||
self.assertRaises(tuf.ssl_commons.exceptions.FormatError, repo.get_filepaths_in_directory,
|
||||
3, recursive_walk=False, followlinks=False)
|
||||
|
|
@ -1016,6 +1021,14 @@ def test_delegations(self):
|
|||
|
||||
|
||||
|
||||
def test_add_delegated_role(self):
|
||||
# Test for invalid targets object.
|
||||
self.assertRaises(tuf.ssl_commons.exceptions.FormatError,
|
||||
self.targets_object.add_delegated_role, 'targets',
|
||||
'bad_object')
|
||||
|
||||
|
||||
|
||||
def test_add_target(self):
|
||||
# Test normal case.
|
||||
# Verify the targets object initially contains zero target files.
|
||||
|
|
|
|||
|
|
@ -530,10 +530,13 @@ def get_filepaths_in_directory(files_directory, recursive_walk=False,
|
|||
targets.append(full_target_path)
|
||||
|
||||
# Prune the subdirectories to walk right now if we do not wish to
|
||||
# recursively walk files_directory.
|
||||
# recursively walk 'files_directory'.
|
||||
if recursive_walk is False:
|
||||
del dirnames[:]
|
||||
|
||||
else:
|
||||
logger.debug('Not pruning subdirectories ' + repr(dirnames))
|
||||
|
||||
return targets
|
||||
|
||||
|
||||
|
|
@ -544,9 +547,9 @@ class Metadata(object):
|
|||
"""
|
||||
<Purpose>
|
||||
Provide a base class to represent a TUF Metadata role. There are four
|
||||
top-level roles: Root, Targets, Snapshot, and Timestamp. The Metadata class
|
||||
provides methods that are needed by all top-level roles, such as adding
|
||||
and removing public keys, private keys, and signatures. Metadata
|
||||
top-level roles: Root, Targets, Snapshot, and Timestamp. The Metadata
|
||||
class provides methods that are needed by all top-level roles, such as
|
||||
adding and removing public keys, private keys, and signatures. Metadata
|
||||
attributes, such as rolename, version, threshold, expiration, key list, and
|
||||
compressions, is also provided by the Metadata base class.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue