aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/commands/tests
diff options
context:
space:
mode:
authorJ08nY2017-08-03 02:50:19 +0200
committerJ08nY2017-08-03 02:50:19 +0200
commit66f1510d1a38c10944a13665e1b7f9ecb14a8d8f (patch)
tree4acb1299d2f4359c3541d3a4c3318c9b1109b575 /src/mailman_pgp/commands/tests
parent5a79bd6c406816ff36e8bdbdb8e516c8e7d8f371 (diff)
downloadmailman-pgp-66f1510d1a38c10944a13665e1b7f9ecb14a8d8f.tar.gz
mailman-pgp-66f1510d1a38c10944a13665e1b7f9ecb14a8d8f.tar.zst
mailman-pgp-66f1510d1a38c10944a13665e1b7f9ecb14a8d8f.zip
Diffstat (limited to 'src/mailman_pgp/commands/tests')
-rw-r--r--src/mailman_pgp/commands/tests/test_key.py96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/mailman_pgp/commands/tests/test_key.py b/src/mailman_pgp/commands/tests/test_key.py
index d89c43d..900af7b 100644
--- a/src/mailman_pgp/commands/tests/test_key.py
+++ b/src/mailman_pgp/commands/tests/test_key.py
@@ -872,6 +872,102 @@ class TestAfterSubscription(unittest.TestCase):
'Need a key which can be used to encrypt communications.',
results_msg.get_payload())
+ def test_revoke_extra_arg(self):
+ message = _create_plain('bart@example.com', 'test@example.com',
+ 'key revoke extra arguments', '')
+ mm_config.switchboards['command'].enqueue(message,
+ listid='test.example.com')
+ make_testable_runner(CommandRunner, 'command').run()
+
+ items = get_queue_messages('virgin', expected_count=1)
+ results_msg = items[0].msg
+
+ self.assertIn('Extraneous argument/s: extra,arguments',
+ results_msg.get_payload())
+
+ def test_revoke_no_email(self):
+ message = _create_mixed('', 'test@example.com', 'key revoke')
+
+ mm_config.switchboards['command'].enqueue(message,
+ listid='test.example.com')
+ make_testable_runner(CommandRunner, 'command').run()
+ items = get_queue_messages('virgin', expected_count=1)
+ results_msg = items[0].msg
+
+ self.assertIn('No email to revoke key of.', results_msg.get_payload())
+
+ def test_revoke_no_pgp_address(self):
+ message = _create_mixed('bart@example.com', 'test@example.com',
+ 'key revoke')
+
+ mm_config.switchboards['command'].enqueue(message,
+ listid='test.example.com')
+ make_testable_runner(CommandRunner, 'command').run()
+ items = get_queue_messages('virgin', expected_count=1)
+ results_msg = items[0].msg
+
+ self.assertIn('A pgp enabled address not found.',
+ results_msg.get_payload())
+
+ def test_revoke_no_key_set(self):
+ bart = getUtility(IUserManager).create_address('bart@example.com',
+ 'Bart Person')
+ with transaction() as t:
+ pgp_address = PGPAddress(bart)
+ t.add(pgp_address)
+
+ message = _create_mixed('bart@example.com', 'test@example.com',
+ 'key revoke')
+
+ mm_config.switchboards['command'].enqueue(message,
+ listid='test.example.com')
+ make_testable_runner(CommandRunner, 'command').run()
+ items = get_queue_messages('virgin', expected_count=1)
+ results_msg = items[0].msg
+
+ self.assertIn("You currently don't have a key set.",
+ results_msg.get_payload())
+
+ def test_revoke_key_not_confirmed(self):
+ bart = getUtility(IUserManager).create_address('bart@example.com',
+ 'Bart Person')
+ with transaction() as t:
+ pgp_address = PGPAddress(bart)
+ pgp_address.key = self.bart_key.pubkey
+ t.add(pgp_address)
+
+ message = _create_mixed('bart@example.com', 'test@example.com',
+ 'key revoke')
+
+ mm_config.switchboards['command'].enqueue(message,
+ listid='test.example.com')
+ make_testable_runner(CommandRunner, 'command').run()
+ items = get_queue_messages('virgin', expected_count=1)
+ results_msg = items[0].msg
+
+ self.assertIn('Your key is currently not confirmed.',
+ results_msg.get_payload())
+
+ def test_revoke_no_revocs(self):
+ bart = getUtility(IUserManager).create_address('bart@example.com',
+ 'Bart Person')
+ with transaction() as t:
+ pgp_address = PGPAddress(bart)
+ pgp_address.key = self.bart_key.pubkey
+ pgp_address.key_confirmed = True
+ t.add(pgp_address)
+
+ message = _create_plain('bart@example.com', 'test@example.com',
+ 'key revoke', '')
+ mm_config.switchboards['command'].enqueue(message,
+ listid='test.example.com')
+ make_testable_runner(CommandRunner, 'command').run()
+ items = get_queue_messages('virgin', expected_count=1)
+ results_msg = items[0].msg
+
+ self.assertIn('No key revocations attached? Send a key revocation.',
+ results_msg.get_payload())
+
def test_revoke_resets(self):
bart = getUtility(IUserManager).create_address('bart@example.com',
'Bart Person')