| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 base::RunLoop().RunUntilIdle(); | 115 base::RunLoop().RunUntilIdle(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 // Verifies that store_->policy_map() has the HomepageLocation entry with | 118 // Verifies that store_->policy_map() has the HomepageLocation entry with |
| 119 // the |expected_value|. | 119 // the |expected_value|. |
| 120 void VerifyPolicyMap(const char* expected_value) { | 120 void VerifyPolicyMap(const char* expected_value) { |
| 121 EXPECT_EQ(1U, store_->policy_map().size()); | 121 EXPECT_EQ(1U, store_->policy_map().size()); |
| 122 const PolicyMap::Entry* entry = | 122 const PolicyMap::Entry* entry = |
| 123 store_->policy_map().Get(key::kHomepageLocation); | 123 store_->policy_map().Get(key::kHomepageLocation); |
| 124 ASSERT_TRUE(entry); | 124 ASSERT_TRUE(entry); |
| 125 EXPECT_TRUE(base::StringValue(expected_value).Equals(entry->value.get())); | 125 EXPECT_TRUE(base::Value(expected_value).Equals(entry->value.get())); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void StoreUserPolicyKey(const std::string& public_key) { | 128 void StoreUserPolicyKey(const std::string& public_key) { |
| 129 ASSERT_TRUE(base::CreateDirectory(user_policy_key_file().DirName())); | 129 ASSERT_TRUE(base::CreateDirectory(user_policy_key_file().DirName())); |
| 130 ASSERT_TRUE(base::WriteFile(user_policy_key_file(), public_key.data(), | 130 ASSERT_TRUE(base::WriteFile(user_policy_key_file(), public_key.data(), |
| 131 public_key.size())); | 131 public_key.size())); |
| 132 } | 132 } |
| 133 | 133 |
| 134 // Stores the current |policy_| and verifies that it is published. | 134 // Stores the current |policy_| and verifies that it is published. |
| 135 // If |new_public_key| is set then it will be persisted after storing but | 135 // If |new_public_key| is set then it will be persisted after storing but |
| (...skipping 15 matching lines...) Expand all Loading... |
| 151 base::RunLoop().RunUntilIdle(); | 151 base::RunLoop().RunUntilIdle(); |
| 152 Mock::VerifyAndClearExpectations(&session_manager_client_); | 152 Mock::VerifyAndClearExpectations(&session_manager_client_); |
| 153 ASSERT_FALSE(store_callback.is_null()); | 153 ASSERT_FALSE(store_callback.is_null()); |
| 154 | 154 |
| 155 // The new policy shouldn't be present yet. | 155 // The new policy shouldn't be present yet. |
| 156 PolicyMap previous_policy; | 156 PolicyMap previous_policy; |
| 157 EXPECT_EQ(previous_value != nullptr, store_->policy() != nullptr); | 157 EXPECT_EQ(previous_value != nullptr, store_->policy() != nullptr); |
| 158 if (previous_value) { | 158 if (previous_value) { |
| 159 previous_policy.Set(key::kHomepageLocation, POLICY_LEVEL_MANDATORY, | 159 previous_policy.Set(key::kHomepageLocation, POLICY_LEVEL_MANDATORY, |
| 160 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, | 160 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, |
| 161 base::MakeUnique<base::StringValue>(previous_value), | 161 base::MakeUnique<base::Value>(previous_value), |
| 162 nullptr); | 162 nullptr); |
| 163 } | 163 } |
| 164 EXPECT_TRUE(previous_policy.Equals(store_->policy_map())); | 164 EXPECT_TRUE(previous_policy.Equals(store_->policy_map())); |
| 165 EXPECT_EQ(initial_status, store_->status()); | 165 EXPECT_EQ(initial_status, store_->status()); |
| 166 | 166 |
| 167 // Store the new public key so that the validation after the retrieve | 167 // Store the new public key so that the validation after the retrieve |
| 168 // operation completes can verify the signature. | 168 // operation completes can verify the signature. |
| 169 if (new_public_key) | 169 if (new_public_key) |
| 170 StoreUserPolicyKey(*new_public_key); | 170 StoreUserPolicyKey(*new_public_key); |
| 171 | 171 |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 | 586 |
| 587 EXPECT_FALSE(store_->policy()); | 587 EXPECT_FALSE(store_->policy()); |
| 588 EXPECT_TRUE(store_->policy_map().empty()); | 588 EXPECT_TRUE(store_->policy_map().empty()); |
| 589 EXPECT_EQ(CloudPolicyStore::STATUS_VALIDATION_ERROR, store_->status()); | 589 EXPECT_EQ(CloudPolicyStore::STATUS_VALIDATION_ERROR, store_->status()); |
| 590 EXPECT_EQ(std::string(), store_->policy_signature_public_key()); | 590 EXPECT_EQ(std::string(), store_->policy_signature_public_key()); |
| 591 } | 591 } |
| 592 | 592 |
| 593 } // namespace | 593 } // namespace |
| 594 | 594 |
| 595 } // namespace policy | 595 } // namespace policy |
| OLD | NEW |