Skip to content

Commit

Permalink
Rename test variables and fix indentation
Browse files Browse the repository at this point in the history
Following @vladimir-v-diaz's review suggestions, this commit
fixes some variable names and indentations in `test_keys.py`
  • Loading branch information
lukpueh committed Sep 15, 2017
1 parent 2e29dc6 commit 59f5876
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions tests/test_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,11 +684,11 @@ def test_extract_pem(self):
self.assertTrue(securesystemslib.formats.PEMRSA_SCHEMA.matches(public_pem))

# Test encrypted private pem
private_pem_encrypted = KEYS.create_rsa_encrypted_pem(private_pem, "pw")
private_pem_encrypted = KEYS.extract_pem(private_pem_encrypted,
private_pem=True)
encrypted_private_pem = KEYS.create_rsa_encrypted_pem(private_pem, "pw")
encrypted_private_pem_stripped = KEYS.extract_pem(encrypted_private_pem,
private_pem=True)
self.assertTrue(securesystemslib.formats.PEMRSA_SCHEMA.matches(
private_pem_encrypted))
encrypted_private_pem_stripped))

# Test for an invalid PEM.
pem_header = '-----BEGIN RSA PRIVATE KEY-----'
Expand Down Expand Up @@ -743,13 +743,14 @@ def test_is_pem_public(self):

def test_is_pem_private(self):
# Test for a valid PEM string.
private_pem = self.rsakey_dict['keyval']['private']
private_pem_rsa = self.rsakey_dict['keyval']['private']
private_pem_ec = self.ecdsakey_dict['keyval']['private']
private_pem_encrypted = KEYS.create_rsa_encrypted_pem(private_pem, "pw")
encrypted_private_pem_rsa = KEYS.create_rsa_encrypted_pem(
private_pem_rsa, "pw")

self.assertTrue(KEYS.is_pem_private(private_pem))
self.assertTrue(KEYS.is_pem_private(private_pem_rsa))
self.assertTrue(KEYS.is_pem_private(private_pem_ec, 'ec'))
self.assertTrue(KEYS.is_pem_private(private_pem_encrypted))
self.assertTrue(KEYS.is_pem_private(encrypted_private_pem_rsa))

# Test for a valid non-private PEM string.
public_pem = self.rsakey_dict['keyval']['public']
Expand All @@ -759,11 +760,11 @@ def test_is_pem_private(self):

# Test for unsupported keytype.
self.assertRaises(securesystemslib.exceptions.FormatError,
KEYS.is_pem_private, private_pem, 'bad_keytype')
KEYS.is_pem_private, private_pem_rsa, 'bad_keytype')

# Test for an invalid PEM string.
self.assertRaises(securesystemslib.exceptions.FormatError,
KEYS.is_pem_private, 123)
KEYS.is_pem_private, 123)



Expand Down

0 comments on commit 59f5876

Please sign in to comment.