summaryrefslogtreecommitdiff
path: root/tests/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'tests/helpers')
-rw-r--r--tests/helpers/client_side_db.py50
1 files changed, 28 insertions, 22 deletions
diff --git a/tests/helpers/client_side_db.py b/tests/helpers/client_side_db.py
index d2a4bbcb..2f8c220f 100644
--- a/tests/helpers/client_side_db.py
+++ b/tests/helpers/client_side_db.py
@@ -2,11 +2,15 @@ import logging
import os
import tempfile
import getpass
-import requests
-import srp._pysrp as srp
import binascii
import json
+try:
+ import requests
+ import srp._pysrp as srp
+except ImportError:
+ pass
+
from twisted.internet.defer import inlineCallbacks
from leap.soledad.client import Soledad
@@ -14,6 +18,7 @@ from leap.soledad.client import Soledad
"""
Helper functions to give access to client-side Soledad database.
+Copied over from soledad/scripts folder.
"""
# create a logger
@@ -33,6 +38,27 @@ def _fail(reason):
exit(2)
+def get_soledad_instance(uuid, passphrase, basedir, server_url, cert_file,
+ token):
+ # setup soledad info
+ logger.info('UUID is %s' % uuid)
+ logger.info('Server URL is %s' % server_url)
+ secrets_path = os.path.join(
+ basedir, '%s.secret' % uuid)
+ local_db_path = os.path.join(
+ basedir, '%s.db' % uuid)
+ # instantiate soledad
+ return Soledad(
+ uuid,
+ unicode(passphrase),
+ secrets_path=secrets_path,
+ local_db_path=local_db_path,
+ server_url=server_url,
+ cert_file=cert_file,
+ auth_token=token,
+ defer_encryption=True)
+
+
def _get_api_info(provider):
info = requests.get(
'https://'+provider+'/provider.json', verify=False).json()
@@ -96,26 +122,6 @@ def _get_soledad_info(username, provider, passphrase, basedir):
return auth[2]['id'], server_url, cert_file, auth[2]['token']
-def get_soledad_instance(uuid, passphrase, basedir, server_url, cert_file,
- token):
- # setup soledad info
- logger.info('UUID is %s' % uuid)
- logger.info('Server URL is %s' % server_url)
- secrets_path = os.path.join(
- basedir, '%s.secret' % uuid)
- local_db_path = os.path.join(
- basedir, '%s.db' % uuid)
- # instantiate soledad
- return Soledad(
- uuid,
- unicode(passphrase),
- secrets_path=secrets_path,
- local_db_path=local_db_path,
- server_url=server_url,
- cert_file=cert_file,
- auth_token=token,
- defer_encryption=True)
-
def _get_passphrase(args):
passphrase = args.passphrase
if passphrase is None: