summaryrefslogtreecommitdiff
path: root/src/leap/soledad/tests
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-03-11 16:54:58 -0300
committerdrebs <drebs@leap.se>2013-03-11 17:43:19 -0300
commitcbff516a2542a9d48704774bbd2477e5a1587d6e (patch)
treecb5c14c82c2519a6d88de60e9c937532c71132e8 /src/leap/soledad/tests
parentab1e1c8862b70d47c7e5f10267639ef71b3bc536 (diff)
Refactor and organize bootstrap sequence.
Diffstat (limited to 'src/leap/soledad/tests')
-rw-r--r--src/leap/soledad/tests/__init__.py14
-rw-r--r--src/leap/soledad/tests/test_encrypted.py19
2 files changed, 18 insertions, 15 deletions
diff --git a/src/leap/soledad/tests/__init__.py b/src/leap/soledad/tests/__init__.py
index fdde8c78..1ed2e248 100644
--- a/src/leap/soledad/tests/__init__.py
+++ b/src/leap/soledad/tests/__init__.py
@@ -32,16 +32,16 @@ class BaseSoledadTest(BaseLeapTest):
document_factory=LeapDocument)
# initialize soledad by hand so we can control keys
self._soledad = Soledad(self.email, gnupg_home=self.gnupg_home,
- initialize=False,
+ bootstrap=False,
prefix=self.tempdir)
self._soledad._init_dirs()
self._soledad._gpg = GPGWrapper(gnupghome=self.gnupg_home)
- self._soledad._gpg.import_keys(PUBLIC_KEY)
- self._soledad._gpg.import_keys(PRIVATE_KEY)
- self._soledad._load_openpgp_keypair()
- if not self._soledad._has_secret():
- self._soledad._gen_secret()
- self._soledad._load_secret()
+ #self._soledad._gpg.import_keys(PUBLIC_KEY)
+ if not self._soledad._has_privkey():
+ self._soledad._set_privkey(PRIVATE_KEY)
+ if not self._soledad._has_symkey():
+ self._soledad._gen_symkey()
+ self._soledad._load_symkey()
self._soledad._init_db()
def tearDown(self):
diff --git a/src/leap/soledad/tests/test_encrypted.py b/src/leap/soledad/tests/test_encrypted.py
index eb78fbe3..b4821cf4 100644
--- a/src/leap/soledad/tests/test_encrypted.py
+++ b/src/leap/soledad/tests/test_encrypted.py
@@ -43,6 +43,9 @@ class EncryptedSyncTestCase(BaseSoledadTest):
self._soledad._gpg.is_encrypted_sym(enc_json),
"could not encrypt with passphrase.")
+
+class RecoveryDocumentTestCase(BaseSoledadTest):
+
def test_export_recovery_document_raw(self):
rd = self._soledad.export_recovery_document(None)
self.assertEqual(
@@ -51,7 +54,7 @@ class EncryptedSyncTestCase(BaseSoledadTest):
'privkey': self._soledad._gpg.export_keys(
self._soledad._fingerprint,
secret=True),
- 'secret': self._soledad._secret
+ 'symkey': self._soledad._symkey
},
json.loads(rd),
"Could not export raw recovery document."
@@ -66,7 +69,7 @@ class EncryptedSyncTestCase(BaseSoledadTest):
'privkey': self._soledad._gpg.export_keys(
self._soledad._fingerprint,
secret=True),
- 'secret': self._soledad._secret,
+ 'symkey': self._soledad._symkey,
}
raw_data = json.loads(str(self._soledad._gpg.decrypt(
rd,
@@ -86,14 +89,14 @@ class EncryptedSyncTestCase(BaseSoledadTest):
rd = self._soledad.export_recovery_document(None)
gnupg_home = self.gnupg_home = "%s/gnupg2" % self.tempdir
s = Soledad('anotheruser@leap.se', gnupg_home=gnupg_home,
- initialize=False, prefix=self.tempdir)
+ bootstrap=False, prefix=self.tempdir)
s._init_dirs()
s._gpg = GPGWrapper(gnupghome=gnupg_home)
s.import_recovery_document(rd, None)
self.assertEqual(self._soledad._user_email,
s._user_email, 'Failed setting user email.')
- self.assertEqual(self._soledad._secret,
- s._secret,
+ self.assertEqual(self._soledad._symkey,
+ s._symkey,
'Failed settinng secret for symmetric encryption.')
self.assertEqual(self._soledad._fingerprint,
s._fingerprint,
@@ -112,14 +115,14 @@ class EncryptedSyncTestCase(BaseSoledadTest):
rd = self._soledad.export_recovery_document('123456')
gnupg_home = self.gnupg_home = "%s/gnupg2" % self.tempdir
s = Soledad('anotheruser@leap.se', gnupg_home=gnupg_home,
- initialize=False, prefix=self.tempdir)
+ bootstrap=False, prefix=self.tempdir)
s._init_dirs()
s._gpg = GPGWrapper(gnupghome=gnupg_home)
s.import_recovery_document(rd, '123456')
self.assertEqual(self._soledad._user_email,
s._user_email, 'Failed setting user email.')
- self.assertEqual(self._soledad._secret,
- s._secret,
+ self.assertEqual(self._soledad._symkey,
+ s._symkey,
'Failed settinng secret for symmetric encryption.')
self.assertEqual(self._soledad._fingerprint,
s._fingerprint,