Skip to content

Commit

Permalink
Remove unused function from RepositoryService
Browse files Browse the repository at this point in the history
Remove function _make_fileinfo RepositoryService that is not
used anywhere.

Signed-off-by: Kairo de Araujo <kdearaujo@vmware.com>
  • Loading branch information
Kairo de Araujo committed Jun 25, 2022
1 parent db951e1 commit a0790bb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 55 deletions.
39 changes: 0 additions & 39 deletions tests/unit/tuf/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,45 +342,6 @@ def test__get_hash_bins_production(self, db_request):
assert result.number_of_prefixes == 65536
assert result.bin_size == 4

def test__make_fileinfo(self):
fake_request = pretend.stub()
fake_storage = pretend.stub()
fake_key_storage = pretend.stub()
service = services.RepositoryService(
fake_storage, fake_key_storage, fake_request
)

fake_file = pretend.stub()
fake_file.blake2_256_digest = "sdfaslkajsdfkjhadsljkhfsdjkh"
fake_file.size = 1024

result = service._make_fileinfo(fake_file)

assert result == {
"hashes": {"blake2b-256": "sdfaslkajsdfkjhadsljkhfsdjkh"},
"length": 1024,
}

def test__make_fileinfo_with_custom(self):
fake_request = pretend.stub()
fake_storage = pretend.stub()
fake_key_storage = pretend.stub()
service = services.RepositoryService(
fake_storage, fake_key_storage, fake_request
)

fake_file = pretend.stub()
fake_file.blake2_256_digest = "sdfaslkajsdfkjhadsljkhfsdjkh"
fake_file.size = 1024

result = service._make_fileinfo(fake_file, custom={"backsigned": True})

assert result == {
"hashes": {"blake2b-256": "sdfaslkajsdfkjhadsljkhfsdjkh"},
"length": 1024,
"custom": {"backsigned": True},
}

def test__set_expiration_for_role_development(self, db_request, monkeypatch):
fake_storage = pretend.stub()
fake_key_storage = pretend.stub()
Expand Down
16 changes: 0 additions & 16 deletions warehouse/tuf/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,6 @@ def _get_hash_bins(self):

return HashBins(number_of_bins)

def _make_fileinfo(self, file, custom=None):
"""
Returns a TUF-compliant 'fileinfo' dictionary suitable for targets metadata.
The optional 'custom' kwarg can be used for additional metadata about target
files (e.g., to indicate backsigning).
"""
hashes = {"blake2b-256": file.blake2_256_digest}
fileinfo = dict()
fileinfo["length"] = file.size
fileinfo["hashes"] = hashes
if custom:
fileinfo["custom"] = custom

return fileinfo

def _set_expiration_for_role(self, role_name):
"""
Returns a metadata expiration date (now + role-specific interval).
Expand Down

0 comments on commit a0790bb

Please sign in to comment.