Skip to content

Commit

Permalink
Rename get_*_metadata_filenames functions
Browse files Browse the repository at this point in the history
Rename repository_lib.get_metadata_filenames() and
get_delegations_filenames() to better match their
functionality and tuf terminology.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
  • Loading branch information
sechkova committed Jun 29, 2020
1 parent 97eff9e commit a69208c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
13 changes: 8 additions & 5 deletions tests/test_repository_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def test_import_ed25519_privatekey_from_file(self):



def test_get_metadata_filenames(self):
def test_get_top_level_metadata_filenames(self):

# Test normal case.
metadata_directory = os.path.join('metadata/')
Expand All @@ -210,7 +210,8 @@ def test_get_metadata_filenames(self):
'snapshot.json': metadata_directory + 'snapshot.json',
'timestamp.json': metadata_directory + 'timestamp.json'}

self.assertEqual(filenames, repo_lib.get_metadata_filenames('metadata/'))
self.assertEqual(filenames,
repo_lib.get_top_level_metadata_filenames('metadata/'))

# If a directory argument is not specified, the current working directory
# is used.
Expand All @@ -219,11 +220,13 @@ def test_get_metadata_filenames(self):
'targets.json': os.path.join(metadata_directory, 'targets.json'),
'snapshot.json': os.path.join(metadata_directory, 'snapshot.json'),
'timestamp.json': os.path.join(metadata_directory, 'timestamp.json')}
self.assertEqual(filenames, repo_lib.get_metadata_filenames(metadata_directory))
self.assertEqual(filenames,
repo_lib.get_top_level_metadata_filenames(metadata_directory))


# Test improperly formatted argument.
self.assertRaises(securesystemslib.exceptions.FormatError, repo_lib.get_metadata_filenames, 3)
self.assertRaises(securesystemslib.exceptions.FormatError,
repo_lib.get_top_level_metadata_filenames, 3)



Expand Down Expand Up @@ -797,7 +800,7 @@ def test__load_top_level_metadata(self):
storage_backend = securesystemslib.storage.FilesystemBackend()
repo_lib.write_metadata_file(signable, root_file, 8, False, storage_backend)

filenames = repo_lib.get_metadata_filenames(metadata_directory)
filenames = repo_lib.get_top_level_metadata_filenames(metadata_directory)
repository = repo_tool.create_new_repository(repository_directory, repository_name)
repo_lib._load_top_level_metadata(repository, filenames, repository_name)

Expand Down
8 changes: 4 additions & 4 deletions tuf/repository_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,8 +812,8 @@ def import_ed25519_privatekey_from_file(filepath, password=None):



def get_delegations_filenames(metadata_directory, consistent_snapshot,
storage_backend=None):
def get_delegated_roles_metadata_filenames(metadata_directory,
consistent_snapshot, storage_backend=None):
"""
Return a dictionary containing all filenames in 'metadata_directory'
except the top-level roles.
Expand Down Expand Up @@ -861,7 +861,7 @@ def get_delegations_filenames(metadata_directory, consistent_snapshot,



def get_metadata_filenames(metadata_directory):
def get_top_level_metadata_filenames(metadata_directory):
"""
<Purpose>
Return a dictionary containing the filenames of the top-level roles.
Expand Down Expand Up @@ -1826,7 +1826,7 @@ def _log_status_of_top_level_roles(targets_directory, metadata_directory,

# The expected full filenames of the top-level roles needed to write them to
# disk.
filenames = get_metadata_filenames(metadata_directory)
filenames = get_top_level_metadata_filenames(metadata_directory)
root_filename = filenames[ROOT_FILENAME]
targets_filename = filenames[TARGETS_FILENAME]
snapshot_filename = filenames[SNAPSHOT_FILENAME]
Expand Down
4 changes: 2 additions & 2 deletions tuf/repository_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -3090,7 +3090,7 @@ def load_repository(repository_directory, repository_name='default',
repository = Repository(repository_directory, metadata_directory,
targets_directory, storage_backend, repository_name)

filenames = repo_lib.get_metadata_filenames(metadata_directory)
filenames = repo_lib.get_top_level_metadata_filenames(metadata_directory)

# The Root file is always available without a version number (a consistent
# snapshot) attached to the filename. Store the 'consistent_snapshot' value
Expand All @@ -3102,7 +3102,7 @@ def load_repository(repository_directory, repository_name='default',
repository, consistent_snapshot = repo_lib._load_top_level_metadata(repository,
filenames, repository_name)

delegated_roles_filenames = repo_lib.get_delegations_filenames(
delegated_roles_filenames = repo_lib.get_delegated_roles_metadata_filenames(
metadata_directory, consistent_snapshot, storage_backend)

# Load the delegated targets metadata and their fileinfo.
Expand Down

0 comments on commit a69208c

Please sign in to comment.