Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: chrome/browser/chromeos/settings/session_manager_operation_unittest.cc

Issue 143183007: Update policy signature verification to include policy domain. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed style error. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Convert from bytes to string format (which is what ValidateSignature() 266 // Convert from bytes to string format (which is what ValidateSignature()
267 // takes). 267 // takes).
268 std::string public_key_as_string = std::string( 268 std::string public_key_as_string = std::string(
269 reinterpret_cast<const char*>(vector_as_array(&public_key)), 269 reinterpret_cast<const char*>(vector_as_array(&public_key)),
270 public_key.size()); 270 public_key.size());
271 validator->ValidateSignature( 271 validator->ValidateSignature(
272 public_key_as_string, 272 public_key_as_string,
273 policy::GetPolicyVerificationKey(), 273 policy::GetPolicyVerificationKey(),
274 policy::PolicyBuilder::GetTestSigningKeySignature(), 274 policy::PolicyBuilder::kFakeDomain,
275 false); 275 false);
276 validator->StartValidation( 276 validator->StartValidation(
277 base::Bind(&SessionManagerOperationTest::CheckSuccessfulValidation, 277 base::Bind(&SessionManagerOperationTest::CheckSuccessfulValidation,
278 base::Unretained(this))); 278 base::Unretained(this)));
279 279
280 message_loop_.RunUntilIdle(); 280 message_loop_.RunUntilIdle();
281 EXPECT_TRUE(validated_); 281 EXPECT_TRUE(validated_);
282 282
283 // Check that the loaded policy_data contains the expected values. 283 // Check that the loaded policy_data contains the expected values.
284 EXPECT_EQ(policy::dm_protocol::kChromeDevicePolicyType, 284 EXPECT_EQ(policy::dm_protocol::kChromeDevicePolicyType,
285 op.policy_data()->policy_type()); 285 op.policy_data()->policy_type());
286 EXPECT_LE((before - base::Time::UnixEpoch()).InMilliseconds(), 286 EXPECT_LE((before - base::Time::UnixEpoch()).InMilliseconds(),
287 op.policy_data()->timestamp()); 287 op.policy_data()->timestamp());
288 EXPECT_GE((after - base::Time::UnixEpoch()).InMilliseconds(), 288 EXPECT_GE((after - base::Time::UnixEpoch()).InMilliseconds(),
289 op.policy_data()->timestamp()); 289 op.policy_data()->timestamp());
290 EXPECT_FALSE(op.policy_data()->has_request_token()); 290 EXPECT_FALSE(op.policy_data()->has_request_token());
291 EXPECT_EQ(policy_.policy_data().username(), op.policy_data()->username()); 291 EXPECT_EQ(policy_.policy_data().username(), op.policy_data()->username());
292 292
293 // Loaded device settings should match what the operation received. 293 // Loaded device settings should match what the operation received.
294 ASSERT_TRUE(op.device_settings().get()); 294 ASSERT_TRUE(op.device_settings().get());
295 EXPECT_EQ(policy_.payload().SerializeAsString(), 295 EXPECT_EQ(policy_.payload().SerializeAsString(),
296 op.device_settings()->SerializeAsString()); 296 op.device_settings()->SerializeAsString());
297 } 297 }
298 298
299 } // namespace chromeos 299 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698