Fix unit tests for developer_tool.py

This commit is contained in:
Vladimir Diaz 2016-07-01 12:52:04 -04:00
parent 872ff7c1a1
commit 5c7333b062
4 changed files with 12 additions and 10 deletions

View file

@ -235,7 +235,7 @@ def test_add_verification_keys(self):
# Add another verification key (should expect exception.)
second_verification_key_path = os.path.join(keystore_path, 'snapshot_key.pub')
second_verification_key = \
developer_tool.import_rsa_publickey_from_file(second_verification_key_path)
developer_tool.import_ed25519_publickey_from_file(second_verification_key_path)
self.assertRaises(tuf.Error,
project.add_verification_key,(second_verification_key))
@ -289,12 +289,12 @@ def test_write(self):
# Add another verification key (should expect exception.)
delegation_key_path = os.path.join(keystore_path, 'snapshot_key.pub')
delegation_key = \
developer_tool.import_rsa_publickey_from_file(delegation_key_path)
developer_tool.import_ed25519_publickey_from_file(delegation_key_path)
# Add a subdelegation.
subdelegation_key_path = os.path.join(keystore_path, 'timestamp_key.pub')
subdelegation_key = \
developer_tool.import_rsa_publickey_from_file(subdelegation_key_path)
developer_tool.import_ed25519_publickey_from_file(subdelegation_key_path)
# Add a delegation.
project.delegate('delegation', [delegation_key], [])
@ -314,13 +314,13 @@ def test_write(self):
delegation_private_key_path = os.path.join(keystore_path, 'snapshot_key')
delegation_private_key = \
developer_tool.import_rsa_privatekey_from_file(delegation_private_key_path,
developer_tool.import_ed25519_privatekey_from_file(delegation_private_key_path,
'password')
subdelegation_private_key_path = \
os.path.join(keystore_path, 'timestamp_key')
subdelegation_private_key = \
developer_tool.import_rsa_privatekey_from_file(subdelegation_private_key_path,
developer_tool.import_ed25519_privatekey_from_file(subdelegation_private_key_path,
'password')
# Test partial write.

View file

@ -89,6 +89,7 @@ def setUp(self):
def tearDown(self):
tuf.roledb.clear_roledb()
pass

View file

@ -862,7 +862,7 @@ def load_project(project_directory, prefix='', new_targets_location=None):
keydict = project_configuration['public_keys']
for keyid in keydict:
key = format_metadata_to_key(keydict[keyid])
key, junk = tuf.keys.format_metadata_to_key(keydict[keyid])
project.add_verification_key(key)
# Load the project's metadata.
@ -895,7 +895,7 @@ def load_project(project_directory, prefix='', new_targets_location=None):
for key_metadata in targets_metadata['delegations']['keys'].values():
key_object = tuf.keys.format_metadata_to_key(key_metadata)
key_object, junk = tuf.keys.format_metadata_to_key(key_metadata)
tuf.keydb.add_key(key_object)
for role in targets_metadata['delegations']['roles']:
@ -977,7 +977,8 @@ def load_project(project_directory, prefix='', new_targets_location=None):
# Add the keys specified in the delegations field of the Targets role.
for key_metadata in metadata_object['delegations']['keys'].values():
key_object = tuf.keys.format_metadata_to_key(key_metadata)
key_object, junk = tuf.keys.format_metadata_to_key(key_metadata)
try:
tuf.keydb.add_key(key_object)

View file

@ -494,8 +494,8 @@ def format_metadata_to_key(key_metadata):
None.
<Returns>
In the case of an RSA key, a dictionary conformant to
'tuf.formats.RSAKEY_SCHEMA'.
A tuple containing the key and its keyids. In the case of an RSA key, a
dictionary conformant to 'tuf.formats.RSAKEY_SCHEMA'.
"""
# Does 'key_metadata' have the correct format?