Skip to content

Commit

Permalink
Metadata API: Fix Metadata.sign() return value
Browse files Browse the repository at this point in the history
We've been returning Signature objects since 49aa0fc.

Also add a test case that does something with the returned signature.

Signed-off-by: Jussi Kukkonen <[email protected]>
  • Loading branch information
Jussi Kukkonen committed Jun 11, 2021
1 parent de78251 commit caf278c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,14 @@ def test_sign_verify(self):

sslib_signer = SSlibSigner(self.keystore['snapshot'])
# Append a new signature with the unrelated key and assert that ...
metadata_obj.sign(sslib_signer, append=True)
sig = metadata_obj.sign(sslib_signer, append=True)
# ... there are now two signatures, and
self.assertTrue(len(metadata_obj.signatures) == 2)
# ... both are valid for the corresponding keys.
targets_key.verify_signature(metadata_obj)
snapshot_key.verify_signature(metadata_obj)
# ... the returned (appended) signature is for snapshot key
self.assertEqual(sig.keyid, snapshot_keyid)

sslib_signer = SSlibSigner(self.keystore['timestamp'])
# Create and assign (don't append) a new signature and assert that ...
Expand Down
4 changes: 2 additions & 2 deletions tuf/api/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def sign(
signer: Signer,
append: bool = False,
signed_serializer: Optional[SignedSerializer] = None,
) -> Dict[str, Any]:
) -> Signature:
"""Creates signature over 'signed' and assigns it to 'signatures'.
Arguments:
Expand All @@ -232,7 +232,7 @@ def sign(
Signing errors.
Returns:
A securesystemslib-style signature object.
Securesystemslib Signature object that was added into signatures.
"""
if signed_serializer is None:
Expand Down

0 comments on commit caf278c

Please sign in to comment.