Example #1
0
 def test_trivial_sync(self):
     mem_db = self.request_state._create_database('test.db')
     mem_doc = mem_db.create_doc_from_json(tests.nested_doc)
     url = self.getURL('~/test.db')
     target = c_backend_wrapper.create_oauth_http_sync_target(url,
             tests.consumer1.key, tests.consumer1.secret,
             tests.token1.key, tests.token1.secret)
     db = c_backend_wrapper.CDatabase(':memory:')
     doc = db.create_doc_from_json(tests.simple_doc)
     c_backend_wrapper.sync_db_to_target(db, target)
     self.assertGetDoc(mem_db, doc.doc_id, doc.rev, doc.get_json(), False)
     self.assertGetDoc(db, mem_doc.doc_id, mem_doc.rev, mem_doc.get_json(),
                       False)
Example #2
0
 def test_trivial_sync(self):
     mem_db = self.request_state._create_database('test.db')
     mem_doc = mem_db.create_doc_from_json(tests.nested_doc)
     url = self.getURL('~/test.db')
     target = c_backend_wrapper.create_oauth_http_sync_target(
         url, tests.consumer1.key, tests.consumer1.secret, tests.token1.key,
         tests.token1.secret)
     db = c_backend_wrapper.CDatabase(':memory:')
     doc = db.create_doc_from_json(tests.simple_doc)
     c_backend_wrapper.sync_db_to_target(db, target)
     self.assertGetDoc(mem_db, doc.doc_id, doc.rev, doc.get_json(), False)
     self.assertGetDoc(db, mem_doc.doc_id, mem_doc.rev, mem_doc.get_json(),
                       False)
Example #3
0
 def test_oauth_credentials(self):
     target = c_backend_wrapper.create_oauth_http_sync_target(
             "http://host/base%2Ctest/",
             'consumer-key', 'consumer-secret', 'token-key', 'token-secret')
     auth = c_backend_wrapper._get_oauth_authorization(target,
         "GET", "http://host/base%2Ctest/sync-from/abcd-efg")
     self.assertIsNot(None, auth)
     self.assertTrue(auth.startswith('Authorization: OAuth realm="", '))
     self.assertNotIn('http://host/base', auth)
     self.assertIn('oauth_nonce="', auth)
     self.assertIn('oauth_timestamp="', auth)
     self.assertIn('oauth_consumer_key="consumer-key"', auth)
     self.assertIn('oauth_signature_method="HMAC-SHA1"', auth)
     self.assertIn('oauth_version="1.0"', auth)
     self.assertIn('oauth_token="token-key"', auth)
     self.assertIn('oauth_signature="', auth)
Example #4
0
 def test_oauth_credentials(self):
     target = c_backend_wrapper.create_oauth_http_sync_target(
         "http://host/base%2Ctest/", 'consumer-key', 'consumer-secret',
         'token-key', 'token-secret')
     auth = c_backend_wrapper._get_oauth_authorization(
         target, "GET", "http://host/base%2Ctest/sync-from/abcd-efg")
     self.assertIsNot(None, auth)
     self.assertTrue(auth.startswith('Authorization: OAuth realm="", '))
     self.assertNotIn('http://host/base', auth)
     self.assertIn('oauth_nonce="', auth)
     self.assertIn('oauth_timestamp="', auth)
     self.assertIn('oauth_consumer_key="consumer-key"', auth)
     self.assertIn('oauth_signature_method="HMAC-SHA1"', auth)
     self.assertIn('oauth_version="1.0"', auth)
     self.assertIn('oauth_token="token-key"', auth)
     self.assertIn('oauth_signature="', auth)