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/settings/session_manager_operation.h" | 5 #include "chrome/browser/chromeos/settings/session_manager_operation.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 policy_response.Pass(), message_loop_.message_loop_proxy()); | 256 policy_response.Pass(), message_loop_.message_loop_proxy()); |
257 validator->ValidateUsername(policy_.policy_data().username()); | 257 validator->ValidateUsername(policy_.policy_data().username()); |
258 validator->ValidateTimestamp( | 258 validator->ValidateTimestamp( |
259 before, | 259 before, |
260 after, | 260 after, |
261 policy::CloudPolicyValidatorBase::TIMESTAMP_REQUIRED); | 261 policy::CloudPolicyValidatorBase::TIMESTAMP_REQUIRED); |
262 validator->ValidatePolicyType(policy::dm_protocol::kChromeDevicePolicyType); | 262 validator->ValidatePolicyType(policy::dm_protocol::kChromeDevicePolicyType); |
263 validator->ValidatePayload(); | 263 validator->ValidatePayload(); |
264 std::vector<uint8> public_key; | 264 std::vector<uint8> public_key; |
265 policy_.GetSigningKey()->ExportPublicKey(&public_key); | 265 policy_.GetSigningKey()->ExportPublicKey(&public_key); |
266 validator->ValidateSignature(public_key, false); | 266 // Convert from bytes to string format (which is what ValidateSignature() |
| 267 // takes). |
| 268 std::string public_key_as_string = std::string( |
| 269 reinterpret_cast<const char*>(vector_as_array(&public_key)), |
| 270 public_key.size()); |
| 271 validator->ValidateSignature( |
| 272 public_key_as_string, |
| 273 policy::GetPolicyVerificationKey(), |
| 274 policy::PolicyBuilder::GetTestSigningKeySignature(), |
| 275 false); |
267 validator->StartValidation( | 276 validator->StartValidation( |
268 base::Bind(&SessionManagerOperationTest::CheckSuccessfulValidation, | 277 base::Bind(&SessionManagerOperationTest::CheckSuccessfulValidation, |
269 base::Unretained(this))); | 278 base::Unretained(this))); |
270 | 279 |
271 message_loop_.RunUntilIdle(); | 280 message_loop_.RunUntilIdle(); |
272 EXPECT_TRUE(validated_); | 281 EXPECT_TRUE(validated_); |
273 | 282 |
274 // Check that the loaded policy_data contains the expected values. | 283 // Check that the loaded policy_data contains the expected values. |
275 EXPECT_EQ(policy::dm_protocol::kChromeDevicePolicyType, | 284 EXPECT_EQ(policy::dm_protocol::kChromeDevicePolicyType, |
276 op.policy_data()->policy_type()); | 285 op.policy_data()->policy_type()); |
277 EXPECT_LE((before - base::Time::UnixEpoch()).InMilliseconds(), | 286 EXPECT_LE((before - base::Time::UnixEpoch()).InMilliseconds(), |
278 op.policy_data()->timestamp()); | 287 op.policy_data()->timestamp()); |
279 EXPECT_GE((after - base::Time::UnixEpoch()).InMilliseconds(), | 288 EXPECT_GE((after - base::Time::UnixEpoch()).InMilliseconds(), |
280 op.policy_data()->timestamp()); | 289 op.policy_data()->timestamp()); |
281 EXPECT_FALSE(op.policy_data()->has_request_token()); | 290 EXPECT_FALSE(op.policy_data()->has_request_token()); |
282 EXPECT_EQ(policy_.policy_data().username(), op.policy_data()->username()); | 291 EXPECT_EQ(policy_.policy_data().username(), op.policy_data()->username()); |
283 | 292 |
284 // Loaded device settings should match what the operation received. | 293 // Loaded device settings should match what the operation received. |
285 ASSERT_TRUE(op.device_settings().get()); | 294 ASSERT_TRUE(op.device_settings().get()); |
286 EXPECT_EQ(policy_.payload().SerializeAsString(), | 295 EXPECT_EQ(policy_.payload().SerializeAsString(), |
287 op.device_settings()->SerializeAsString()); | 296 op.device_settings()->SerializeAsString()); |
288 } | 297 } |
289 | 298 |
290 } // namespace chromeos | 299 } // namespace chromeos |
OLD | NEW |