summaryrefslogtreecommitdiff
path: root/src/leap/soledad/tests/test_crypto.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-03-12 16:30:21 -0300
committerdrebs <drebs@leap.se>2013-03-12 16:30:21 -0300
commit0b0384c4985210ba2763dc31de98afa59e3936e4 (patch)
treee9a85ddec162c8aba2b00638358c0ee490e17f12 /src/leap/soledad/tests/test_crypto.py
parent779fec037c012de6cfe77dd5cd6211feecd2e894 (diff)
Add test for _has_keys().
Diffstat (limited to 'src/leap/soledad/tests/test_crypto.py')
-rw-r--r--src/leap/soledad/tests/test_crypto.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/leap/soledad/tests/test_crypto.py b/src/leap/soledad/tests/test_crypto.py
index 4936b56c..52cc0315 100644
--- a/src/leap/soledad/tests/test_crypto.py
+++ b/src/leap/soledad/tests/test_crypto.py
@@ -154,6 +154,8 @@ class SoledadAuxMethods(BaseLeapTest):
def _soledad_instance(self):
return Soledad('leap@leap.se', bootstrap=False,
prefix=self.tempdir+'/soledad')
+ def _gpgwrapper_instance(self):
+ return GPGWrapper(gnupghome="%s/gnupg" % self.tempdir)
def test__init_dirs(self):
sol = self._soledad_instance()
@@ -163,7 +165,7 @@ class SoledadAuxMethods(BaseLeapTest):
def test__init_db(self):
sol = self._soledad_instance()
sol._init_dirs()
- sol._gpg = GPGWrapper(gnupghome="%s/gnupg" % self.tempdir)
+ sol._gpg = self._gpgwrapper_instance()
#self._soledad._gpg.import_keys(PUBLIC_KEY)
if not sol._has_privkey():
sol._set_privkey(PRIVATE_KEY)
@@ -177,17 +179,29 @@ class SoledadAuxMethods(BaseLeapTest):
def test__has_privkey(self):
sol = self._soledad_instance()
sol._init_dirs()
- sol._gpg = GPGWrapper(gnupghome="%s/gnupg" % self.tempdir)
+ sol._gpg = GPGWrapper(gnupghome="%s/gnupg2" % self.tempdir)
self.assertFalse(sol._has_privkey())
sol._set_privkey(PRIVATE_KEY)
self.assertTrue(sol._has_privkey())
def test__has_symkey(self):
- sol = self._soledad_instance()
+ sol = Soledad('leap@leap.se', bootstrap=False,
+ prefix=self.tempdir+'/soledad3')
sol._init_dirs()
- sol._gpg = GPGWrapper(gnupghome="%s/gnupg" % self.tempdir)
+ sol._gpg = GPGWrapper(gnupghome="%s/gnupg3" % self.tempdir)
if not sol._has_privkey():
sol._set_privkey(PRIVATE_KEY)
self.assertFalse(sol._has_symkey())
sol._gen_symkey()
self.assertTrue(sol._has_symkey())
+
+ def test__has_keys(self):
+ sol = self._soledad_instance()
+ sol._init_dirs()
+ sol._gpg = self._gpgwrapper_instance()
+ self.assertFalse(sol._has_keys())
+ sol._set_privkey(PRIVATE_KEY)
+ self.assertFalse(sol._has_keys())
+ sol._gen_symkey()
+ self.assertTrue(sol._has_keys())
+