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::FromJavaTime(32), client_.last_policy_timestamp_); | 82 EXPECT_EQ(base::Time::FromJavaTime(32), client_.last_policy_timestamp_); |
84 EXPECT_TRUE(client_.submit_machine_id_); | |
85 EXPECT_TRUE(client_.public_key_version_valid_); | 83 EXPECT_TRUE(client_.public_key_version_valid_); |
86 EXPECT_EQ(17, client_.public_key_version_); | 84 EXPECT_EQ(17, client_.public_key_version_); |
87 } | 85 } |
88 | 86 |
89 TEST_F(CloudPolicyServiceTest, PolicyUpdateClientFailure) { | 87 TEST_F(CloudPolicyServiceTest, PolicyUpdateClientFailure) { |
90 client_.SetStatus(DM_STATUS_REQUEST_FAILED); | 88 client_.SetStatus(DM_STATUS_REQUEST_FAILED); |
91 EXPECT_CALL(store_, Store(_)).Times(0); | 89 EXPECT_CALL(store_, Store(_)).Times(0); |
92 client_.NotifyPolicyFetched(); | 90 client_.NotifyPolicyFetched(); |
93 } | 91 } |
94 | 92 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 testing::Mock::VerifyAndClearExpectations(&observer); | 271 testing::Mock::VerifyAndClearExpectations(&observer); |
274 | 272 |
275 // Now, the next time the store is loaded, the observer should not be called | 273 // Now, the next time the store is loaded, the observer should not be called |
276 // again. | 274 // again. |
277 EXPECT_CALL(observer, OnInitializationCompleted(&service_)).Times(0); | 275 EXPECT_CALL(observer, OnInitializationCompleted(&service_)).Times(0); |
278 store_.NotifyStoreLoaded(); | 276 store_.NotifyStoreLoaded(); |
279 service_.RemoveObserver(&observer); | 277 service_.RemoveObserver(&observer); |
280 } | 278 } |
281 | 279 |
282 } // namespace policy | 280 } // namespace policy |
OLD | NEW |