diff options
author | drebs <drebs@leap.se> | 2013-05-01 13:57:22 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2013-05-01 13:57:22 -0300 |
commit | 16e66a74faf2c877bb2444951ec5e4799275afdd (patch) | |
tree | 0658b5d207b3931676ab4d24c1e502da7f952e09 /src/leap/soledad | |
parent | e02541f541cac636c1d3e6071a5f931cb98d7982 (diff) |
Include tests for HTTPDatabase and token auth.
Diffstat (limited to 'src/leap/soledad')
-rw-r--r-- | src/leap/soledad/tests/test_leap_backend.py | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/leap/soledad/tests/test_leap_backend.py b/src/leap/soledad/tests/test_leap_backend.py index ffb242fe..2ca76cb9 100644 --- a/src/leap/soledad/tests/test_leap_backend.py +++ b/src/leap/soledad/tests/test_leap_backend.py @@ -28,7 +28,10 @@ except ImportError: import cStringIO -from u1db.remote import http_client +from u1db.remote import ( + http_client, + http_database, +) from leap.soledad.backends import leap_backend @@ -554,4 +557,40 @@ def token_leap_https_sync_target(test, host, path): # 'sync_target': token_leap_https_sync_target}), # ] + +#----------------------------------------------------------------------------- +# The following tests come from `u1db.tests.test_https`. +#----------------------------------------------------------------------------- + +class _HTTPDatabase(http_database.HTTPDatabase): + """ + Wraps our token auth implementation. + """ + + def set_token_credentials(self, uuid, token): + auth.set_token_credentials(self, uuid, token) + + def _sign_request(self, method, url_query, params): + return auth._sign_request(self, method, url_query, params) + + +class TestHTTPDatabaseWithCreds(test_http_database.TestHTTPDatabaseCtrWithCreds): + + def test_get_sync_target_inherits_token_credentials(self): + # this test was from TestDatabaseSimpleOperations but we put it here + # for convenience. + self.db = _HTTPDatabase('dbase') + self.db.set_token_credentials('user-uuid', 'auth-token') + st = self.db.get_sync_target() + self.assertEqual(self.db._creds, st._creds) + + + def test_ctr_with_creds(self): + db1 = _HTTPDatabase('http://dbs/db', creds={'token': { + 'uuid': 'user-uuid', + 'token': 'auth-token', + }}) + self.assertIn('token', db1._creds) + + load_tests = tests.load_with_scenarios |