| Index: chrome/browser/chromeos/login/signed_settings_unittest.cc
|
| diff --git a/chrome/browser/chromeos/login/signed_settings_unittest.cc b/chrome/browser/chromeos/login/signed_settings_unittest.cc
|
| index e6ca1f1116f262859116f655094d9ae0cc42f51c..36896cdacef042b60bf1e127f3cad9c56707aca0 100644
|
| --- a/chrome/browser/chromeos/login/signed_settings_unittest.cc
|
| +++ b/chrome/browser/chromeos/login/signed_settings_unittest.cc
|
| @@ -177,39 +177,6 @@ class SignedSettingsTest : public testing::Test {
|
| poldata->set_policy_value(pol.SerializeAsString());
|
| }
|
|
|
| - bool CheckWhitelist(const std::string& email, const em::PolicyData& poldata) {
|
| - if (!poldata.has_policy_value())
|
| - return false;
|
| - em::ChromeDeviceSettingsProto pol;
|
| - pol.ParseFromString(poldata.policy_value());
|
| - if (!pol.has_user_whitelist())
|
| - return false;
|
| -
|
| - const RepeatedPtrField<std::string>& whitelist =
|
| - pol.user_whitelist().user_whitelist();
|
| - for (RepeatedPtrField<std::string>::const_iterator it = whitelist.begin();
|
| - it != whitelist.end();
|
| - ++it) {
|
| - if (email == *it)
|
| - return true;
|
| - }
|
| - return false;
|
| - }
|
| -
|
| - void ExpectWhitelistOp(SignedSettings* s,
|
| - em::PolicyData* fake_pol,
|
| - em::PolicyData* out_pol) {
|
| - mock_service(s, &m_);
|
| - EXPECT_CALL(m_, StartSigningAttempt(_, _))
|
| - .Times(1);
|
| - EXPECT_CALL(m_, has_cached_policy())
|
| - .WillOnce(Return(true));
|
| - EXPECT_CALL(m_, cached_policy())
|
| - .WillOnce(ReturnRef(*fake_pol));
|
| - EXPECT_CALL(m_, set_cached_policy(A<const em::PolicyData&>()))
|
| - .WillOnce(SaveArg<0>(out_pol));
|
| - }
|
| -
|
| void FailingStorePropertyOp(const OwnerManager::KeyOpCode return_code) {
|
| NormalDelegate<bool> d(false);
|
| scoped_refptr<SignedSettings> s(
|
| @@ -314,160 +281,6 @@ ACTION_P(Retrieve, policy_blob) { arg0.Run(policy_blob); }
|
| ACTION_P(Store, success) { arg1.Run(success); }
|
| ACTION_P(FinishKeyOp, s) { arg2->OnKeyOpComplete(OwnerManager::SUCCESS, s); }
|
|
|
| -TEST_F(SignedSettingsTest, CheckWhitelist) {
|
| - NormalDelegate<bool> d(true);
|
| - d.expect_success();
|
| - scoped_refptr<SignedSettings> s(
|
| - SignedSettings::CreateCheckWhitelistOp(fake_email_, &d));
|
| -
|
| - mock_service(s.get(), &m_);
|
| - EXPECT_CALL(m_, has_cached_policy())
|
| - .WillOnce(Return(true));
|
| -
|
| - std::vector<std::string> whitelist(1, fake_email_);
|
| - whitelist.push_back(fake_email_ + "m");
|
| - em::PolicyData fake_pol = BuildPolicyData(whitelist);
|
| - EXPECT_CALL(m_, cached_policy())
|
| - .WillOnce(ReturnRef(fake_pol));
|
| -
|
| - s->Execute();
|
| - message_loop_.RunAllPending();
|
| -}
|
| -
|
| -TEST_F(SignedSettingsTest, CheckWhitelistWildcards) {
|
| - NormalDelegate<bool> d(true);
|
| - d.expect_success();
|
| - scoped_refptr<SignedSettings> s(
|
| - SignedSettings::CreateCheckWhitelistOp(fake_email_, &d));
|
| -
|
| - mock_service(s.get(), &m_);
|
| - EXPECT_CALL(m_, has_cached_policy())
|
| - .WillOnce(Return(true));
|
| -
|
| - std::vector<std::string> whitelist(1, fake_domain_);
|
| - whitelist.push_back(fake_email_ + "m");
|
| - em::PolicyData fake_pol = BuildPolicyData(whitelist);
|
| - EXPECT_CALL(m_, cached_policy())
|
| - .WillOnce(ReturnRef(fake_pol))
|
| - .WillOnce(ReturnRef(fake_pol));
|
| -
|
| - s->Execute();
|
| - message_loop_.RunAllPending();
|
| -}
|
| -
|
| -TEST_F(SignedSettingsTest, CheckWhitelistNotFound) {
|
| - NormalDelegate<bool> d(true);
|
| - scoped_refptr<SignedSettings> s(
|
| - SignedSettings::CreateCheckWhitelistOp(fake_email_, &d));
|
| - d.expect_failure(SignedSettings::NOT_FOUND);
|
| -
|
| - mock_service(s.get(), &m_);
|
| - EXPECT_CALL(m_, has_cached_policy())
|
| - .WillOnce(Return(true));
|
| -
|
| - std::vector<std::string> whitelist(1, fake_email_ + "m");
|
| - em::PolicyData fake_pol = BuildPolicyData(whitelist);
|
| - EXPECT_CALL(m_, cached_policy())
|
| - .WillOnce(ReturnRef(fake_pol))
|
| - .WillOnce(ReturnRef(fake_pol));
|
| -
|
| - s->Execute();
|
| - message_loop_.RunAllPending();
|
| -}
|
| -
|
| -TEST_F(SignedSettingsTest, Whitelist) {
|
| - NormalDelegate<bool> d(true);
|
| - d.expect_success();
|
| - scoped_refptr<SignedSettings> s(
|
| - SignedSettings::CreateWhitelistOp(fake_email_, true, &d));
|
| - em::PolicyData in_pol = BuildPolicyData(std::vector<std::string>());
|
| - em::PolicyData out_pol;
|
| - ExpectWhitelistOp(s.get(), &in_pol, &out_pol);
|
| -
|
| - MockSessionManagerClient* client =
|
| - mock_dbus_thread_manager_->mock_session_manager_client();
|
| - EXPECT_CALL(*client, StorePolicy(_, _))
|
| - .WillOnce(Store(true))
|
| - .RetiresOnSaturation();
|
| -
|
| - s->Execute();
|
| - s->OnKeyOpComplete(OwnerManager::SUCCESS, std::vector<uint8>());
|
| - message_loop_.RunAllPending();
|
| -
|
| - ASSERT_TRUE(CheckWhitelist(fake_email_, out_pol));
|
| -}
|
| -
|
| -TEST_F(SignedSettingsTest, AddToExistingWhitelist) {
|
| - NormalDelegate<bool> d(true);
|
| - d.expect_success();
|
| - scoped_refptr<SignedSettings> s(
|
| - SignedSettings::CreateWhitelistOp(fake_email_, true, &d));
|
| - em::PolicyData in_pol =
|
| - BuildPolicyData(std::vector<std::string>(1, fake_domain_));
|
| - em::PolicyData out_pol;
|
| - ExpectWhitelistOp(s.get(), &in_pol, &out_pol);
|
| -
|
| - MockSessionManagerClient* client =
|
| - mock_dbus_thread_manager_->mock_session_manager_client();
|
| - EXPECT_CALL(*client, StorePolicy(_, _))
|
| - .WillOnce(Store(true))
|
| - .RetiresOnSaturation();
|
| -
|
| - s->Execute();
|
| - s->OnKeyOpComplete(OwnerManager::SUCCESS, std::vector<uint8>());
|
| - message_loop_.RunAllPending();
|
| -
|
| - ASSERT_TRUE(CheckWhitelist(fake_email_, out_pol));
|
| -}
|
| -
|
| -TEST_F(SignedSettingsTest, Unwhitelist) {
|
| - NormalDelegate<bool> d(true);
|
| - d.expect_success();
|
| - scoped_refptr<SignedSettings> s(
|
| - SignedSettings::CreateWhitelistOp(fake_email_, false, &d));
|
| - em::PolicyData in_pol =
|
| - BuildPolicyData(std::vector<std::string>(1, fake_email_));
|
| - em::PolicyData out_pol;
|
| - ExpectWhitelistOp(s.get(), &in_pol, &out_pol);
|
| -
|
| - MockSessionManagerClient* client =
|
| - mock_dbus_thread_manager_->mock_session_manager_client();
|
| - EXPECT_CALL(*client, StorePolicy(_, _))
|
| - .WillOnce(Store(true))
|
| - .RetiresOnSaturation();
|
| -
|
| - s->Execute();
|
| - s->OnKeyOpComplete(OwnerManager::SUCCESS, std::vector<uint8>());
|
| - message_loop_.RunAllPending();
|
| -
|
| - ASSERT_FALSE(CheckWhitelist(fake_email_, out_pol));
|
| -}
|
| -
|
| -TEST_F(SignedSettingsTest, RemoveFromExistingWhitelist) {
|
| - NormalDelegate<bool> d(true);
|
| - d.expect_success();
|
| - scoped_refptr<SignedSettings> s(
|
| - SignedSettings::CreateWhitelistOp(fake_email_, false, &d));
|
| - std::vector<std::string> whitelist(1, fake_domain_);
|
| - whitelist.push_back(fake_email_);
|
| - whitelist.push_back(fake_email_ + "m");
|
| - em::PolicyData in_pol = BuildPolicyData(whitelist);
|
| - em::PolicyData out_pol;
|
| - ExpectWhitelistOp(s.get(), &in_pol, &out_pol);
|
| -
|
| - MockSessionManagerClient* client =
|
| - mock_dbus_thread_manager_->mock_session_manager_client();
|
| - EXPECT_CALL(*client, StorePolicy(_, _))
|
| - .WillOnce(Store(true))
|
| - .RetiresOnSaturation();
|
| -
|
| - s->Execute();
|
| - s->OnKeyOpComplete(OwnerManager::SUCCESS, std::vector<uint8>());
|
| - message_loop_.RunAllPending();
|
| -
|
| - ASSERT_FALSE(CheckWhitelist(fake_email_, out_pol));
|
| -}
|
| -
|
| TEST_F(SignedSettingsTest, StoreProperty) {
|
| NormalDelegate<bool> d(true);
|
| d.expect_success();
|
|
|