Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor interface tests and add more #279

Merged
merged 4 commits into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions securesystemslib/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def generate_and_write_rsa_keypair(filepath=None, bits=DEFAULT_RSA_KEY_BITS,
securesystemslib.formats.PATH_SCHEMA.check_match(filepath)

# If the caller does not provide a password argument, prompt for one.
if password is None: # pragma: no cover
if password is None:

# It is safe to specify the full path of 'filepath' in the prompt and not
# worry about leaking sensitive information about the key's location.
Expand Down Expand Up @@ -480,7 +480,7 @@ def generate_and_write_ed25519_keypair(filepath=None, password=None):
securesystemslib.formats.PATH_SCHEMA.check_match(filepath)

# If the caller does not provide a password argument, prompt for one.
if password is None: # pragma: no cover
if password is None:

# It is safe to specify the full path of 'filepath' in the prompt and not
# worry about leaking sensitive information about the key's location.
Expand Down Expand Up @@ -584,7 +584,7 @@ def import_ed25519_publickey_from_file(filepath):
# Raise an exception if an unexpected key type is imported. Redundant
# validation of 'keytype'. 'securesystemslib.keys.format_metadata_to_key()'
# should have fully validated 'ed25519_key_metadata'.
if ed25519_key['keytype'] != 'ed25519': # pragma: no cover
if ed25519_key['keytype'] != 'ed25519':
message = 'Invalid key type loaded: ' + repr(ed25519_key['keytype'])
raise securesystemslib.exceptions.FormatError(message)

Expand Down Expand Up @@ -675,7 +675,7 @@ def import_ed25519_privatekey_from_file(filepath, password=None, prompt=False,

# If user sets an empty string for the password, explicitly set the
# password to None, because some functions may expect this later.
if len(password) == 0: # pragma: no cover
if len(password) == 0:
password = None

# Finally, regardless of password, try decrypting the key, if necessary.
Expand Down Expand Up @@ -745,7 +745,7 @@ def generate_and_write_ecdsa_keypair(filepath=None, password=None):
securesystemslib.formats.PATH_SCHEMA.check_match(filepath)

# If the caller does not provide a password argument, prompt for one.
if password is None: # pragma: no cover
if password is None:

# It is safe to specify the full path of 'filepath' in the prompt and not
# worry about leaking sensitive information about the key's location.
Expand Down Expand Up @@ -889,7 +889,7 @@ def import_ecdsa_privatekey_from_file(filepath, password=None,
# If the caller does not provide a password argument, prompt for one.
# Password confirmation disabled here, which should ideally happen only
# when creating encrypted key files (i.e., improve usability).
if password is None: # pragma: no cover
if password is None:

# It is safe to specify the full path of 'filepath' in the prompt and not
# worry about leaking sensitive information about the key's location.
Expand Down
1 change: 1 addition & 0 deletions tests/data/keystore/ecdsa_key
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b10c798b80a5362c57cf54bdbc6d37e3@@@@100000@@@@852bb8805566c96c13e0e89dd1c61702480656e818da1c9bc70514053aa37e95@@@@e68c557ba0bce8f5ad81f1273ff77e2a@@@@af16836050062e7ef32c868f0fee50ffe1ba7fddd58fb9fba807c4cfbf1d9d188786c86e0f110d4c26e11b99a8aae98f90091d6a2d8733f8aceab7719bdde92b9e761821283c4bc29af5803bd4822e95e024ec5f1d3de361bd109d40d3a4a88d28895a865903cf6dc7662c87e936fb7a9d18b92271183950197983d31e0ea6365c821238bd9910855e7f5ce6d053b591972028802bc865f9867efb9e50b0319a800190c4f7a820dafbe4c5aa0ff6243f6709137f52d4fceb62c66a9bd86ee649adbf93d50be5a9d7f7b4dc6dbfdec36482d00cc4552546a969e10b13085038c7f951d6b84856f73c56ddb13e1a41d84ff6add934d17809253f7e75abe6b774a658ea4f3ff6519e468acc5302478a3c2b44a6b5317d04f7f1e82c5eeeaaeaa2ef8cbb4b3bbef18a74105b7463f06651946b1da8582f6018f3c2dca1dfb04c04e8c4686ac168c378106ab82a777fd68d57b865014d6c2dd854375a70b6a6cb9ba098f79b44cfd593b99ee468615f6217d6df2d0eaccbb9b3d99cf7417d98930c2d1891eae9561ee08cca81077f5c198939d833eb0d98beff06cc217b7bb4b06af84d294c77a2e1082fc15292898aeaa8ab1676e2898a33234ab71e62a929b2135a8006ba362018e9c5dbea9c48e1758c0b59890124b3a1aa9dcf70483f4116631733cdd448e5c68b1e715e9d36f4b5970302700c5b882669ddc0d2c953d60cb568ba7eaced480fc51c4efbb5143ab4d9c76f9267e5d2bc71cd66c68a4e59d1322ef45403451f7dd49fc41c0c8bb34e997850e37f24f13f55f276490347131d8d11b6102b1fa2333fc7d5b0051f1c831f1d2cbd5a7d5b653832eebadc0f8c69e1f33ae36f98a199aa069b5c0a16e97d8de2dddc23dc54d3dad3
1 change: 1 addition & 0 deletions tests/data/keystore/ecdsa_key.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"keytype": "ecdsa", "scheme": "ecdsa-sha2-nistp256", "keyid_hash_algorithms": ["sha256", "sha512"], "keyval": {"public": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEsYJfSlYU3UlYbGOZfE/yOHkayWWq\nLPR/NeCa83szZmnJGc9wwCRPvJS87K+eDGIhhhKueTyrLqXQqmyHioQbOQ==\n-----END PUBLIC KEY-----\n"}}
1 change: 1 addition & 0 deletions tests/data/keystore/ed25519_key
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
788b012147f9afe9c1a1512265eb63b0@@@@100000@@@@b9b5c42795411118e907cecdb46f9de8cfb22154664f65aa473df7542969ebfd@@@@1f50f6aa17bea38f7f3f3b94b35863c1@@@@bb498fa82340c0b2ab244e6032df2dfdeb7155fd614ec797ccc833b36f404d06177824b62b4242dc323e5e90ba9d009df0b62e9ad2a26ab1705687ed220065aa24af1cd5e531c9939ad8d6327cf8321fa28e271330d283c71d9c605b6c9a6579c63ecbd457f31fc5343088c8a30d1aebf5dcbffa4f5852b57f59e2683581fe426a55f23c61a432b435ec633111f7051bfbbe84994b7b85beaa2ed8cd515d3956ec8d241bc98cce855e7875c8d5b0ad80a42c1cf26038b82dfadf593753ed0c65418f1ddbfd754956599d20ab3463ccbf70eacf59902a551ab714d496fb9fb4fe6f23132b6461d25901ac8a92b1f440fec815322979d5082c463616a92a05481be27fd9bb0abd6ec0f10651675273e9e58360fb6062a367b82d909c9863515755cde651d803e9763bb0f6eee289e356e9bfb961ce62464559b1e4fa739786606381b40e1b286b8b7462f94dc32a281baa
1 change: 1 addition & 0 deletions tests/data/keystore/ed25519_key.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"keytype": "ed25519", "scheme": "ed25519", "keyid_hash_algorithms": ["sha256", "sha512"], "keyval": {"public": "50a5768a7a577483c28e57a6742b4d2170b9be628a961355ef127c45f2aefdc5"}}
1 change: 1 addition & 0 deletions tests/data/keystore/no_key
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading