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

Unified Diff: components/policy/core/common/cloud/cloud_policy_validator_unittest.cc

Issue 116273002: Added support for signed policy blobs on desktop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for ios. Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: components/policy/core/common/cloud/cloud_policy_validator_unittest.cc
diff --git a/components/policy/core/common/cloud/cloud_policy_validator_unittest.cc b/components/policy/core/common/cloud/cloud_policy_validator_unittest.cc
index c0e165e20b7cd1e35788f268af7f1047ec8baebc..18dc7bec23a26d740f7b4ebef34d304c02d6a12b 100644
--- a/components/policy/core/common/cloud/cloud_policy_validator_unittest.cc
+++ b/components/policy/core/common/cloud/cloud_policy_validator_unittest.cc
@@ -8,6 +8,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_proxy.h"
+#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/core/common/cloud/cloud_policy_validator.h"
@@ -57,11 +58,18 @@ class CloudPolicyValidatorTest : public testing::Test {
}
scoped_ptr<UserCloudPolicyValidator> CreateValidator() {
- std::vector<uint8> public_key;
+ std::vector<uint8> public_key_bytes;
EXPECT_TRUE(
- PolicyBuilder::CreateTestSigningKey()->ExportPublicKey(&public_key));
+ PolicyBuilder::CreateTestSigningKey()->ExportPublicKey(
+ &public_key_bytes));
policy_.Build();
+ // Convert from bytes to string format (which is what ValidateSignature()
+ // takes).
+ std::string public_key = std::string(
+ reinterpret_cast<const char*>(vector_as_array(&public_key_bytes)),
+ public_key_bytes.size());
+
UserCloudPolicyValidator* validator = UserCloudPolicyValidator::Create(
policy_.GetCopy(), base::MessageLoopProxy::current());
validator->ValidateTimestamp(timestamp_, timestamp_,
@@ -71,9 +79,12 @@ class CloudPolicyValidatorTest : public testing::Test {
validator->ValidateDMToken(existing_dm_token_, ignore_missing_dm_token_);
validator->ValidatePolicyType(dm_protocol::kChromeUserPolicyType);
validator->ValidatePayload();
- validator->ValidateSignature(public_key, allow_key_rotation_);
+ validator->ValidateSignature(public_key,
+ GetPolicyVerificationKey(),
+ PolicyBuilder::GetTestSigningKeySignature(),
+ allow_key_rotation_);
if (allow_key_rotation_)
- validator->ValidateInitialKey();
+ validator->ValidateInitialKey(GetPolicyVerificationKey());
return make_scoped_ptr(validator);
}

Powered by Google App Engine
This is Rietveld 408576698