summaryrefslogtreecommitdiff
path: root/common/src
diff options
context:
space:
mode:
Diffstat (limited to 'common/src')
-rw-r--r--common/src/leap/soledad/common/README.txt4
-rw-r--r--common/src/leap/soledad/common/backend.py15
-rw-r--r--common/src/leap/soledad/common/couch/__init__.py4
-rw-r--r--common/src/leap/soledad/common/couch/state.py10
-rw-r--r--common/src/leap/soledad/common/document.py4
-rw-r--r--common/src/leap/soledad/common/errors.py5
-rw-r--r--common/src/leap/soledad/common/l2db/__init__.py6
-rw-r--r--common/src/leap/soledad/common/l2db/backends/__init__.py16
-rw-r--r--common/src/leap/soledad/common/l2db/backends/inmemory.py11
-rw-r--r--common/src/leap/soledad/common/l2db/backends/sqlite_backend.py16
-rw-r--r--common/src/leap/soledad/common/l2db/query_parser.py11
-rw-r--r--common/src/leap/soledad/common/l2db/remote/http_app.py21
-rw-r--r--common/src/leap/soledad/common/l2db/remote/http_client.py16
-rw-r--r--common/src/leap/soledad/common/l2db/remote/http_database.py14
-rw-r--r--common/src/leap/soledad/common/l2db/remote/http_errors.py11
-rw-r--r--common/src/leap/soledad/common/l2db/remote/http_target.py15
-rw-r--r--common/src/leap/soledad/common/l2db/sync.py9
-rw-r--r--common/src/leap/soledad/common/tests/server_state.py2
-rw-r--r--common/src/leap/soledad/common/tests/test_async.py2
-rw-r--r--common/src/leap/soledad/common/tests/test_couch.py15
-rw-r--r--common/src/leap/soledad/common/tests/test_http.py2
-rw-r--r--common/src/leap/soledad/common/tests/test_http_client.py5
-rw-r--r--common/src/leap/soledad/common/tests/test_https.py15
-rw-r--r--common/src/leap/soledad/common/tests/test_server.py9
-rw-r--r--common/src/leap/soledad/common/tests/test_soledad_app.py4
-rw-r--r--common/src/leap/soledad/common/tests/test_sqlcipher.py8
-rw-r--r--common/src/leap/soledad/common/tests/test_sqlcipher_sync.py13
-rw-r--r--common/src/leap/soledad/common/tests/test_sync.py2
-rw-r--r--common/src/leap/soledad/common/tests/test_sync_target.py36
-rw-r--r--common/src/leap/soledad/common/tests/u1db_tests/__init__.py14
-rw-r--r--common/src/leap/soledad/common/tests/u1db_tests/test_backends.py19
-rw-r--r--common/src/leap/soledad/common/tests/u1db_tests/test_document.py10
-rw-r--r--common/src/leap/soledad/common/tests/u1db_tests/test_http_client.py18
-rw-r--r--common/src/leap/soledad/common/tests/u1db_tests/test_http_database.py9
-rw-r--r--common/src/leap/soledad/common/tests/u1db_tests/test_https.py196
-rw-r--r--common/src/leap/soledad/common/tests/u1db_tests/test_open.py10
-rw-r--r--common/src/leap/soledad/common/tests/util.py12
37 files changed, 273 insertions, 316 deletions
diff --git a/common/src/leap/soledad/common/README.txt b/common/src/leap/soledad/common/README.txt
index 106efb5e..38b9858e 100644
--- a/common/src/leap/soledad/common/README.txt
+++ b/common/src/leap/soledad/common/README.txt
@@ -3,10 +3,10 @@ Soledad common package
This package contains Soledad bits used by both server and client.
-Couch U1DB Backend
+Couch L2DB Backend
------------------
-U1DB backends rely on some atomic operations that modify documents contents
+L2DB backends rely on some atomic operations that modify documents contents
and metadata (conflicts, transaction ids and indexes). The only atomic
operation in Couch is a document put, so every u1db atomic operation has to be
mapped to a couch document put.
diff --git a/common/src/leap/soledad/common/backend.py b/common/src/leap/soledad/common/backend.py
index 0a36c068..f4f48f86 100644
--- a/common/src/leap/soledad/common/backend.py
+++ b/common/src/leap/soledad/common/backend.py
@@ -16,27 +16,28 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-"""A U1DB generic backend."""
+"""A L2DB generic backend."""
import functools
-from u1db import vectorclock
-from u1db.errors import (
+
+from leap.soledad.common.document import ServerDocument
+from leap.soledad.common.l2db import vectorclock
+from leap.soledad.common.l2db.errors import (
RevisionConflict,
InvalidDocId,
ConflictedDoc,
DocumentDoesNotExist,
DocumentAlreadyDeleted,
)
-from u1db.backends import CommonBackend
-from u1db.backends import CommonSyncTarget
-from leap.soledad.common.document import ServerDocument
+from leap.soledad.common.l2db.backends import CommonBackend
+from leap.soledad.common.l2db.backends import CommonSyncTarget
class SoledadBackend(CommonBackend):
BATCH_SUPPORT = False
"""
- A U1DB backend implementation.
+ A L2DB backend implementation.
"""
def __init__(self, database, replica_uid=None):
diff --git a/common/src/leap/soledad/common/couch/__init__.py b/common/src/leap/soledad/common/couch/__init__.py
index 8c60b6a4..523a50a0 100644
--- a/common/src/leap/soledad/common/couch/__init__.py
+++ b/common/src/leap/soledad/common/couch/__init__.py
@@ -42,12 +42,12 @@ from couchdb.http import (
urljoin as couch_urljoin,
Resource,
)
-from u1db.errors import (
+from leap.soledad.common.l2db.errors import (
DatabaseDoesNotExist,
InvalidGeneration,
RevisionConflict,
)
-from u1db.remote import http_app
+from leap.soledad.common.l2db.remote import http_app
from leap.soledad.common import ddocs
diff --git a/common/src/leap/soledad/common/couch/state.py b/common/src/leap/soledad/common/couch/state.py
index 4f07c105..9b40a264 100644
--- a/common/src/leap/soledad/common/couch/state.py
+++ b/common/src/leap/soledad/common/couch/state.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# state.py
-# Copyright (C) 2015 LEAP
+# Copyright (C) 2015,2016 LEAP
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,17 +17,17 @@
"""
Server state using CouchDatabase as backend.
"""
-import re
import logging
+import re
import time
from urlparse import urljoin
from hashlib import sha512
-from u1db.remote.server_state import ServerState
-from leap.soledad.common.command import exec_validated_cmd
from leap.soledad.common.couch import CouchDatabase
from leap.soledad.common.couch import couch_server
-from u1db.errors import Unauthorized
+from leap.soledad.common.command import exec_validated_cmd
+from leap.soledad.common.l2db.remote.server_state import ServerState
+from leap.soledad.common.l2db.errors import Unauthorized
logger = logging.getLogger(__name__)
diff --git a/common/src/leap/soledad/common/document.py b/common/src/leap/soledad/common/document.py
index 9e0c0976..6c26a29f 100644
--- a/common/src/leap/soledad/common/document.py
+++ b/common/src/leap/soledad/common/document.py
@@ -17,11 +17,11 @@
"""
-A Soledad Document is an u1db.Document with lasers.
+A Soledad Document is an l2db.Document with lasers.
"""
-from u1db import Document
+from .l2db import Document
#
diff --git a/common/src/leap/soledad/common/errors.py b/common/src/leap/soledad/common/errors.py
index 76a7240d..dec871c9 100644
--- a/common/src/leap/soledad/common/errors.py
+++ b/common/src/leap/soledad/common/errors.py
@@ -20,9 +20,8 @@
Soledad errors.
"""
-
-from u1db import errors
-from u1db.remote import http_errors
+from .l2db import errors
+from .l2db.remote import http_errors
def register_exception(cls):
diff --git a/common/src/leap/soledad/common/l2db/__init__.py b/common/src/leap/soledad/common/l2db/__init__.py
index e33309a4..cc121d06 100644
--- a/common/src/leap/soledad/common/l2db/__init__.py
+++ b/common/src/leap/soledad/common/l2db/__init__.py
@@ -14,14 +14,14 @@
# You should have received a copy of the GNU Lesser General Public License
# along with u1db. If not, see <http://www.gnu.org/licenses/>.
-"""U1DB"""
+"""L2DB"""
try:
import simplejson as json
except ImportError:
import json # noqa
-from u1db.errors import InvalidJSON, InvalidContent
+from leap.soledad.common.l2db.errors import InvalidJSON, InvalidContent
__version_info__ = (13, 9)
__version__ = '.'.join(map(lambda x: '%02d' % x, __version_info__))
@@ -40,7 +40,7 @@ def open(path, create, document_factory=None):
parameters as Document.__init__.
:return: An instance of Database.
"""
- from u1db.backends import sqlite_backend
+ from leap.soledad.common.l2db.backends import sqlite_backend
return sqlite_backend.SQLiteDatabase.open_database(
path, create=create, document_factory=document_factory)
diff --git a/common/src/leap/soledad/common/l2db/backends/__init__.py b/common/src/leap/soledad/common/l2db/backends/__init__.py
index a647c8aa..922daafd 100644
--- a/common/src/leap/soledad/common/l2db/backends/__init__.py
+++ b/common/src/leap/soledad/common/l2db/backends/__init__.py
@@ -23,22 +23,20 @@ except ImportError:
import json # noqa
import uuid
-import u1db
-from u1db import (
- errors,
-)
-import u1db.sync
-from u1db.vectorclock import VectorClockRev
+from leap.soledad.common import l2db
+from leap.soledad.common.l2db import sync as l2db_sync
+from leap.soledad.common.l2db import errors
+from leap.soledad.common.l2db.vectorclock import VectorClockRev
-check_doc_id_re = re.compile("^" + u1db.DOC_ID_CONSTRAINTS + "$", re.UNICODE)
+check_doc_id_re = re.compile("^" + l2db.DOC_ID_CONSTRAINTS + "$", re.UNICODE)
-class CommonSyncTarget(u1db.sync.LocalSyncTarget):
+class CommonSyncTarget(l2db_sync.LocalSyncTarget):
pass
-class CommonBackend(u1db.Database):
+class CommonBackend(l2db.Database):
document_size_limit = 0
diff --git a/common/src/leap/soledad/common/l2db/backends/inmemory.py b/common/src/leap/soledad/common/l2db/backends/inmemory.py
index 1feb1604..06a934a6 100644
--- a/common/src/leap/soledad/common/l2db/backends/inmemory.py
+++ b/common/src/leap/soledad/common/l2db/backends/inmemory.py
@@ -21,13 +21,10 @@ try:
except ImportError:
import json # noqa
-from u1db import (
- Document,
- errors,
- query_parser,
- vectorclock,
- )
-from u1db.backends import CommonBackend, CommonSyncTarget
+from leap.soledad.common.l2db import (
+ Document, errors,
+ query_parser, vectorclock)
+from leap.soledad.common.l2db.backends import CommonBackend, CommonSyncTarget
def get_prefix(value):
diff --git a/common/src/leap/soledad/common/l2db/backends/sqlite_backend.py b/common/src/leap/soledad/common/l2db/backends/sqlite_backend.py
index 773213b5..309000ee 100644
--- a/common/src/leap/soledad/common/l2db/backends/sqlite_backend.py
+++ b/common/src/leap/soledad/common/l2db/backends/sqlite_backend.py
@@ -1,4 +1,5 @@
# Copyright 2011 Canonical Ltd.
+# Copyright 2016 LEAP Encryption Access Project
#
# This file is part of u1db.
#
@@ -14,7 +15,9 @@
# You should have received a copy of the GNU Lesser General Public License
# along with u1db. If not, see <http://www.gnu.org/licenses/>.
-"""A U1DB implementation that uses SQLite as its persistence layer."""
+"""
+A L2DB implementation that uses SQLite as its persistence layer.
+"""
import errno
import os
@@ -29,13 +32,10 @@ import uuid
import pkg_resources
-from u1db.backends import CommonBackend, CommonSyncTarget
-from u1db import (
- Document,
- errors,
- query_parser,
- vectorclock,
- )
+from leap.soledad.common.l2db.backends import CommonBackend, CommonSyncTarget
+from leap.soledad.common.l2db import (
+ Document, errors,
+ query_parser, vectorclock)
class SQLiteDatabase(CommonBackend):
diff --git a/common/src/leap/soledad/common/l2db/query_parser.py b/common/src/leap/soledad/common/l2db/query_parser.py
index f564821f..7f07b554 100644
--- a/common/src/leap/soledad/common/l2db/query_parser.py
+++ b/common/src/leap/soledad/common/l2db/query_parser.py
@@ -1,4 +1,5 @@
# Copyright 2011 Canonical Ltd.
+# Copyright 2016 LEAP Encryption Access Project
#
# This file is part of u1db.
#
@@ -13,13 +14,13 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with u1db. If not, see <http://www.gnu.org/licenses/>.
-
-"""Code for parsing Index definitions."""
+"""
+Code for parsing Index definitions.
+"""
import re
-from u1db import (
- errors,
- )
+
+from leap.soledad.common.l2db import errors
class Getter(object):
diff --git a/common/src/leap/soledad/common/l2db/remote/http_app.py b/common/src/leap/soledad/common/l2db/remote/http_app.py
index 85cdb029..3b65f5f7 100644
--- a/common/src/leap/soledad/common/l2db/remote/http_app.py
+++ b/common/src/leap/soledad/common/l2db/remote/http_app.py
@@ -1,4 +1,5 @@
# Copyright 2011-2012 Canonical Ltd.
+# Copyright 2016 LEAP Encryption Access Project
#
# This file is part of u1db.
#
@@ -14,7 +15,11 @@
# You should have received a copy of the GNU Lesser General Public License
# along with u1db. If not, see <http://www.gnu.org/licenses/>.
-"""HTTP Application exposing U1DB."""
+"""
+HTTP Application exposing U1DB.
+"""
+
+# TODO -- deprecate, use twisted/txaio.
import functools
import httplib
@@ -28,17 +33,11 @@ import urlparse
import routes.mapper
-from u1db import (
+from leap.soledad.common.l2db import (
__version__ as _u1db_version,
- DBNAME_CONSTRAINTS,
- Document,
- errors,
- sync,
- )
-from u1db.remote import (
- http_errors,
- utils,
- )
+ DBNAME_CONSTRAINTS, Document,
+ errors, sync)
+from leap.soledad.common.l2db.remote import http_errors, utils
def parse_bool(expression):
diff --git a/common/src/leap/soledad/common/l2db/remote/http_client.py b/common/src/leap/soledad/common/l2db/remote/http_client.py
index 2044d756..eea42888 100644
--- a/common/src/leap/soledad/common/l2db/remote/http_client.py
+++ b/common/src/leap/soledad/common/l2db/remote/http_client.py
@@ -1,4 +1,5 @@
# Copyright 2011-2012 Canonical Ltd.
+# Copyright 2016 LEAP Encryption Access Project
#
# This file is part of u1db.
#
@@ -29,17 +30,12 @@ import urlparse
import urllib
from time import sleep
-from u1db import (
- errors,
- )
-from u1db.remote import (
- http_errors,
- )
-
-from u1db.remote.ssl_match_hostname import ( # noqa
+from leap.soledad.common.l2db import errors
+from leap.soledad.common.l2db.remote import http_errors
+
+from leap.soledad.common.l2db.remote.ssl_match_hostname import ( # noqa
CertificateError,
- match_hostname,
- )
+ match_hostname)
# Ubuntu/debian
# XXX other...
diff --git a/common/src/leap/soledad/common/l2db/remote/http_database.py b/common/src/leap/soledad/common/l2db/remote/http_database.py
index 400e4020..d8dcfd55 100644
--- a/common/src/leap/soledad/common/l2db/remote/http_database.py
+++ b/common/src/leap/soledad/common/l2db/remote/http_database.py
@@ -22,16 +22,14 @@ except ImportError:
import json # noqa
import uuid
-from u1db import (
+from leap.soledad.common.l2db import (
Database,
Document,
- errors,
- )
-from u1db.remote import (
+ errors)
+from leap.soledad.common.l2db.remote import (
http_client,
http_errors,
- http_target,
- )
+ http_target)
DOCUMENT_DELETED_STATUS = http_errors.wire_description_to_status[
@@ -152,8 +150,8 @@ class HTTPDatabase(http_client.HTTPClientBase, Database):
if doc.doc_id is None:
raise errors.InvalidDocId()
params = {'old_rev': doc.rev}
- res, headers = self._request_json('DELETE',
- ['doc', doc.doc_id], params)
+ res, headers = self._request_json(
+ 'DELETE', ['doc', doc.doc_id], params)
doc.make_tombstone()
doc.rev = res['rev']
diff --git a/common/src/leap/soledad/common/l2db/remote/http_errors.py b/common/src/leap/soledad/common/l2db/remote/http_errors.py
index f6bd01d3..ee4cfefa 100644
--- a/common/src/leap/soledad/common/l2db/remote/http_errors.py
+++ b/common/src/leap/soledad/common/l2db/remote/http_errors.py
@@ -1,4 +1,5 @@
# Copyright 2011-2012 Canonical Ltd.
+# Copyright 2016 LEAP Encryption Access Project
#
# This file is part of u1db.
#
@@ -14,11 +15,11 @@
# You should have received a copy of the GNU Lesser General Public License
# along with u1db. If not, see <http://www.gnu.org/licenses/>.
-"""Information about the encoding of errors over HTTP."""
+"""
+Information about the encoding of errors over HTTP.
+"""
-from u1db import (
- errors,
- )
+from leap.soledad.common.l2db import errors
# error wire descriptions mapping to HTTP status codes
@@ -37,7 +38,7 @@ wire_description_to_status = dict([
(errors.InvalidReplicaUID.wire_description, 409),
(errors.InvalidTransactionId.wire_description, 409),
(errors.Unavailable.wire_description, 503),
-# without matching exception
+ # without matching exception
(errors.DOCUMENT_DELETED, 404)
])
diff --git a/common/src/leap/soledad/common/l2db/remote/http_target.py b/common/src/leap/soledad/common/l2db/remote/http_target.py
index 1028963e..598170e4 100644
--- a/common/src/leap/soledad/common/l2db/remote/http_target.py
+++ b/common/src/leap/soledad/common/l2db/remote/http_target.py
@@ -21,17 +21,10 @@ try:
except ImportError:
import json # noqa
-from u1db import (
- Document,
- SyncTarget,
- )
-from u1db.errors import (
- BrokenSyncStream,
- )
-from u1db.remote import (
- http_client,
- utils,
- )
+from leap.soledad.common.l2db import Document, SyncTarget
+from leap.soledad.common.l2db.errors import BrokenSyncStream
+from leap.soledad.common.l2db.remote import (
+ http_client, utils)
class HTTPSyncTarget(http_client.HTTPClientBase, SyncTarget):
diff --git a/common/src/leap/soledad/common/l2db/sync.py b/common/src/leap/soledad/common/l2db/sync.py
index d9e455d8..26e67140 100644
--- a/common/src/leap/soledad/common/l2db/sync.py
+++ b/common/src/leap/soledad/common/l2db/sync.py
@@ -17,8 +17,8 @@
"""The synchronization utilities for U1DB."""
from itertools import izip
-import u1db
-from u1db import errors
+from leap.soledad.common import l2db
+from leap.soledad.common.l2db import errors
class Synchronizer(object):
@@ -275,11 +275,10 @@ class SyncExchange(object):
# for tests
self._db._last_exchange_log['return'] = {
'docs': _outgoing_trace,
- 'last_gen': self.new_gen
- }
+ 'last_gen': self.new_gen}
-class LocalSyncTarget(u1db.SyncTarget):
+class LocalSyncTarget(l2db.SyncTarget):
"""Common sync target implementation logic for all local sync targets."""
def __init__(self, db):
diff --git a/common/src/leap/soledad/common/tests/server_state.py b/common/src/leap/soledad/common/tests/server_state.py
index 2fe9472f..26838f89 100644
--- a/common/src/leap/soledad/common/tests/server_state.py
+++ b/common/src/leap/soledad/common/tests/server_state.py
@@ -26,7 +26,7 @@ import errno
import tempfile
-from u1db.remote.server_state import ServerState
+from leap.soledad.common.l2db.remote.server_state import ServerState
from leap.soledad.common.tests.util import (
copy_sqlcipher_database_for_test,
)
diff --git a/common/src/leap/soledad/common/tests/test_async.py b/common/src/leap/soledad/common/tests/test_async.py
index 302ecc37..52be4ff3 100644
--- a/common/src/leap/soledad/common/tests/test_async.py
+++ b/common/src/leap/soledad/common/tests/test_async.py
@@ -14,8 +14,6 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
import os
import hashlib
diff --git a/common/src/leap/soledad/common/tests/test_couch.py b/common/src/leap/soledad/common/tests/test_couch.py
index 7ba50e11..eefefc5d 100644
--- a/common/src/leap/soledad/common/tests/test_couch.py
+++ b/common/src/leap/soledad/common/tests/test_couch.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# test_couch.py
-# Copyright (C) 2013 LEAP
+# Copyright (C) 2013-2016 LEAP
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -14,26 +14,23 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
"""
Test ObjectStore and Couch backend bits.
"""
-
-
import json
+from uuid import uuid4
from urlparse import urljoin
+
from couchdb.client import Server
-from uuid import uuid4
from testscenarios import TestWithScenarios
from twisted.trial import unittest
from mock import Mock
-from u1db import errors as u1db_errors
-from u1db import SyncTarget
-from u1db import vectorclock
+from leap.soledad.common.l2db import errors as u1db_errors
+from leap.soledad.common.l2db import SyncTarget
+from leap.soledad.common.l2db import vectorclock
from leap.soledad.common import couch
from leap.soledad.common.document import ServerDocument
diff --git a/common/src/leap/soledad/common/tests/test_http.py b/common/src/leap/soledad/common/tests/test_http.py
index bc486fe3..2351748d 100644
--- a/common/src/leap/soledad/common/tests/test_http.py
+++ b/common/src/leap/soledad/common/tests/test_http.py
@@ -17,10 +17,10 @@
"""
Test Leap backend bits: test http database
"""
-from u1db.remote import http_database
from leap.soledad.client import auth
from leap.soledad.common.tests.u1db_tests import test_http_database
+from leap.soledad.common.l2db.remote import http_database
# -----------------------------------------------------------------------------
diff --git a/common/src/leap/soledad/common/tests/test_http_client.py b/common/src/leap/soledad/common/tests/test_http_client.py
index 700ae3b6..d932b2b0 100644
--- a/common/src/leap/soledad/common/tests/test_http_client.py
+++ b/common/src/leap/soledad/common/tests/test_http_client.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# test_http_client.py
-# Copyright (C) 2013, 2014 LEAP
+# Copyright (C) 2013-2016 LEAP
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -19,11 +19,10 @@ Test Leap backend bits: sync target
"""
import json
-from u1db.remote import http_client
-
from testscenarios import TestWithScenarios
from leap.soledad.client import auth
+from leap.soledad.common.l2db.remote import http_client
from leap.soledad.common.tests.u1db_tests import test_http_client
from leap.soledad.server.auth import SoledadTokenAuthMiddleware
diff --git a/common/src/leap/soledad/common/tests/test_https.py b/common/src/leap/soledad/common/tests/test_https.py
index eeeb4982..8d9b8d92 100644
--- a/common/src/leap/soledad/common/tests/test_https.py
+++ b/common/src/leap/soledad/common/tests/test_https.py
@@ -14,19 +14,16 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
"""
Test Leap backend bits: https
"""
+from unittest import skip
-
-from u1db.remote import http_client
+from testscenarios import TestWithScenarios
from leap.soledad import client
-from testscenarios import TestWithScenarios
-
+from leap.soledad.common.l2db.remote import http_client
from leap.soledad.common.tests.u1db_tests import test_backends
from leap.soledad.common.tests.u1db_tests import test_https
from leap.soledad.common.tests.util import (
@@ -65,14 +62,16 @@ def token_leap_https_sync_target(test, host, path, cert_file=None):
return st
+@skip("Skiping tests imported from U1DB.")
class TestSoledadHTTPSyncTargetHttpsSupport(
TestWithScenarios,
- test_https.TestHttpSyncTargetHttpsSupport,
+ # test_https.TestHttpSyncTargetHttpsSupport,
BaseSoledadTest):
scenarios = [
('token_soledad_https',
- {'server_def': test_https.https_server_def,
+ {
+ #'server_def': test_https.https_server_def,
'make_app_with_state': make_token_soledad_app,
'make_document_for_test': make_soledad_document_for_test,
'sync_target': token_leap_https_sync_target}),
diff --git a/common/src/leap/soledad/common/tests/test_server.py b/common/src/leap/soledad/common/tests/test_server.py
index 2fee119d..357027e9 100644
--- a/common/src/leap/soledad/common/tests/test_server.py
+++ b/common/src/leap/soledad/common/tests/test_server.py
@@ -17,16 +17,17 @@
"""
Tests for server-related functionality.
"""
+import binascii
+import mock
import os
import tempfile
-import mock
import time
-import binascii
+
+from hashlib import sha512
from pkg_resources import resource_filename
+from urlparse import urljoin
from uuid import uuid4
-from hashlib import sha512
-from urlparse import urljoin
from twisted.internet import defer
from twisted.trial import unittest
diff --git a/common/src/leap/soledad/common/tests/test_soledad_app.py b/common/src/leap/soledad/common/tests/test_soledad_app.py
index 4598a7bb..7f9a58d3 100644
--- a/common/src/leap/soledad/common/tests/test_soledad_app.py
+++ b/common/src/leap/soledad/common/tests/test_soledad_app.py
@@ -14,13 +14,9 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
"""
Test ObjectStore and Couch backend bits.
"""
-
-
from testscenarios import TestWithScenarios
from leap.soledad.common.tests.util import BaseSoledadTest
diff --git a/common/src/leap/soledad/common/tests/test_sqlcipher.py b/common/src/leap/soledad/common/tests/test_sqlcipher.py
index 8105c56e..2bcdf0fb 100644
--- a/common/src/leap/soledad/common/tests/test_sqlcipher.py
+++ b/common/src/leap/soledad/common/tests/test_sqlcipher.py
@@ -26,10 +26,10 @@ import shutil
from pysqlcipher import dbapi2
from testscenarios import TestWithScenarios
-# u1db stuff.
-from u1db import errors
-from u1db import query_parser
-from u1db.backends.sqlite_backend import SQLitePartialExpandDatabase
+# l2db stuff.
+from leap.soledad.common.l2db import errors
+from leap.soledad.common.l2db import query_parser
+from leap.soledad.common.l2db.backends.sqlite_backend import SQLitePartialExpandDatabase
# soledad stuff.
from leap.soledad.common import soledad_assert
diff --git a/common/src/leap/soledad/common/tests/test_sqlcipher_sync.py b/common/src/leap/soledad/common/tests/test_sqlcipher_sync.py
index 439fc070..42cfa6b7 100644
--- a/common/src/leap/soledad/common/tests/test_sqlcipher_sync.py
+++ b/common/src/leap/soledad/common/tests/test_sqlcipher_sync.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# test_sqlcipher.py
-# Copyright (C) 2013 LEAP
+# Copyright (C) 2013-2016 LEAP
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,20 +17,19 @@
"""
Test sqlcipher backend sync.
"""
-
-
import os
-from u1db import sync
-from u1db import vectorclock
-from u1db import errors
from uuid import uuid4
from testscenarios import TestWithScenarios
+from leap.soledad.common.l2db import sync
+from leap.soledad.common.l2db import vectorclock
+from leap.soledad.common.l2db import errors
+
from leap.soledad.common.crypto import ENC_SCHEME_KEY
-from leap.soledad.client.http_target import SoledadHTTPSyncTarget
from leap.soledad.client.crypto import decrypt_doc_dict
+from leap.soledad.client.http_target import SoledadHTTPSyncTarget
from leap.soledad.common.tests import u1db_tests as tests
from leap.soledad.common.tests.test_sqlcipher import SQLCIPHER_SCENARIOS
diff --git a/common/src/leap/soledad/common/tests/test_sync.py b/common/src/leap/soledad/common/tests/test_sync.py
index 1041367b..cc18d387 100644
--- a/common/src/leap/soledad/common/tests/test_sync.py
+++ b/common/src/leap/soledad/common/tests/test_sync.py
@@ -14,8 +14,6 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
import json
import tempfile
import threading
diff --git a/common/src/leap/soledad/common/tests/test_sync_target.py b/common/src/leap/soledad/common/tests/test_sync_target.py
index f25e84dd..c9b705a3 100644
--- a/common/src/leap/soledad/common/tests/test_sync_target.py
+++ b/common/src/leap/soledad/common/tests/test_sync_target.py
@@ -21,7 +21,6 @@ import cStringIO
import os
import time
import json
-import u1db
import random
import string
import shutil
@@ -36,8 +35,9 @@ from leap.soledad.client.sqlcipher import SQLCipherU1DBSync
from leap.soledad.client.sqlcipher import SQLCipherOptions
from leap.soledad.client.sqlcipher import SQLCipherDatabase
-from leap.soledad.common.document import SoledadDocument
+from leap.soledad.common import l2db
+from leap.soledad.common.document import SoledadDocument
from leap.soledad.common.tests import u1db_tests as tests
from leap.soledad.common.tests.util import make_sqlcipher_database_for_test
from leap.soledad.common.tests.util import make_soledad_app
@@ -90,53 +90,53 @@ class TestSoledadParseReceivedDocResponse(SoledadWithCouchServerMixin):
doc.get_json(), doc.doc_id, doc.rev,
key, secret)
- with self.assertRaises(u1db.errors.BrokenSyncStream):
+ with self.assertRaises(l2db.errors.BrokenSyncStream):
self.target._parse_received_doc_response("[\r\n{},\r\n]")
- with self.assertRaises(u1db.errors.BrokenSyncStream):
+ with self.assertRaises(l2db.errors.BrokenSyncStream):
self.target._parse_received_doc_response(
('[\r\n{},\r\n{"id": "i", "rev": "r", ' +
'"content": %s, "gen": 3, "trans_id": "T-sid"}' +
',\r\n]') % json.dumps(enc_json))
def test_wrong_start(self):
- with self.assertRaises(u1db.errors.BrokenSyncStream):
+ with self.assertRaises(l2db.errors.BrokenSyncStream):
self.target._parse_received_doc_response("{}\r\n]")
- with self.assertRaises(u1db.errors.BrokenSyncStream):
+ with self.assertRaises(l2db.errors.BrokenSyncStream):
self.target._parse_received_doc_response("\r\n{}\r\n]")
- with self.assertRaises(u1db.errors.BrokenSyncStream):
+ with self.assertRaises(l2db.errors.BrokenSyncStream):
self.target._parse_received_doc_response("")
def test_wrong_end(self):
- with self.assertRaises(u1db.errors.BrokenSyncStream):
+ with self.assertRaises(l2db.errors.BrokenSyncStream):
self.target._parse_received_doc_response("[\r\n{}")
- with self.assertRaises(u1db.errors.BrokenSyncStream):
+ with self.assertRaises(l2db.errors.BrokenSyncStream):
self.target._parse_received_doc_response("[\r\n")
def test_missing_comma(self):
- with self.assertRaises(u1db.errors.BrokenSyncStream):
+ with self.assertRaises(l2db.errors.BrokenSyncStream):
self.target._parse_received_doc_response(
'[\r\n{}\r\n{"id": "i", "rev": "r", '
'"content": "c", "gen": 3}\r\n]')
def test_no_entries(self):
- with self.assertRaises(u1db.errors.BrokenSyncStream):
+ with self.assertRaises(l2db.errors.BrokenSyncStream):
self.target._parse_received_doc_response("[\r\n]")
def test_error_in_stream(self):
- with self.assertRaises(u1db.errors.BrokenSyncStream):
+ with self.assertRaises(l2db.errors.BrokenSyncStream):
self.target._parse_received_doc_response(
'[\r\n{"new_generation": 0},'
'\r\n{"error": "unavailable"}\r\n')
- with self.assertRaises(u1db.errors.BrokenSyncStream):
+ with self.assertRaises(l2db.errors.BrokenSyncStream):
self.target._parse_received_doc_response(
'[\r\n{"error": "unavailable"}\r\n')
- with self.assertRaises(u1db.errors.BrokenSyncStream):
+ with self.assertRaises(l2db.errors.BrokenSyncStream):
self.target._parse_received_doc_response('[\r\n{"error": "?"}\r\n')
#
@@ -256,7 +256,7 @@ class TestSoledadSyncTarget(
replica_trans_id=None, number_of_docs=None,
doc_idx=None, sync_id=None):
if doc.doc_id in trigger_ids:
- raise u1db.errors.U1DBError
+ raise l2db.errors.U1DBError
return _put_doc_if_newer(doc, save_conflict=save_conflict,
replica_uid=replica_uid,
replica_gen=replica_gen,
@@ -278,7 +278,7 @@ class TestSoledadSyncTarget(
doc2 = self.make_document('doc-here2', 'replica:1',
'{"value": "here2"}')
- with self.assertRaises(u1db.errors.U1DBError):
+ with self.assertRaises(l2db.errors.U1DBError):
yield remote_target.sync_exchange(
[(doc1, 10, 'T-sid'), (doc2, 11, 'T-sud')],
'replica',
@@ -706,7 +706,7 @@ class SoledadDatabaseSyncTargetTests(
def before_get_docs_explode(state):
if state != 'before get_docs':
return
- raise u1db.errors.U1DBError("fail")
+ raise l2db.errors.U1DBError("fail")
self.set_trace_hook(before_get_docs_explode)
# suppress traceback printing in the wsgiref server
# self.patch(simple_server.ServerHandler,
@@ -714,7 +714,7 @@ class SoledadDatabaseSyncTargetTests(
doc = self.db.create_doc_from_json(tests.simple_doc)
self.assertTransactionLog([doc.doc_id], self.db)
self.assertRaises(
- (u1db.errors.U1DBError, u1db.errors.BrokenSyncStream),
+ (l2db.errors.U1DBError, l2db.errors.BrokenSyncStream),
self.st.sync_exchange, [], 'other-replica',
last_known_generation=0, last_known_trans_id=None,
insert_doc_cb=self.receive_doc)
diff --git a/common/src/leap/soledad/common/tests/u1db_tests/__init__.py b/common/src/leap/soledad/common/tests/u1db_tests/__init__.py
index 01da9381..7f334b4a 100644
--- a/common/src/leap/soledad/common/tests/u1db_tests/__init__.py
+++ b/common/src/leap/soledad/common/tests/u1db_tests/__init__.py
@@ -36,13 +36,13 @@ from twisted.web.server import Site
from twisted.web.wsgi import WSGIResource
from twisted.internet import reactor
-from u1db import errors
-from u1db import Document
-from u1db.backends import inmemory
-from u1db.backends import sqlite_backend
-from u1db.remote import server_state
-from u1db.remote import http_app
-from u1db.remote import http_target
+from leap.soledad.common.l2db import errors
+from leap.soledad.common.l2db import Document
+from leap.soledad.common.l2db.backends import inmemory
+from leap.soledad.common.l2db.backends import sqlite_backend
+from leap.soledad.common.l2db.remote import server_state
+from leap.soledad.common.l2db.remote import http_app
+from leap.soledad.common.l2db.remote import http_target
class TestCase(unittest.TestCase):
diff --git a/common/src/leap/soledad/common/tests/u1db_tests/test_backends.py b/common/src/leap/soledad/common/tests/u1db_tests/test_backends.py
index 410d838f..c0c6ea6b 100644
--- a/common/src/leap/soledad/common/tests/u1db_tests/test_backends.py
+++ b/common/src/leap/soledad/common/tests/u1db_tests/test_backends.py
@@ -1,8 +1,9 @@
# Copyright 2011 Canonical Ltd.
+# Copyright 2016 LEAP Encryption Access Project
#
-# This file is part of u1db.
+# This file is part of leap.soledad.common
#
-# u1db is free software: you can redistribute it and/or modify
+# leap.soledad.common is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
@@ -14,21 +15,21 @@
# You should have received a copy of the GNU Lesser General Public License
# along with u1db. If not, see <http://www.gnu.org/licenses/>.
-"""The backend class for U1DB. This deals with hiding storage details."""
+"""
+The backend class for L2DB. This deals with hiding storage details.
+"""
import json
-from u1db import DocumentBase
-from u1db import errors
-from u1db import vectorclock
+from leap.soledad.common.l2db import DocumentBase
+from leap.soledad.common.l2db import errors
+from leap.soledad.common.l2db import vectorclock
+from leap.soledad.common.l2db.remote import http_database
from leap.soledad.common.tests import u1db_tests as tests
-
from leap.soledad.common.tests.u1db_tests import make_http_app
from leap.soledad.common.tests.u1db_tests import make_oauth_http_app
-from u1db.remote import http_database
-
from unittest import skip
simple_doc = tests.simple_doc
diff --git a/common/src/leap/soledad/common/tests/u1db_tests/test_document.py b/common/src/leap/soledad/common/tests/u1db_tests/test_document.py
index 23502b4b..4e8bcaf9 100644
--- a/common/src/leap/soledad/common/tests/u1db_tests/test_document.py
+++ b/common/src/leap/soledad/common/tests/u1db_tests/test_document.py
@@ -1,8 +1,9 @@
# Copyright 2011 Canonical Ltd.
+# Copyright 2016 LEAP Encryption Access Project
#
-# This file is part of u1db.
+# This file is part of leap.soledad.common
#
-# u1db is free software: you can redistribute it and/or modify
+# leap.soledad.common is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
@@ -13,10 +14,9 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with u1db. If not, see <http://www.gnu.org/licenses/>.
-
-
from unittest import skip
-from u1db import errors
+
+from leap.soledad.common.l2db import errors
from leap.soledad.common.tests import u1db_tests as tests
diff --git a/common/src/leap/soledad/common/tests/u1db_tests/test_http_client.py b/common/src/leap/soledad/common/tests/u1db_tests/test_http_client.py
index 973c3b26..344dcb29 100644
--- a/common/src/leap/soledad/common/tests/u1db_tests/test_http_client.py
+++ b/common/src/leap/soledad/common/tests/u1db_tests/test_http_client.py
@@ -1,4 +1,5 @@
# Copyright 2011-2012 Canonical Ltd.
+# Copyright 2016 LEAP Encryption Access Project
#
# This file is part of u1db.
#
@@ -14,22 +15,17 @@
# You should have received a copy of the GNU Lesser General Public License
# along with u1db. If not, see <http://www.gnu.org/licenses/>.
-"""Tests for HTTPDatabase"""
-
-from oauth import oauth
+"""
+Tests for HTTPDatabase
+"""
import json
-from u1db import (
- errors,
-)
-
from unittest import skip
-from leap.soledad.common.tests import u1db_tests as tests
+from leap.soledad.common.l2db import errors
+from leap.soledad.common.l2db.remote import http_client
-from u1db.remote import (
- http_client,
-)
+from leap.soledad.common.tests import u1db_tests as tests
@skip("Skiping tests imported from U1DB.")
diff --git a/common/src/leap/soledad/common/tests/u1db_tests/test_http_database.py b/common/src/leap/soledad/common/tests/u1db_tests/test_http_database.py
index 015e6e69..001aebd4 100644
--- a/common/src/leap/soledad/common/tests/u1db_tests/test_http_database.py
+++ b/common/src/leap/soledad/common/tests/u1db_tests/test_http_database.py
@@ -21,11 +21,10 @@ import json
from unittest import skip
-from u1db import errors
-from u1db import Document
-from u1db.remote import http_database
-from u1db.remote import http_target
-
+from leap.soledad.common.l2db import errors
+from leap.soledad.common.l2db import Document
+from leap.soledad.common.l2db.remote import http_database
+from leap.soledad.common.l2db.remote import http_target
from leap.soledad.common.tests import u1db_tests as tests
from leap.soledad.common.tests.u1db_tests import make_http_app
diff --git a/common/src/leap/soledad/common/tests/u1db_tests/test_https.py b/common/src/leap/soledad/common/tests/u1db_tests/test_https.py
index e177a808..8a5743e7 100644
--- a/common/src/leap/soledad/common/tests/u1db_tests/test_https.py
+++ b/common/src/leap/soledad/common/tests/u1db_tests/test_https.py
@@ -4,119 +4,111 @@ import os
import ssl
import sys
-from paste import httpserver
+#from paste import httpserver
from unittest import skip
-from u1db.remote import http_client
-from u1db.remote import http_target
+from leap.soledad.common.l2db.remote import http_client
+#from leap.soledad.common.l2db.remote import http_target
from leap import soledad
from leap.soledad.common.tests import u1db_tests as tests
from leap.soledad.common.tests.u1db_tests import make_oauth_http_app
-def https_server_def():
- def make_server(host_port, application):
- from OpenSSL import SSL
- cert_file = os.path.join(os.path.dirname(__file__), 'testing-certs',
- 'testing.cert')
- key_file = os.path.join(os.path.dirname(__file__), 'testing-certs',
- 'testing.key')
- ssl_context = SSL.Context(SSL.SSLv23_METHOD)
- ssl_context.use_privatekey_file(key_file)
- ssl_context.use_certificate_chain_file(cert_file)
- srv = httpserver.WSGIServerBase(application, host_port,
- httpserver.WSGIHandler,
- ssl_context=ssl_context
- )
-
- def shutdown_request(req):
- req.shutdown()
- srv.close_request(req)
-
- srv.shutdown_request = shutdown_request
- application.base_url = "https://localhost:%s" % srv.server_address[1]
- return srv
- return make_server, "shutdown", "https"
-
-
-def oauth_https_sync_target(test, host, path):
- _, port = test.server.server_address
- st = http_target.HTTPSyncTarget('https://%s:%d/~/%s' % (host, port, path))
- st.set_oauth_credentials(tests.consumer1.key, tests.consumer1.secret,
- tests.token1.key, tests.token1.secret)
- return st
-
-
-@skip("Skiping tests imported from U1DB.")
-class TestHttpSyncTargetHttpsSupport(tests.TestCaseWithServer):
-
- scenarios = [
- ('oauth_https', {'server_def': https_server_def,
- 'make_app_with_state': make_oauth_http_app,
- 'make_document_for_test':
- tests.make_document_for_test,
- 'sync_target': oauth_https_sync_target
- }),
- ]
-
- def setUp(self):
- try:
- import OpenSSL # noqa
- except ImportError:
- self.skipTest("Requires pyOpenSSL")
- self.cacert_pem = os.path.join(os.path.dirname(__file__),
- 'testing-certs', 'cacert.pem')
+#def https_server_def():
+ #def make_server(host_port, application):
+ #from OpenSSL import SSL
+ #cert_file = os.path.join(os.path.dirname(__file__), 'testing-certs',
+ #'testing.cert')
+ #key_file = os.path.join(os.path.dirname(__file__), 'testing-certs',
+ #'testing.key')
+ #ssl_context = SSL.Context(SSL.SSLv23_METHOD)
+ #ssl_context.use_privatekey_file(key_file)
+ #ssl_context.use_certificate_chain_file(cert_file)
+ #srv = httpserver.WSGIServerBase(application, host_port,
+ #httpserver.WSGIHandler,
+ #ssl_context=ssl_context
+ #)
+#
+ #def shutdown_request(req):
+ #req.shutdown()
+ #srv.close_request(req)
+#
+ #srv.shutdown_request = shutdown_request
+ #application.base_url = "https://localhost:%s" % srv.server_address[1]
+ #return srv
+ #return make_server, "shutdown", "https"
+
+
+#@skip("Skiping tests imported from U1DB.")
+#class TestHttpSyncTargetHttpsSupport(tests.TestCaseWithServer):
+#
+ #scenarios = [
+ #('oauth_https', {'server_def': https_server_def,
+ #'make_app_with_state': make_oauth_http_app,
+ #'make_document_for_test':
+ #tests.make_document_for_test,
+ #'sync_target': oauth_https_sync_target
+ #}),
+ #]
+#
+ #def setUp(self):
+ #try:
+ #import OpenSSL # noqa
+ #except ImportError:
+ #self.skipTest("Requires pyOpenSSL")
+ #self.cacert_pem = os.path.join(os.path.dirname(__file__),
+ #'testing-certs', 'cacert.pem')
# The default u1db http_client class for doing HTTPS only does HTTPS
# if the platform is linux. Because of this, soledad replaces that
# class with one that will do HTTPS independent of the platform. In
# order to maintain the compatibility with u1db default tests, we undo
# that replacement here.
- http_client._VerifiedHTTPSConnection = \
- soledad.client.api.old__VerifiedHTTPSConnection
- super(TestHttpSyncTargetHttpsSupport, self).setUp()
-
- def getSyncTarget(self, host, path=None, cert_file=None):
- if self.server is None:
- self.startServer()
- return self.sync_target(self, host, path, cert_file=cert_file)
-
- def test_working(self):
- self.startServer()
- db = self.request_state._create_database('test')
- self.patch(http_client, 'CA_CERTS', self.cacert_pem)
- remote_target = self.getSyncTarget('localhost', 'test')
- remote_target.record_sync_info('other-id', 2, 'T-id')
- self.assertEqual(
- (2, 'T-id'), db._get_replica_gen_and_trans_id('other-id'))
-
- def test_cannot_verify_cert(self):
- if not sys.platform.startswith('linux'):
- self.skipTest(
- "XXX certificate verification happens on linux only for now")
- self.startServer()
+ #http_client._VerifiedHTTPSConnection = \
+ #soledad.client.api.old__VerifiedHTTPSConnection
+ #super(TestHttpSyncTargetHttpsSupport, self).setUp()
+#
+ #def getSyncTarget(self, host, path=None, cert_file=None):
+ #if self.server is None:
+ #self.startServer()
+ #return self.sync_target(self, host, path, cert_file=cert_file)
+#
+ #def test_working(self):
+ #self.startServer()
+ #db = self.request_state._create_database('test')
+ #self.patch(http_client, 'CA_CERTS', self.cacert_pem)
+ #remote_target = self.getSyncTarget('localhost', 'test')
+ #remote_target.record_sync_info('other-id', 2, 'T-id')
+ #self.assertEqual(
+ #(2, 'T-id'), db._get_replica_gen_and_trans_id('other-id'))
+#
+ #def test_cannot_verify_cert(self):
+ #if not sys.platform.startswith('linux'):
+ #self.skipTest(
+ #"XXX certificate verification happens on linux only for now")
+ #self.startServer()
# don't print expected traceback server-side
- self.server.handle_error = lambda req, cli_addr: None
- self.request_state._create_database('test')
- remote_target = self.getSyncTarget('localhost', 'test')
- try:
- remote_target.record_sync_info('other-id', 2, 'T-id')
- except ssl.SSLError, e:
- self.assertIn("certificate verify failed", str(e))
- else:
- self.fail("certificate verification should have failed.")
-
- def test_host_mismatch(self):
- if not sys.platform.startswith('linux'):
- self.skipTest(
- "XXX certificate verification happens on linux only for now")
- self.startServer()
- self.request_state._create_database('test')
- self.patch(http_client, 'CA_CERTS', self.cacert_pem)
- remote_target = self.getSyncTarget('127.0.0.1', 'test')
- self.assertRaises(
- http_client.CertificateError, remote_target.record_sync_info,
- 'other-id', 2, 'T-id')
-
-
-load_tests = tests.load_with_scenarios
+ #self.server.handle_error = lambda req, cli_addr: None
+ #self.request_state._create_database('test')
+ #remote_target = self.getSyncTarget('localhost', 'test')
+ #try:
+ #remote_target.record_sync_info('other-id', 2, 'T-id')
+ #except ssl.SSLError, e:
+ #self.assertIn("certificate verify failed", str(e))
+ #else:
+ #self.fail("certificate verification should have failed.")
+#
+ #def test_host_mismatch(self):
+ #if not sys.platform.startswith('linux'):
+ #self.skipTest(
+ #"XXX certificate verification happens on linux only for now")
+ #self.startServer()
+ #self.request_state._create_database('test')
+ #self.patch(http_client, 'CA_CERTS', self.cacert_pem)
+ #remote_target = self.getSyncTarget('127.0.0.1', 'test')
+ #self.assertRaises(
+ #http_client.CertificateError, remote_target.record_sync_info,
+ #'other-id', 2, 'T-id')
+#
+#
+#load_tests = tests.load_with_scenarios
diff --git a/common/src/leap/soledad/common/tests/u1db_tests/test_open.py b/common/src/leap/soledad/common/tests/u1db_tests/test_open.py
index ee249e6e..2fc04e38 100644
--- a/common/src/leap/soledad/common/tests/u1db_tests/test_open.py
+++ b/common/src/leap/soledad/common/tests/u1db_tests/test_open.py
@@ -1,4 +1,5 @@
# Copyright 2011 Canonical Ltd.
+# Copyright 2016 LEAP Encryption Access Project
#
# This file is part of u1db.
#
@@ -17,14 +18,13 @@
"""Test u1db.open"""
import os
+from unittest import skip
-from u1db import (
- errors,
- open as u1db_open,
+from leap.soledad.common.l2db import (
+ errors, open as u1db_open,
)
-from unittest import skip
from leap.soledad.common.tests import u1db_tests as tests
-from u1db.backends import sqlite_backend
+from leap.soledad.common.l2db.backends import sqlite_backend
from leap.soledad.common.tests.u1db_tests.test_backends \
import TestAlternativeDocument
diff --git a/common/src/leap/soledad/common/tests/util.py b/common/src/leap/soledad/common/tests/util.py
index c681fa93..abe531ce 100644
--- a/common/src/leap/soledad/common/tests/util.py
+++ b/common/src/leap/soledad/common/tests/util.py
@@ -26,7 +26,6 @@ import tempfile
import shutil
import random
import string
-import u1db
import couchdb
from uuid import uuid4
@@ -35,13 +34,14 @@ from urlparse import urljoin
from StringIO import StringIO
from pysqlcipher import dbapi2
-from u1db import sync
-from u1db.remote import http_database
-
from twisted.trial import unittest
from leap.common.testing.basetest import BaseLeapTest
+from leap.soledad.common import l2db
+from leap.soledad.common.l2db import sync
+from leap.soledad.common.l2db.remote import http_database
+
from leap.soledad.common import soledad_assert
from leap.soledad.common.document import SoledadDocument
from leap.soledad.common.couch import CouchDatabase
@@ -234,9 +234,9 @@ class BaseSoledadTest(BaseLeapTest, MockedSharedDBTest):
self.db2_file = os.path.join(self.tempdir, "db2.u1db")
self.email = ADDRESS
# open test dbs
- self._db1 = u1db.open(self.db1_file, create=True,
+ self._db1 = l2db.open(self.db1_file, create=True,
document_factory=SoledadDocument)
- self._db2 = u1db.open(self.db2_file, create=True,
+ self._db2 = l2db.open(self.db2_file, create=True,
document_factory=SoledadDocument)
# get a random prefix for each test, so we do not mess with
# concurrency during initialization and shutting down of