diff options
author | Tulio Casagrande <tcasagra@thoughtworks.com> | 2016-09-06 17:45:19 -0300 |
---|---|---|
committer | Bruno Wagner <bwagner@riseup.net> | 2016-09-08 14:09:30 -0300 |
commit | eb61dad1ac92c0c0e5bcce34b3aa68b50d40c518 (patch) | |
tree | 42fec68f02de85364e7ac15a2c80d0fa9ef20af8 /service/test | |
parent | 9237868a1c71bf68d797c2d4b1982628c3805648 (diff) |
[#778][Test] Don't send an existing public key
I added a new test to check that an existing public key is not being
sent to leap on every login
Diffstat (limited to 'service/test')
-rw-r--r-- | service/test/unit/bitmask_libraries/test_keymanager.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/service/test/unit/bitmask_libraries/test_keymanager.py b/service/test/unit/bitmask_libraries/test_keymanager.py index cdd6f3de..0c46460a 100644 --- a/service/test/unit/bitmask_libraries/test_keymanager.py +++ b/service/test/unit/bitmask_libraries/test_keymanager.py @@ -19,7 +19,6 @@ from mockito import when from test_abstract_leap import AbstractLeapTest from leap.keymanager import openpgp, KeyNotFound from pixelated.bitmask_libraries.keymanager import Keymanager -from pixelated.bitmask_libraries.certs import LeapCertificate from pixelated.config import leap_config @@ -64,4 +63,20 @@ class KeymanagerTest(AbstractLeapTest): keymanager.generate_openpgp_key() keyman.get_key.assert_called_with('test_user@some-server.test', private=True, fetch_remote=False) - keyman.gen_key.assert_called() + keyman.gen_key.assert_called_once() + keyman.send_key.assert_called_once() + + @patch('pixelated.bitmask_libraries.keymanager.KeyManager') + def test_existing_key_not_sent_to_leap(self, keymanager_mock): + keyman = keymanager_mock.return_value + keyman.get_key.side_effect = KeyNotFound + keymanager = Keymanager(self.provider, + self.soledad, + 'test_user@some-server.test', + self.auth.token, + self.auth.uuid) + + when(keymanager)._key_exists('test_user@some-server.test').thenReturn(True) + keymanager.generate_openpgp_key() + keyman.gen_key.assert_not_called() + keyman.send_key.assert_not_called() |