diff options
author | drebs <drebs@leap.se> | 2014-07-29 16:09:48 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2014-07-29 16:09:48 -0300 |
commit | 4f1584857aa39e7f048ecfb616127f4152d32add (patch) | |
tree | e992505057a42ab63ab44681591225c499be6539 /keymanager | |
parent | 485953a1eb822eaac66bbe07ce5bde592c07a5e4 (diff) | |
parent | 008328cc0ad2738109472869f3644100ca85859d (diff) |
Merge branch 'bug/tests-dont-pass' into develop
Diffstat (limited to 'keymanager')
-rw-r--r-- | keymanager/src/leap/keymanager/openpgp.py | 12 | ||||
-rw-r--r-- | keymanager/src/leap/keymanager/tests/test_keymanager.py | 9 |
2 files changed, 13 insertions, 8 deletions
diff --git a/keymanager/src/leap/keymanager/openpgp.py b/keymanager/src/leap/keymanager/openpgp.py index 950d022c..46ae2aab 100644 --- a/keymanager/src/leap/keymanager/openpgp.py +++ b/keymanager/src/leap/keymanager/openpgp.py @@ -649,13 +649,17 @@ class OpenPGPScheme(EncryptionScheme): result = gpg.verify(data) else: # to verify using a detached sig we have to use - # gpg.verify_file(), which receives the data as a binary - # stream and the name of a file containing the signature. + # gpg.verify_file(), which receives the name of + # files containing the date and the signature. sf, sfname = tempfile.mkstemp() with os.fdopen(sf, 'w') as sfd: sfd.write(detached_sig) - with closing(_make_binary_stream(data, gpg._encoding)) as df: - result = gpg.verify_file(df, sig_file=sfname) + df, dfname = tempfile.mkstemp() + with os.fdopen(df, 'w') as sdd: + sdd.write(data) + result = gpg.verify_file(dfname, sig_file=sfname) + os.unlink(sfname) + os.unlink(dfname) gpgpubkey = gpg.list_keys().pop() valid = result.valid rfprint = result.fingerprint diff --git a/keymanager/src/leap/keymanager/tests/test_keymanager.py b/keymanager/src/leap/keymanager/tests/test_keymanager.py index e2558e45..f89dcd9b 100644 --- a/keymanager/src/leap/keymanager/tests/test_keymanager.py +++ b/keymanager/src/leap/keymanager/tests/test_keymanager.py @@ -147,8 +147,8 @@ class KeyManagerWithSoledadTestCase(BaseLeapTest): for key in km.get_all_keys_in_local_db(private=True): km._wrapper_map[key.__class__].delete_key(key) - def _key_manager(self, user=ADDRESS, url=''): - return KeyManager(user, url, self._soledad, + def _key_manager(self, user=ADDRESS, url='', token=None): + return KeyManager(user, url, self._soledad, token=token, gpgbinary=GPG_BINARY_PATH) @@ -387,7 +387,8 @@ class KeyManagerKeyManagementTestCase(KeyManagerWithSoledadTestCase): """ Test that request is well formed when sending keys to server. """ - km = self._key_manager() + token = "mytoken" + km = self._key_manager(token=token) km._wrapper_map[OpenPGPKey].put_ascii_key(PUBLIC_KEY) km._fetcher.put = Mock() # the following data will be used on the send @@ -404,7 +405,7 @@ class KeyManagerKeyManagementTestCase(KeyManagerWithSoledadTestCase): url = '%s/%s/users/%s.json' % ('apiuri', 'apiver', 'myuid') km._fetcher.put.assert_called_once_with( url, data=data, verify='capath', - cookies={'_session_id': 'sessionid'}, + headers={'Authorization': 'Token token=%s' % token}, ) def test__fetch_keys_from_server(self): |