aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/commands
diff options
context:
space:
mode:
authorJ08nY2017-07-14 01:44:54 +0200
committerJ08nY2017-07-14 01:44:54 +0200
commitd8afe4bec9282254483ea1c7571298dcd9731508 (patch)
treea847fca023b6601771ad0aeb35b0cbba9ee4480e /src/mailman_pgp/commands
parent8368cd832d21b404c01ab475ade6209b906ab422 (diff)
downloadmailman-pgp-d8afe4bec9282254483ea1c7571298dcd9731508.tar.gz
mailman-pgp-d8afe4bec9282254483ea1c7571298dcd9731508.tar.zst
mailman-pgp-d8afe4bec9282254483ea1c7571298dcd9731508.zip
Diffstat (limited to 'src/mailman_pgp/commands')
-rw-r--r--src/mailman_pgp/commands/tests/test_key.py65
1 files changed, 31 insertions, 34 deletions
diff --git a/src/mailman_pgp/commands/tests/test_key.py b/src/mailman_pgp/commands/tests/test_key.py
index 4f62b11..44d5b25 100644
--- a/src/mailman_pgp/commands/tests/test_key.py
+++ b/src/mailman_pgp/commands/tests/test_key.py
@@ -26,6 +26,7 @@ from mailman.interfaces.usermanager import IUserManager
from mailman.runners.command import CommandRunner
from mailman.testing.helpers import get_queue_messages, make_testable_runner
from mailman.utilities.datetime import now
+from public import public
from zope.component import getUtility
from mailman_pgp.config import mm_config
@@ -59,6 +60,7 @@ def _create_mixed(from_hdr, to_hdr, subject_hdr):
return message
+@public
class TestPreDispatch(unittest.TestCase):
layer = PGPConfigLayer
@@ -103,6 +105,7 @@ class TestPreDispatch(unittest.TestCase):
results_msg.get_payload())
+@public
class TestPreSubscription(unittest.TestCase):
layer = PGPConfigLayer
@@ -111,6 +114,9 @@ class TestPreSubscription(unittest.TestCase):
self.pgp_list = PGPMailingList.for_list(self.mlist)
self.pgp_list.key = load_key('ecc_p256.priv.asc')
+ self.bart_key = load_key('rsa_1024.priv.asc')
+ self.anne_key = load_key('ecc_p256.priv.asc')
+
def test_set(self):
self.mlist.subscription_policy = OpenSubscriptionPolicy
bart = getUtility(IUserManager).create_address('bart@example.com',
@@ -121,12 +127,10 @@ class TestPreSubscription(unittest.TestCase):
get_queue_messages('virgin')
- bart_key = load_key('rsa_1024.priv.asc')
-
set_message = _create_mixed('bart@example.com', 'test@example.com',
'Re: key set {}'.format(token))
wrapped_set_message = MIMEWrapper(set_message)
- set_message = wrapped_set_message.attach_key(bart_key.pubkey)
+ set_message = wrapped_set_message.attach_key(self.bart_key.pubkey)
mm_config.switchboards['command'].enqueue(set_message,
listid='test.example.com')
@@ -134,7 +138,8 @@ class TestPreSubscription(unittest.TestCase):
pgp_address = PGPAddress.for_address(bart)
self.assertIsNotNone(pgp_address)
- self.assertEqual(pgp_address.key.fingerprint, bart_key.fingerprint)
+ self.assertEqual(pgp_address.key.fingerprint,
+ self.bart_key.fingerprint)
self.assertFalse(pgp_address.key_confirmed)
items = get_queue_messages('virgin', expected_count=2)
@@ -146,7 +151,7 @@ class TestPreSubscription(unittest.TestCase):
confirm_request = items[0].msg
self.assertIn('Key succesfully set.', results.get_payload())
- self.assertIn('Key fingerprint: {}'.format(bart_key.fingerprint),
+ self.assertIn('Key fingerprint: {}'.format(self.bart_key.fingerprint),
results.get_payload())
confirm_wrapped = PGPWrapper(confirm_request)
@@ -178,15 +183,12 @@ class TestPreSubscription(unittest.TestCase):
results_msg.get_payload())
def test_set_multiple_keys(self):
- bart_key = load_key('rsa_1024.priv.asc')
- anne_key = load_key('ecc_p256.priv.asc')
-
set_message = _create_mixed('bart@example.com', 'test@example.com',
'Re: key set token')
wrapped_set_message = MIMEWrapper(set_message)
- set_message = wrapped_set_message.attach_key(bart_key.pubkey)
+ set_message = wrapped_set_message.attach_key(self.bart_key.pubkey)
wrapped_set_message = MIMEWrapper(set_message)
- set_message = wrapped_set_message.attach_key(anne_key.pubkey)
+ set_message = wrapped_set_message.attach_key(self.anne_key.pubkey)
mm_config.switchboards['command'].enqueue(set_message,
listid='test.example.com')
@@ -198,11 +200,9 @@ class TestPreSubscription(unittest.TestCase):
results_msg.get_payload())
def test_set_no_email(self):
- bart_key = load_key('rsa_1024.priv.asc')
-
message = _create_mixed('', 'test@example.com', 'key set token')
wrapped_message = MIMEWrapper(message)
- message = wrapped_message.attach_key(bart_key.pubkey)
+ message = wrapped_message.attach_key(self.bart_key.pubkey)
mm_config.switchboards['command'].enqueue(message,
listid='test.example.com')
@@ -213,12 +213,10 @@ class TestPreSubscription(unittest.TestCase):
self.assertIn('No email to subscribe with.', results_msg.get_payload())
def test_set_no_address(self):
- bart_key = load_key('rsa_1024.priv.asc')
-
set_message = _create_mixed('bart@example.com', 'test@example.com',
'key set token')
wrapped_set_message = MIMEWrapper(set_message)
- set_message = wrapped_set_message.attach_key(bart_key.pubkey)
+ set_message = wrapped_set_message.attach_key(self.bart_key.pubkey)
mm_config.switchboards['command'].enqueue(set_message,
listid='test.example.com')
@@ -235,19 +233,18 @@ class TestPreSubscription(unittest.TestCase):
'Bart Person')
bart.verified_on = now()
- bart_key = load_key('rsa_1024.priv.asc')
-
token, token_owner, member = ISubscriptionManager(self.mlist).register(
- bart, pubkey=bart_key.pubkey)
+ bart, pubkey=self.bart_key.pubkey)
get_queue_messages('virgin')
message = _create_plain('bart@example.com', 'test@example.com',
'Re: key confirm {}'.format(token),
- CONFIRM_REQUEST.format(bart_key.fingerprint,
- token))
+ CONFIRM_REQUEST.format(
+ self.bart_key.fingerprint,
+ token))
wrapped_message = MIMEWrapper(message)
- message = wrapped_message.sign(bart_key)
+ message = wrapped_message.sign(self.bart_key)
mm_config.switchboards['command'].enqueue(message,
listid='test.example.com')
@@ -263,20 +260,20 @@ class TestPreSubscription(unittest.TestCase):
'Bart Person')
bart.verified_on = now()
- bart_key = load_key('rsa_1024.priv.asc')
-
token, token_owner, member = ISubscriptionManager(self.mlist).register(
- bart, pubkey=bart_key.pubkey)
+ bart, pubkey=self.bart_key.pubkey)
get_queue_messages('virgin')
message = _create_plain('bart@example.com', 'test@example.com',
'Re: key confirm {}'.format(token),
- CONFIRM_REQUEST.format(bart_key.fingerprint,
- token))
+ CONFIRM_REQUEST.format(
+ self.bart_key.fingerprint,
+ token))
wrapped_message = MIMEWrapper(message)
- message = wrapped_message.sign_encrypt(bart_key, self.pgp_list.pubkey,
- bart_key.pubkey)
+ message = wrapped_message.sign_encrypt(self.bart_key,
+ self.pgp_list.pubkey,
+ self.bart_key.pubkey)
mm_config.switchboards['command'].enqueue(message,
listid='test.example.com')
@@ -330,17 +327,16 @@ class TestPreSubscription(unittest.TestCase):
'Bart Person')
bart.verified_on = now()
- bart_key = load_key('rsa_1024.priv.asc')
-
token, token_owner, member = ISubscriptionManager(self.mlist).register(
- bart, pubkey=bart_key.pubkey)
+ bart, pubkey=self.bart_key.pubkey)
get_queue_messages('virgin')
message = _create_plain('bart@example.com', 'test@example.com',
'Re: key confirm {}'.format(token),
- CONFIRM_REQUEST.format(bart_key.fingerprint,
- token))
+ CONFIRM_REQUEST.format(
+ self.bart_key.fingerprint,
+ token))
mm_config.switchboards['command'].enqueue(message,
listid='test.example.com')
@@ -353,6 +349,7 @@ class TestPreSubscription(unittest.TestCase):
results_msg.get_payload())
+@public
class TestAfterSubscription(unittest.TestCase):
layer = PGPConfigLayer