diff options
author | drebs <drebs@leap.se> | 2016-05-07 17:51:55 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2016-05-07 17:56:04 -0300 |
commit | 7efa05d1b09b91c323815e85cae7e6d523259267 (patch) | |
tree | bca5dcabd6463329d78126edac2d22cf9009938b | |
parent | 73af9d386e08124d5cec0af2ec259d9cd5ec67a5 (diff) |
[refactor] change secrets import/export meth names to load/dumpbug/remove-unicode-conversion
-rw-r--r-- | client/src/leap/soledad/client/secrets.py | 28 | ||||
-rw-r--r-- | common/src/leap/soledad/common/tests/test_crypto.py | 10 | ||||
-rw-r--r-- | common/src/leap/soledad/common/tests/test_soledad.py | 2 |
3 files changed, 20 insertions, 20 deletions
diff --git a/client/src/leap/soledad/client/secrets.py b/client/src/leap/soledad/client/secrets.py index 347ebe4d..08573f6b 100644 --- a/client/src/leap/soledad/client/secrets.py +++ b/client/src/leap/soledad/client/secrets.py @@ -265,7 +265,7 @@ class SoledadSecrets(object): content = None with open(self._secrets_path, 'r') as f: content = json.loads(f.read()) - _, active_secret, version = self._import_recovery_document(content) + _, active_secret, version = self._load_recovery_document(content) self._maybe_set_active_secret(active_secret) @@ -287,7 +287,7 @@ class SoledadSecrets(object): if doc is None: raise NoStorageSecret - _, active_secret, version = self._import_recovery_document(doc.content) + _, active_secret, version = self._load_recovery_document(doc.content) self._maybe_set_active_secret(active_secret) return version @@ -341,9 +341,9 @@ class SoledadSecrets(object): '%s%s' % (self._passphrase_as_string(), self._uuid)).hexdigest() - def _export_recovery_document(self): + def _dump_recovery_document(self): """ - Export the storage secrets. + Dump the storage secrets. Current format of recovery document has the following structure: @@ -378,18 +378,18 @@ class SoledadSecrets(object): } return data - def _import_recovery_document(self, data): + def _load_recovery_document(self, data): """ - Import storage secrets for symmetric encryption from a recovery + Load storage secrets for symmetric encryption from a recovery document. - Note that this method does not store the imported data on disk. For + Note that this method does not store the loaded data on disk. For that, use C{self._store_secrets()}. :param data: The recovery document. :type data: dict - :return: A tuple containing the number of imported secrets, the + :return: A tuple containing the number of loaded secrets, the secret_id of the last active secret, and the recovery document format version. :rtype: (int, str, int) @@ -397,13 +397,13 @@ class SoledadSecrets(object): # determine version of recovery document in order to use correct # loading method. Assume version is 1 if no version is present. version = data.get(self.RECOVERY_DOC_VERSION_KEY, 1) - meth = getattr(self, '_import_recovery_document_version_%d' % version) + meth = getattr(self, '_load_recovery_document_version_%d' % version) secret_count, active_secret = meth(data) return secret_count, active_secret, version - def _import_recovery_document_version_1(self, data): + def _load_recovery_document_version_1(self, data): """ - Import storage secrets for symmetric encryption from a recovery + Load storage secrets for symmetric encryption from a recovery document with format version 1. Version 1 of recovery document has the following structure: @@ -423,7 +423,7 @@ class SoledadSecrets(object): :param data: The recovery document. :type data: dict - :return: A tuple containing the number of imported secrets, the + :return: A tuple containing the number of loaded secrets, the secret_id of the last active secret, and the recovery document format version. :rtype: (int, str, int) @@ -480,7 +480,7 @@ class SoledadSecrets(object): doc = document.SoledadDocument( doc_id=self._shared_db_doc_id()) # fill doc with encrypted secrets - doc.content = self._export_recovery_document() + doc.content = self._dump_recovery_document() # upload secrets to server user_data = self._get_user_data() events.emit_async(events.SOLEDAD_UPLOADING_KEYS, user_data) @@ -634,7 +634,7 @@ class SoledadSecrets(object): with open(self._secrets_path, 'w') as f: f.write( json.dumps( - self._export_recovery_document())) + self._dump_recovery_document())) def change_passphrase(self, new_passphrase): """ diff --git a/common/src/leap/soledad/common/tests/test_crypto.py b/common/src/leap/soledad/common/tests/test_crypto.py index 5ced024b..08185a80 100644 --- a/common/src/leap/soledad/common/tests/test_crypto.py +++ b/common/src/leap/soledad/common/tests/test_crypto.py @@ -62,8 +62,8 @@ class EncryptedSyncTestCase(BaseSoledadTest): class RecoveryDocumentTestCase(BaseSoledadTest): - def test_export_recovery_document_raw(self): - rd = self._soledad.secrets._export_recovery_document() + def test_dump_recovery_document_raw(self): + rd = self._soledad.secrets._dump_recovery_document() secret_id = rd[self._soledad.secrets.STORAGE_SECRETS_KEY].items()[0][0] # assert exported secret is the same secret = self._soledad.secrets._decrypt_storage_secret_version_1( @@ -79,10 +79,10 @@ class RecoveryDocumentTestCase(BaseSoledadTest): self.assertTrue(self._soledad.secrets.LENGTH_KEY in encrypted_secret) self.assertTrue(self._soledad.secrets.SECRET_KEY in encrypted_secret) - def test_import_recovery_document(self): - rd = self._soledad.secrets._export_recovery_document() + def test_load_recovery_document(self): + rd = self._soledad.secrets._dump_recovery_document() s = self._soledad_instance() - s.secrets._import_recovery_document(rd) + s.secrets._load_recovery_document(rd) s.secrets.set_secret_id(self._soledad.secrets._secret_id) self.assertEqual(self._soledad.storage_secret, s.storage_secret, diff --git a/common/src/leap/soledad/common/tests/test_soledad.py b/common/src/leap/soledad/common/tests/test_soledad.py index ba1113bc..f3b82ab7 100644 --- a/common/src/leap/soledad/common/tests/test_soledad.py +++ b/common/src/leap/soledad/common/tests/test_soledad.py @@ -294,7 +294,7 @@ class SoledadSignalingTestCase(BaseSoledadTest): sol = self._soledad_instance() # create a document with secrets doc = SoledadDocument(doc_id=sol.secrets._shared_db_doc_id()) - doc.content = sol.secrets._export_recovery_document() + doc.content = sol.secrets._dump_recovery_document() sol.close() # reset mock soledad.client.secrets.events.emit_async.reset_mock() |