summaryrefslogtreecommitdiff
path: root/src/leap/common/tests
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-04-19 21:48:57 -0300
committerdrebs <drebs@leap.se>2013-04-19 21:57:18 -0300
commitb833d9042da3a1650fde3354f38998a2e497672b (patch)
tree7129bf066d772f228f6431d7a09cbad15b861cf2 /src/leap/common/tests
parent32999ef8d08b6e94d356ea5fbce43ceebbf5247c (diff)
Make keymanager OpenPGP wrapper store using Soledad.
Diffstat (limited to 'src/leap/common/tests')
-rw-r--r--src/leap/common/tests/test_keymanager.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/leap/common/tests/test_keymanager.py b/src/leap/common/tests/test_keymanager.py
index 4189aac..23d702b 100644
--- a/src/leap/common/tests/test_keymanager.py
+++ b/src/leap/common/tests/test_keymanager.py
@@ -26,12 +26,26 @@ import unittest
from leap.common.testing.basetest import BaseLeapTest
from leap.common.keymanager import KeyManager, openpgp, KeyNotFound
-
+from leap.soledad import Soledad
+from leap.common.keymanager.gpg import GPGWrapper
class KeyManagerTestCase(BaseLeapTest):
def setUp(self):
- pass
+ self._soledad = Soledad(
+ "leap@leap.se",
+ "123456",
+ gnupg_home=self.tempdir+"/gnupg",
+ secret_path=self.tempdir+"/secret.gpg",
+ local_db_path=self.tempdir+"/soledad.u1db",
+ bootstrap=False,
+ )
+ # initialize solead by hand for testing purposes
+ self._soledad._init_dirs()
+ self._soledad._gpg = GPGWrapper(gnupghome=self.tempdir+"/gnupg")
+ self._soledad._shared_db = None
+ self._soledad._init_keys()
+ self._soledad._init_db()
def tearDown(self):
pass
@@ -40,7 +54,7 @@ class KeyManagerTestCase(BaseLeapTest):
return KeyManager(user, url)
def test_openpgp_gen_key(self):
- pgp = openpgp.OpenPGPWrapper(self.tempdir+'/gnupg')
+ pgp = openpgp.OpenPGPWrapper(self._soledad)
try:
pgp.get_key('user@leap.se')
except KeyNotFound:
@@ -51,12 +65,12 @@ class KeyManagerTestCase(BaseLeapTest):
self.assertEqual(
'4096', key.length, 'Wrong key length.')
- def test_openpgp_put_key(self):
- pgp = openpgp.OpenPGPWrapper(self.tempdir+'/gnupg2')
+ def test_openpgp_put_key_raw(self):
+ pgp = openpgp.OpenPGPWrapper(self._soledad)
try:
pgp.get_key('leap@leap.se')
except KeyNotFound:
- pgp.put_key(PUBLIC_KEY)
+ pgp.put_key_raw(PUBLIC_KEY)
key = pgp.get_key('leap@leap.se')
self.assertIsInstance(key, openpgp.OpenPGPKey)
self.assertEqual(