From d5d47dc216fd285ec60df1ccaab1e0740e29e3c5 Mon Sep 17 00:00:00 2001 From: drebs Date: Mon, 18 Nov 2013 11:06:37 -0200 Subject: Add MAC verification to recovery document. Closes #4348. --- common/src/leap/soledad/common/crypto.py | 21 +++++++++++++++++++++ common/src/leap/soledad/common/tests/test_crypto.py | 9 ++++----- .../src/leap/soledad/common/tests/test_soledad.py | 5 +++-- 3 files changed, 28 insertions(+), 7 deletions(-) (limited to 'common') diff --git a/common/src/leap/soledad/common/crypto.py b/common/src/leap/soledad/common/crypto.py index 2c6bd7a3..56bb608a 100644 --- a/common/src/leap/soledad/common/crypto.py +++ b/common/src/leap/soledad/common/crypto.py @@ -35,6 +35,13 @@ class EncryptionSchemes(object): PUBKEY = 'pubkey' +class UnknownEncryptionScheme(Exception): + """ + Raised when trying to decrypt from unknown encryption schemes. + """ + pass + + class MacMethods(object): """ Representation of MAC methods used to authenticate document's contents. @@ -43,6 +50,20 @@ class MacMethods(object): HMAC = 'hmac' +class UnknownMacMethod(Exception): + """ + Raised when trying to authenticate document's content with unknown MAC + mehtod. + """ + pass + + +class WrongMac(Exception): + """ + Raised when failing to authenticate document's contents based on MAC. + """ + + # # Crypto utilities for a SoledadDocument. # diff --git a/common/src/leap/soledad/common/tests/test_crypto.py b/common/src/leap/soledad/common/tests/test_crypto.py index db217bb3..af11bc76 100644 --- a/common/src/leap/soledad/common/tests/test_crypto.py +++ b/common/src/leap/soledad/common/tests/test_crypto.py @@ -40,6 +40,7 @@ from leap.soledad.common.tests import ( KEY_FINGERPRINT, PRIVATE_KEY, ) +from leap.soledad.common.crypto import WrongMac, UnknownMacMethod from leap.soledad.common.tests.u1db_tests import ( simple_doc, nested_doc, @@ -88,11 +89,9 @@ class RecoveryDocumentTestCase(BaseSoledadTest): def test_import_recovery_document(self): rd = self._soledad.export_recovery_document() - s = self._soledad_instance(user='anotheruser@leap.se') + s = self._soledad_instance() s.import_recovery_document(rd) s._set_secret_id(self._soledad._secret_id) - self.assertEqual(self._soledad._uuid, - s._uuid, 'Failed setting user uuid.') self.assertEqual(self._soledad._get_storage_secret(), s._get_storage_secret(), 'Failed settinng secret for symmetric encryption.') @@ -164,7 +163,7 @@ class MacAuthTestCase(BaseSoledadTest): doc.content[target.MAC_KEY] = '1234567890ABCDEF' # try to decrypt doc self.assertRaises( - target.WrongMac, + WrongMac, target.decrypt_doc, self._soledad._crypto, doc) def test_decrypt_with_unknown_mac_method_raises(self): @@ -182,7 +181,7 @@ class MacAuthTestCase(BaseSoledadTest): doc.content[target.MAC_METHOD_KEY] = 'mymac' # try to decrypt doc self.assertRaises( - target.UnknownMacMethod, + UnknownMacMethod, target.decrypt_doc, self._soledad._crypto, doc) diff --git a/common/src/leap/soledad/common/tests/test_soledad.py b/common/src/leap/soledad/common/tests/test_soledad.py index 8970a437..035c5ac5 100644 --- a/common/src/leap/soledad/common/tests/test_soledad.py +++ b/common/src/leap/soledad/common/tests/test_soledad.py @@ -33,6 +33,7 @@ from leap.soledad.common.tests import ( ) from leap import soledad from leap.soledad.common.document import SoledadDocument +from leap.soledad.common.crypto import WrongMac from leap.soledad.client import Soledad, PassphraseTooShort from leap.soledad.client.crypto import SoledadCrypto from leap.soledad.client.shared_db import SoledadSharedDatabase @@ -119,7 +120,7 @@ class AuxMethodsTestCase(BaseSoledadTest): sol.change_passphrase(u'654321') self.assertRaises( - DatabaseError, + WrongMac, self._soledad_instance, 'leap@leap.se', passphrase=u'123', prefix=self.rand_prefix) @@ -292,7 +293,7 @@ class SoledadSignalingTestCase(BaseSoledadTest): sol = self._soledad_instance() # create a document with secrets doc = SoledadDocument(doc_id=sol._shared_db_doc_id()) - doc.content = sol.export_recovery_document(include_uuid=False) + doc.content = sol.export_recovery_document() class Stage2MockSharedDB(object): -- cgit v1.2.3 From 75bc8c2220aa636a2c63fa0d151f271c22920040 Mon Sep 17 00:00:00 2001 From: drebs Date: Thu, 21 Nov 2013 09:49:05 -0200 Subject: Add unicode conversion to put_doc. Closes #4095. --- common/changes/bug_4095_add-unicode-conversion-to-put_doc | 1 + 1 file changed, 1 insertion(+) create mode 100644 common/changes/bug_4095_add-unicode-conversion-to-put_doc (limited to 'common') diff --git a/common/changes/bug_4095_add-unicode-conversion-to-put_doc b/common/changes/bug_4095_add-unicode-conversion-to-put_doc new file mode 100644 index 00000000..bed446ac --- /dev/null +++ b/common/changes/bug_4095_add-unicode-conversion-to-put_doc @@ -0,0 +1 @@ + o Add unicode conversion to put_doc(). Closes #4095. -- cgit v1.2.3 From 61fe6b1ed3f8a42eb22e12168c88212e55b9095e Mon Sep 17 00:00:00 2001 From: drebs Date: Thu, 21 Nov 2013 19:27:06 -0200 Subject: Remove tests dependency on nose2. Closes #4258. --- common/changes/bug_4258_remove-dependency-on-nose2 | 1 + common/pkg/requirements-testing.pip | 5 ----- common/src/leap/soledad/common/tests/u1db_tests/README | 8 -------- 3 files changed, 1 insertion(+), 13 deletions(-) create mode 100644 common/changes/bug_4258_remove-dependency-on-nose2 (limited to 'common') diff --git a/common/changes/bug_4258_remove-dependency-on-nose2 b/common/changes/bug_4258_remove-dependency-on-nose2 new file mode 100644 index 00000000..d83fc49c --- /dev/null +++ b/common/changes/bug_4258_remove-dependency-on-nose2 @@ -0,0 +1 @@ + o Remove tests dependency on nose2. Closes #4258. diff --git a/common/pkg/requirements-testing.pip b/common/pkg/requirements-testing.pip index 6ff52ff9..9302450c 100644 --- a/common/pkg/requirements-testing.pip +++ b/common/pkg/requirements-testing.pip @@ -1,10 +1,5 @@ mock -nose2 testscenarios leap.common leap.soledad.server leap.soledad.client - -# Under quarantine... -# I've been able to run all tests with six==1.3 -- kali -# six==1.1.0 # some tests are incompatible with newer versions of six. diff --git a/common/src/leap/soledad/common/tests/u1db_tests/README b/common/src/leap/soledad/common/tests/u1db_tests/README index 605f01fa..d543f250 100644 --- a/common/src/leap/soledad/common/tests/u1db_tests/README +++ b/common/src/leap/soledad/common/tests/u1db_tests/README @@ -12,7 +12,6 @@ Dependencies u1db tests depend on the following python packages: - nose2 unittest2 mercurial hgtools @@ -25,10 +24,3 @@ u1db tests depend on the following python packages: routes simplejson cython - -Running tests -------------- - -Use nose2 to run tests: - - nose2 leap.soledad.tests.u1db_tests -- cgit v1.2.3 From 6792e50606e33f10c12f16b0d7d7aeb87d4a4adb Mon Sep 17 00:00:00 2001 From: drebs Date: Wed, 4 Dec 2013 17:40:55 -0200 Subject: Encode U1DB metadata doc prefix. Closes #4658. --- common/changes/bug_4658_encode-u1db-metadata-doc-prefix | 1 + common/src/leap/soledad/common/objectstore.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 common/changes/bug_4658_encode-u1db-metadata-doc-prefix (limited to 'common') diff --git a/common/changes/bug_4658_encode-u1db-metadata-doc-prefix b/common/changes/bug_4658_encode-u1db-metadata-doc-prefix new file mode 100644 index 00000000..17013f6b --- /dev/null +++ b/common/changes/bug_4658_encode-u1db-metadata-doc-prefix @@ -0,0 +1 @@ + o Encode U1DB metadata doc prefix. Closes #4658. diff --git a/common/src/leap/soledad/common/objectstore.py b/common/src/leap/soledad/common/objectstore.py index 7aff3e32..9f477a8d 100644 --- a/common/src/leap/soledad/common/objectstore.py +++ b/common/src/leap/soledad/common/objectstore.py @@ -50,7 +50,7 @@ class ObjectStoreDatabase(InMemoryDatabase): A backend for storing u1db data in an object store. """ - U1DB_DATA_DOC_ID_PREFIX = 'u1db/' + U1DB_DATA_DOC_ID_PREFIX = 'u1db%2F' @classmethod def open_database(cls, url, create, document_factory=None): -- cgit v1.2.3 From 8807335119d43c24f5d18c9fa69ad0f9f6e458f2 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Thu, 5 Dec 2013 10:11:23 -0400 Subject: add venwrapper script for tests --- common/pkg/tools/with_venvwrapper.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 common/pkg/tools/with_venvwrapper.sh (limited to 'common') diff --git a/common/pkg/tools/with_venvwrapper.sh b/common/pkg/tools/with_venvwrapper.sh new file mode 100755 index 00000000..b62bc10f --- /dev/null +++ b/common/pkg/tools/with_venvwrapper.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +#Wraps a command in a virtualenwrapper passed as first argument. +#Example: +#with_virtualenvwrapper.sh leap-bitmask ./run_tests.sh + +wd=`pwd` +alias pyver='python -c "import $1;print $1.__path__[0]; print $1.__version__;"' + +source `which virtualenvwrapper.sh` +echo "Activating virtualenv " $1 +echo "------------------------------------" +workon $1 +cd $wd +echo "running version: " +echo `pyver leap.bitmask` +echo `pyver leap.soledad.common` +echo `pyver leap.keymanager` +$2 $3 $4 $5 -- cgit v1.2.3 From f8bba9c2c2031941955340d48636bf769e99d146 Mon Sep 17 00:00:00 2001 From: drebs Date: Thu, 5 Dec 2013 15:48:48 -0200 Subject: Revert "Encode U1DB metadata doc prefix. Closes #4658." This reverts commit 6792e50606e33f10c12f16b0d7d7aeb87d4a4adb. --- common/changes/bug_4658_encode-u1db-metadata-doc-prefix | 1 - common/src/leap/soledad/common/objectstore.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 common/changes/bug_4658_encode-u1db-metadata-doc-prefix (limited to 'common') diff --git a/common/changes/bug_4658_encode-u1db-metadata-doc-prefix b/common/changes/bug_4658_encode-u1db-metadata-doc-prefix deleted file mode 100644 index 17013f6b..00000000 --- a/common/changes/bug_4658_encode-u1db-metadata-doc-prefix +++ /dev/null @@ -1 +0,0 @@ - o Encode U1DB metadata doc prefix. Closes #4658. diff --git a/common/src/leap/soledad/common/objectstore.py b/common/src/leap/soledad/common/objectstore.py index 9f477a8d..7aff3e32 100644 --- a/common/src/leap/soledad/common/objectstore.py +++ b/common/src/leap/soledad/common/objectstore.py @@ -50,7 +50,7 @@ class ObjectStoreDatabase(InMemoryDatabase): A backend for storing u1db data in an object store. """ - U1DB_DATA_DOC_ID_PREFIX = 'u1db%2F' + U1DB_DATA_DOC_ID_PREFIX = 'u1db/' @classmethod def open_database(cls, url, create, document_factory=None): -- cgit v1.2.3 From 5f2a29120ba2d22d7d2406628ce2f6735b60d09c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Fri, 6 Dec 2013 15:42:59 -0300 Subject: Fold in changes --- common/changes/VERSION_COMPAT | 0 common/changes/bug_4095_add-unicode-conversion-to-put_doc | 1 - common/changes/bug_4258_remove-dependency-on-nose2 | 1 - 3 files changed, 2 deletions(-) create mode 100644 common/changes/VERSION_COMPAT delete mode 100644 common/changes/bug_4095_add-unicode-conversion-to-put_doc delete mode 100644 common/changes/bug_4258_remove-dependency-on-nose2 (limited to 'common') diff --git a/common/changes/VERSION_COMPAT b/common/changes/VERSION_COMPAT new file mode 100644 index 00000000..e69de29b diff --git a/common/changes/bug_4095_add-unicode-conversion-to-put_doc b/common/changes/bug_4095_add-unicode-conversion-to-put_doc deleted file mode 100644 index bed446ac..00000000 --- a/common/changes/bug_4095_add-unicode-conversion-to-put_doc +++ /dev/null @@ -1 +0,0 @@ - o Add unicode conversion to put_doc(). Closes #4095. diff --git a/common/changes/bug_4258_remove-dependency-on-nose2 b/common/changes/bug_4258_remove-dependency-on-nose2 deleted file mode 100644 index d83fc49c..00000000 --- a/common/changes/bug_4258_remove-dependency-on-nose2 +++ /dev/null @@ -1 +0,0 @@ - o Remove tests dependency on nose2. Closes #4258. -- cgit v1.2.3