OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/component_cloud_policy_store.h" | 5 #include "components/policy/core/common/cloud/component_cloud_policy_store.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 EXPECT_EQ(kTestExtension, policy_data.settings_entity_id()); | 168 EXPECT_EQ(kTestExtension, policy_data.settings_entity_id()); |
169 EXPECT_EQ(kTestDownload, payload.download_url()); | 169 EXPECT_EQ(kTestDownload, payload.download_url()); |
170 EXPECT_EQ(TestPolicyHash(), payload.secure_hash()); | 170 EXPECT_EQ(TestPolicyHash(), payload.secure_hash()); |
171 } | 171 } |
172 | 172 |
173 TEST_F(ComponentCloudPolicyStoreTest, ValidatePolicyWrongTimestamp) { | 173 TEST_F(ComponentCloudPolicyStoreTest, ValidatePolicyWrongTimestamp) { |
174 EXPECT_CALL(store_delegate_, OnComponentCloudPolicyStoreUpdated()); | 174 EXPECT_CALL(store_delegate_, OnComponentCloudPolicyStoreUpdated()); |
175 EXPECT_TRUE(store_->Store(kTestPolicyNS, CreateSerializedResponse(), | 175 EXPECT_TRUE(store_->Store(kTestPolicyNS, CreateSerializedResponse(), |
176 CreatePolicyData(), TestPolicyHash(), kTestPolicy)); | 176 CreatePolicyData(), TestPolicyHash(), kTestPolicy)); |
177 | 177 |
178 const int64_t kPastTimestamp = base::TimeDelta::FromDays(1).InMilliseconds(); | 178 const int64_t kPastTimestamp = |
| 179 (base::Time() + base::TimeDelta::FromDays(1)).ToJavaTime(); |
179 CHECK_GT(ComponentPolicyBuilder::kFakeTimestamp, kPastTimestamp); | 180 CHECK_GT(ComponentPolicyBuilder::kFakeTimestamp, kPastTimestamp); |
180 builder_.policy_data().set_timestamp(kPastTimestamp); | 181 builder_.policy_data().set_timestamp(kPastTimestamp); |
181 EXPECT_FALSE(store_->ValidatePolicy(kTestPolicyNS, CreateResponse(), | 182 EXPECT_FALSE(store_->ValidatePolicy(kTestPolicyNS, CreateResponse(), |
182 nullptr /* policy_data */, | 183 nullptr /* policy_data */, |
183 nullptr /* payload */)); | 184 nullptr /* payload */)); |
184 } | 185 } |
185 | 186 |
186 TEST_F(ComponentCloudPolicyStoreTest, ValidatePolicyWrongUsername) { | 187 TEST_F(ComponentCloudPolicyStoreTest, ValidatePolicyWrongUsername) { |
187 builder_.policy_data().set_username("anotheruser@example.com"); | 188 builder_.policy_data().set_username("anotheruser@example.com"); |
188 EXPECT_FALSE(store_->ValidatePolicy(kTestPolicyNS, CreateResponse(), | 189 EXPECT_FALSE(store_->ValidatePolicy(kTestPolicyNS, CreateResponse(), |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 ComponentPolicyBuilder::kFakeUsername, | 543 ComponentPolicyBuilder::kFakeUsername, |
543 ComponentPolicyBuilder::kFakeToken, | 544 ComponentPolicyBuilder::kFakeToken, |
544 ComponentPolicyBuilder::kFakeDeviceId, | 545 ComponentPolicyBuilder::kFakeDeviceId, |
545 public_key_, | 546 public_key_, |
546 ComponentPolicyBuilder::kFakePublicKeyVersion); | 547 ComponentPolicyBuilder::kFakePublicKeyVersion); |
547 yet_another_store.Load(); | 548 yet_another_store.Load(); |
548 EXPECT_TRUE(yet_another_store.policy().Equals(empty_bundle)); | 549 EXPECT_TRUE(yet_another_store.policy().Equals(empty_bundle)); |
549 } | 550 } |
550 | 551 |
551 } // namespace policy | 552 } // namespace policy |
OLD | NEW |