From 0b0384c4985210ba2763dc31de98afa59e3936e4 Mon Sep 17 00:00:00 2001 From: drebs Date: Tue, 12 Mar 2013 16:30:21 -0300 Subject: Add test for _has_keys(). --- src/leap/soledad/tests/test_crypto.py | 22 ++++++++++++++++++---- 1 file 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()) + -- cgit v1.2.3