summaryrefslogtreecommitdiff
path: root/service/test
diff options
context:
space:
mode:
authorGiovane <giovaneliberato@gmail.com>2016-03-01 16:21:23 -0300
committerGiovane <giovaneliberato@gmail.com>2016-03-01 16:22:53 -0300
commite74cf4898f0274de22d5e11186af664f9f5f2003 (patch)
tree4c432a3396823b555f0c6f498b2bc10651867943 /service/test
parent1f613c23c16f6b34bcfd064791a3da7591ac19da (diff)
Fix tests after change on OpenPGPKey.get_json API
- The main identifier of a key now is the fingerprint, not the id anymore - The address is not required anymore when creating the json
Diffstat (limited to 'service/test')
-rw-r--r--service/test/unit/adapter/mailstore/maintenance/test_soledad_maintenance.py38
-rw-r--r--service/test/unit/resources/test_keys_resources.py24
2 files changed, 29 insertions, 33 deletions
diff --git a/service/test/unit/adapter/mailstore/maintenance/test_soledad_maintenance.py b/service/test/unit/adapter/mailstore/maintenance/test_soledad_maintenance.py
index e46d6864..be73af93 100644
--- a/service/test/unit/adapter/mailstore/maintenance/test_soledad_maintenance.py
+++ b/service/test/unit/adapter/mailstore/maintenance/test_soledad_maintenance.py
@@ -26,7 +26,7 @@ logging.getLogger('pixelated.adapter.mailstore.maintenance').addHandler(logging.
SOME_EMAIL_ADDRESS = 'foo@example.tld'
-SOME_KEY_ID = '4914254E384E264C'
+SOME_FINGERPRINT = '4914254E384E264C'
class TestSoledadMaintenance(unittest.TestCase):
@@ -42,8 +42,8 @@ class TestSoledadMaintenance(unittest.TestCase):
@defer.inlineCallbacks
def test_repair_delete_public_key_active_docs(self):
soledad = mock()
- key = self._public_key(SOME_EMAIL_ADDRESS, SOME_KEY_ID)
- active_doc = SoledadDocument(doc_id='some_doc', json=key.get_active_json(SOME_EMAIL_ADDRESS))
+ key = self._public_key(SOME_EMAIL_ADDRESS, SOME_FINGERPRINT)
+ active_doc = SoledadDocument(doc_id='some_doc', json=key.get_active_json())
when(soledad).get_all_docs().thenReturn(defer.succeed((1, [active_doc])))
yield SoledadMaintenance(soledad).repair()
@@ -53,8 +53,8 @@ class TestSoledadMaintenance(unittest.TestCase):
@defer.inlineCallbacks
def test_repair_delete_public_key_docs(self):
soledad = mock()
- key = self._public_key(SOME_EMAIL_ADDRESS, SOME_KEY_ID)
- active_doc = SoledadDocument(doc_id='some_doc', json=key.get_active_json(SOME_EMAIL_ADDRESS))
+ key = self._public_key(SOME_EMAIL_ADDRESS, SOME_FINGERPRINT)
+ active_doc = SoledadDocument(doc_id='some_doc', json=key.get_active_json())
key_doc = SoledadDocument(doc_id='some_doc', json=key.get_json())
when(soledad).get_all_docs().thenReturn(defer.succeed((1, [key_doc, active_doc])))
@@ -66,9 +66,9 @@ class TestSoledadMaintenance(unittest.TestCase):
@defer.inlineCallbacks
def test_repair_keeps_active_and_key_doc_if_private_key_exists(self):
soledad = mock()
- key = self._public_key(SOME_EMAIL_ADDRESS, SOME_KEY_ID)
- private_key = self._private_key(SOME_EMAIL_ADDRESS, SOME_KEY_ID)
- active_doc = SoledadDocument(doc_id='some_doc', json=key.get_active_json(SOME_EMAIL_ADDRESS))
+ key = self._public_key(SOME_EMAIL_ADDRESS, SOME_FINGERPRINT)
+ private_key = self._private_key(SOME_EMAIL_ADDRESS, SOME_FINGERPRINT)
+ active_doc = SoledadDocument(doc_id='some_doc', json=key.get_active_json())
key_doc = SoledadDocument(doc_id='some_doc', json=key.get_json())
private_key_doc = SoledadDocument(doc_id='some_doc', json=private_key.get_json())
when(soledad).get_all_docs().thenReturn(defer.succeed((1, [key_doc, active_doc, private_key_doc])))
@@ -82,8 +82,8 @@ class TestSoledadMaintenance(unittest.TestCase):
@defer.inlineCallbacks
def test_repair_only_deletes_key_docs(self):
soledad = mock()
- key = self._public_key(SOME_EMAIL_ADDRESS, SOME_KEY_ID)
- key_doc = SoledadDocument(doc_id='some_doc', json=key.get_active_json(SOME_EMAIL_ADDRESS))
+ key = self._public_key(SOME_EMAIL_ADDRESS, SOME_FINGERPRINT)
+ key_doc = SoledadDocument(doc_id='some_doc', json=key.get_active_json())
other_doc = SoledadDocument(doc_id='something', json='{}')
when(soledad).get_all_docs().thenReturn(defer.succeed((1, [key_doc, other_doc])))
@@ -95,19 +95,19 @@ class TestSoledadMaintenance(unittest.TestCase):
def test_repair_recreates_public_key_active_doc_if_necessary(self):
soledad = mock()
- private_key = self._private_key(SOME_EMAIL_ADDRESS, SOME_KEY_ID)
- private_key_doc = SoledadDocument(doc_id='some_doc', json=private_key.get_json())
+ private_key = self._private_key(SOME_EMAIL_ADDRESS, SOME_FINGERPRINT)
+ private_key_doc = SoledadDocument(doc_id='some_doc', json=private_key.get_active_json())
when(soledad).get_all_docs().thenReturn(defer.succeed((1, [private_key_doc])))
yield SoledadMaintenance(soledad).repair()
- verify(soledad).create_doc_from_json('{"key_id": "4914254E384E264C", "tags": ["keymanager-active"], "type": "OpenPGPKey-active", "private": false, "address": "foo@example.tld"}')
+ verify(soledad).create_doc_from_json('{"encr_used": false, "sign_used": false, "validation": "Weak_Chain", "version": 1, "address": "foo@example.tld", "last_audited_at": 0, "fingerprint": "4914254E384E264C", "type": "OpenPGPKey-active", "private": false, "tags": ["keymanager-active"]}')
- def _public_key(self, address, keyid):
- return self._gpgkey(address, keyid, private=False)
+ def _public_key(self, address, fingerprint):
+ return self._gpgkey(address, fingerprint, private=False)
- def _private_key(self, address, keyid):
- return self._gpgkey(address, keyid, private=True)
+ def _private_key(self, address, fingerprint):
+ return self._gpgkey(address, fingerprint, private=True)
- def _gpgkey(self, address, keyid, private=False):
- return OpenPGPKey(address, key_id=keyid, private=private)
+ def _gpgkey(self, address, fingerprint, private=False):
+ return OpenPGPKey(address, fingerprint=fingerprint, private=private)
diff --git a/service/test/unit/resources/test_keys_resources.py b/service/test/unit/resources/test_keys_resources.py
index 6aa822e1..2bf53cb4 100644
--- a/service/test/unit/resources/test_keys_resources.py
+++ b/service/test/unit/resources/test_keys_resources.py
@@ -44,20 +44,16 @@ class TestKeysResource(unittest.TestCase):
d = self.web.get(request)
expected = {
- "tags": ["keymanager-key"],
- "fingerprint": '',
- "private": False,
- 'sign_used': False,
- 'refreshed_at': 0,
- "expiry_date": 0,
- "address": 'some@key',
- 'encr_used': False,
- 'last_audited_at': 0,
- 'key_data': '',
- 'length': 0,
- 'key_id': '',
- 'validation': 'Weak_Chain',
- 'type': 'OpenPGPKey',
+ u'address': u'some@key',
+ u'encr_used': False,
+ u'fingerprint': u'',
+ u'last_audited_at': 0,
+ u'private': False,
+ u'sign_used': False,
+ u'tags': [u'keymanager-active'],
+ u'type': u'OpenPGPKey-active',
+ u'validation': u'Weak_Chain',
+ u'version': 1,
}
def assert_response(_):