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 "components/policy/core/common/cloud/cloud_policy_service.h" | 5 #include "components/policy/core/common/cloud/cloud_policy_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 client_.SetPolicy(policy_type_, std::string(), policy); | 67 client_.SetPolicy(policy_type_, std::string(), policy); |
68 EXPECT_CALL(store_, Store(ProtoMatches(policy))).Times(1); | 68 EXPECT_CALL(store_, Store(ProtoMatches(policy))).Times(1); |
69 client_.NotifyPolicyFetched(); | 69 client_.NotifyPolicyFetched(); |
70 | 70 |
71 // After |store_| initializes, credentials and other meta data should be | 71 // After |store_| initializes, credentials and other meta data should be |
72 // transferred to |client_|. | 72 // transferred to |client_|. |
73 store_.policy_.reset(new em::PolicyData()); | 73 store_.policy_.reset(new em::PolicyData()); |
74 store_.policy_->set_request_token("fake token"); | 74 store_.policy_->set_request_token("fake token"); |
75 store_.policy_->set_device_id("fake client id"); | 75 store_.policy_->set_device_id("fake client id"); |
76 store_.policy_->set_timestamp(32); | 76 store_.policy_->set_timestamp(32); |
77 store_.policy_->set_valid_serial_number_missing(true); | |
78 store_.policy_->set_public_key_version(17); | 77 store_.policy_->set_public_key_version(17); |
79 EXPECT_CALL(client_, | 78 EXPECT_CALL(client_, |
80 SetupRegistration(store_.policy_->request_token(), | 79 SetupRegistration(store_.policy_->request_token(), |
81 store_.policy_->device_id())).Times(1); | 80 store_.policy_->device_id())).Times(1); |
82 store_.NotifyStoreLoaded(); | 81 store_.NotifyStoreLoaded(); |
83 EXPECT_EQ(base::Time::UnixEpoch() + base::TimeDelta::FromMilliseconds(32), | 82 EXPECT_EQ(base::Time::UnixEpoch() + base::TimeDelta::FromMilliseconds(32), |
84 client_.last_policy_timestamp_); | 83 client_.last_policy_timestamp_); |
85 EXPECT_TRUE(client_.submit_machine_id_); | |
86 EXPECT_TRUE(client_.public_key_version_valid_); | 84 EXPECT_TRUE(client_.public_key_version_valid_); |
87 EXPECT_EQ(17, client_.public_key_version_); | 85 EXPECT_EQ(17, client_.public_key_version_); |
88 } | 86 } |
89 | 87 |
90 TEST_F(CloudPolicyServiceTest, PolicyUpdateClientFailure) { | 88 TEST_F(CloudPolicyServiceTest, PolicyUpdateClientFailure) { |
91 client_.SetStatus(DM_STATUS_REQUEST_FAILED); | 89 client_.SetStatus(DM_STATUS_REQUEST_FAILED); |
92 EXPECT_CALL(store_, Store(_)).Times(0); | 90 EXPECT_CALL(store_, Store(_)).Times(0); |
93 client_.NotifyPolicyFetched(); | 91 client_.NotifyPolicyFetched(); |
94 } | 92 } |
95 | 93 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 testing::Mock::VerifyAndClearExpectations(&observer); | 272 testing::Mock::VerifyAndClearExpectations(&observer); |
275 | 273 |
276 // Now, the next time the store is loaded, the observer should not be called | 274 // Now, the next time the store is loaded, the observer should not be called |
277 // again. | 275 // again. |
278 EXPECT_CALL(observer, OnInitializationCompleted(&service_)).Times(0); | 276 EXPECT_CALL(observer, OnInitializationCompleted(&service_)).Times(0); |
279 store_.NotifyStoreLoaded(); | 277 store_.NotifyStoreLoaded(); |
280 service_.RemoveObserver(&observer); | 278 service_.RemoveObserver(&observer); |
281 } | 279 } |
282 | 280 |
283 } // namespace policy | 281 } // namespace policy |
OLD | NEW |