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

Avoid looking for encrypted messages with "Plaintext" encoding #447

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 7 additions & 6 deletions tests/test_05_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ def targette_sec():
seckeys = [ PGPKey.from_file(f)[0] for f in sorted(glob.glob('tests/testdata/keys/*.sec.asc')) ]
pubkeys = [ PGPKey.from_file(f)[0] for f in sorted(glob.glob('tests/testdata/keys/*.pub.asc')) ]

symalgos = sorted(filter(lambda x: x is not SymmetricKeyAlgorithm.Plaintext, sorted(SymmetricKeyAlgorithm)))

class TestPGPKey_Actions(object):
sigs = {}
Expand Down Expand Up @@ -906,14 +907,14 @@ def test_gpg_import_abe(self, abe):
self.gpg_verify(abe)

@pytest.mark.parametrize('pub,cipher',
itertools.product(pubkeys, sorted(SymmetricKeyAlgorithm)),
ids=['{}:{}-{}'.format(pk.key_algorithm.name, pk.key_size, c.name) for pk, c in itertools.product(pubkeys, sorted(SymmetricKeyAlgorithm))])
itertools.product(pubkeys, symalgos),
ids=['{}:{}-{}'.format(pk.key_algorithm.name, pk.key_size, c.name) for pk, c in itertools.product(pubkeys, symalgos)])
def test_encrypt_message(self, pub, cipher):
if pub.key_algorithm in {PubKeyAlgorithm.DSA}:
pytest.skip('Asymmetric encryption only implemented for RSA/ECDH currently')

if cipher in {SymmetricKeyAlgorithm.Plaintext, SymmetricKeyAlgorithm.Twofish256, SymmetricKeyAlgorithm.IDEA}:
pytest.xfail('Symmetric cipher {} not supported for encryption'.format(cipher))
if cipher in {SymmetricKeyAlgorithm.Twofish256, SymmetricKeyAlgorithm.IDEA}:
pytest.xfail(f'{cipher!r} not supported for encryption')

# test encrypting a message
mtxt = "This message will have been encrypted"
Expand All @@ -925,7 +926,7 @@ def test_encrypt_message(self, pub, cipher):

@pytest.mark.order(after='test_encrypt_message')
@pytest.mark.parametrize('sf,cipher',
itertools.product(sorted(glob.glob('tests/testdata/keys/*.sec.asc')), sorted(SymmetricKeyAlgorithm)))
itertools.product(sorted(glob.glob('tests/testdata/keys/*.sec.asc')), symalgos))
def test_decrypt_message(self, sf, cipher):
# test decrypting a message
sec, _ = PGPKey.from_file(sf)
Expand All @@ -949,7 +950,7 @@ def test_decrypt_message(self, sf, cipher):

@pytest.mark.order(after='test_encrypt_message')
@pytest.mark.parametrize('sf,cipher',
itertools.product(sorted(glob.glob('tests/testdata/keys/*.sec.asc')), sorted(SymmetricKeyAlgorithm)))
itertools.product(sorted(glob.glob('tests/testdata/keys/*.sec.asc')), symalgos))
def test_sign_encrypted_message(self, sf, cipher):
# test decrypting a message
sec, _ = PGPKey.from_file(sf)
Expand Down