diff options
author | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-31 19:44:25 +0000 |
---|---|---|
committer | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-31 19:44:25 +0000 |
commit | 310512cc361ab20d11a236095664fafae2250fac (patch) | |
tree | ce779afc56fb845f043ea7f54e905c7ff4d8d697 /sync/test | |
parent | 126f1d652abfd11204fb7b4aed48dcb9999903d9 (diff) | |
download | chromium_src-310512cc361ab20d11a236095664fafae2250fac.zip chromium_src-310512cc361ab20d11a236095664fafae2250fac.tar.gz chromium_src-310512cc361ab20d11a236095664fafae2250fac.tar.bz2 |
[Sync] Add support for performing a GetKey on startup.
The functionality is behind the --sync-keystore-encryption flag, and the key
is not currently consumed by anything, but this lays the groundwork for testing
the server and client interaction.
We request a key anytime we perform a GetUpdates while the cryptographer
does not have a keystore key. But, it is considered an error to request a key
and not receive one, putting us into a state of backoff.
BUG=129665
TEST=sync_unit_tests, running against python server
Review URL: https://chromiumcodereview.appspot.com/10455012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149248 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/test')
-rw-r--r-- | sync/test/engine/mock_connection_manager.cc | 13 | ||||
-rw-r--r-- | sync/test/engine/mock_connection_manager.h | 6 | ||||
-rw-r--r-- | sync/test/engine/syncer_command_test.h | 3 |
3 files changed, 18 insertions, 4 deletions
diff --git a/sync/test/engine/mock_connection_manager.cc b/sync/test/engine/mock_connection_manager.cc index 5b5174d..3739bf3 100644 --- a/sync/test/engine/mock_connection_manager.cc +++ b/sync/test/engine/mock_connection_manager.cc @@ -11,6 +11,7 @@ #include "base/location.h" #include "base/stringprintf.h" #include "sync/engine/syncer_proto_util.h" +#include "sync/test/engine/test_id_factory.h" #include "sync/protocol/bookmark_specifics.pb.h" #include "sync/syncable/directory.h" #include "sync/syncable/write_transaction.h" @@ -427,7 +428,7 @@ void MockConnectionManager::ProcessGetUpdates( if (!updates->entries(i).deleted()) { ModelType entry_type = GetModelType(updates->entries(i)); EXPECT_TRUE( - IsModelTypePresentInSpecifics(gu.from_progress_marker(), entry_type)) + IsModelTypePresentInSpecifics(gu.from_progress_marker(), entry_type)) << "Syncer did not request updates being provided by the test."; } } @@ -447,9 +448,19 @@ void MockConnectionManager::ProcessGetUpdates( } } + // Fill the keystore key if requested. + if (gu.need_encryption_key()) + response->mutable_get_updates()->set_encryption_key(keystore_key_); + update_queue_.pop_front(); } +void MockConnectionManager::SetKeystoreKey(const std::string& key) { + // Note: this is not a thread-safe set, ok for now. NOT ok if tests + // run the syncer on the background thread while this method is called. + keystore_key_ = key; +} + bool MockConnectionManager::ShouldConflictThisCommit() { bool conflict = false; if (conflict_all_commits_) { diff --git a/sync/test/engine/mock_connection_manager.h b/sync/test/engine/mock_connection_manager.h index eb98471..5aabe7f 100644 --- a/sync/test/engine/mock_connection_manager.h +++ b/sync/test/engine/mock_connection_manager.h @@ -122,6 +122,8 @@ class MockConnectionManager : public ServerConnectionManager { void FailNextPostBufferToPathCall() { countdown_to_postbuffer_fail_ = 1; } void FailNthPostBufferToPathCall(int n) { countdown_to_postbuffer_fail_ = n; } + void SetKeystoreKey(const std::string& key); + void FailNonPeriodicGetUpdates() { fail_non_periodic_get_updates_ = true; } // Simple inspectors. @@ -302,8 +304,8 @@ class MockConnectionManager : public ServerConnectionManager { base::Closure mid_commit_callback_; MidCommitObserver* mid_commit_observer_; - // The clear data response we'll return in the next response - sync_pb::SyncEnums::ErrorType clear_user_data_response_errortype_; + // The keystore key we return for a GetUpdates with need_encryption_key set. + std::string keystore_key_; // The AUTHENTICATE response we'll return for auth requests. sync_pb::AuthenticateResponse auth_response_; diff --git a/sync/test/engine/syncer_command_test.h b/sync/test/engine/syncer_command_test.h index 0c0185e..803ef18 100644 --- a/sync/test/engine/syncer_command_test.h +++ b/sync/test/engine/syncer_command_test.h @@ -127,7 +127,8 @@ class SyncerCommandTestBase : public testing::Test, throttled_data_type_tracker_.get(), std::vector<SyncEngineEventListener*>(), &mock_debug_info_getter_, - &traffic_recorder_)); + &traffic_recorder_, + true /* enable keystore encryption*/ )); context_->set_account_name(directory()->name()); ClearSession(); } |