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 dea6c5803aa1c479898118935092bdd0ed72eb7c..a5f86db26fc89854668d5e639047163d0499dc16 100644 |
--- a/chrome/browser/chromeos/login/signed_settings_unittest.cc |
+++ b/chrome/browser/chromeos/login/signed_settings_unittest.cc |
@@ -176,39 +176,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( |
@@ -337,136 +304,6 @@ class SignedSettingsTest : public testing::Test { |
ScopedStubCrosEnabler stub_cros_enabler_; |
}; |
-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); |
- |
- 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); |
- |
- 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); |
- |
- 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); |
- |
- 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(); |