summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authoratwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-06 01:53:17 +0000
committeratwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-06 01:53:17 +0000
commitf5bd03a865895d850d53a0262671ea1e97533438 (patch)
treecdc329cfc24460f1c932f8d62832a2aff5f59b7f /components
parent3327e1c36621e38969db310ef51cc048a546c5cd (diff)
downloadchromium_src-f5bd03a865895d850d53a0262671ea1e97533438.zip
chromium_src-f5bd03a865895d850d53a0262671ea1e97533438.tar.gz
chromium_src-f5bd03a865895d850d53a0262671ea1e97533438.tar.bz2
Policy header now includes the policy_token.
BUG=326799 Review URL: https://codereview.chromium.org/151183005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249211 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r--components/policy/core/common/cloud/policy_header_service.cc10
-rw-r--r--components/policy/core/common/cloud/policy_header_service_unittest.cc17
-rw-r--r--components/policy/proto/device_management_backend.proto10
3 files changed, 21 insertions, 16 deletions
diff --git a/components/policy/core/common/cloud/policy_header_service.cc b/components/policy/core/common/cloud/policy_header_service.cc
index 3ba5b03..1f83090 100644
--- a/components/policy/core/common/cloud/policy_header_service.cc
+++ b/components/policy/core/common/cloud/policy_header_service.cc
@@ -64,12 +64,10 @@ std::string PolicyHeaderService::CreateHeaderValue() {
std::string user_dm_token = user_policy_store_->policy()->request_token();
base::DictionaryValue value;
value.SetString(kUserDMTokenKey, user_dm_token);
- // TODO(atwilson): Enable this once policy token is available.
- //if (user_policy_store_->policy()->has_policy_token()) {
- // value.SetString(kUserPolicyTokenKey,
- // user_policy_store_->policy()->policy_token());
- //}
- value.SetString(kUserPolicyTokenKey, "");
+ if (user_policy_store_->policy()->has_policy_token()) {
+ value.SetString(kUserPolicyTokenKey,
+ user_policy_store_->policy()->policy_token());
+ }
if (!verification_key_hash_.empty())
value.SetString(kVerificationKeyHashKey, verification_key_hash_);
diff --git a/components/policy/core/common/cloud/policy_header_service_unittest.cc b/components/policy/core/common/cloud/policy_header_service_unittest.cc
index c5cf639..3073d92 100644
--- a/components/policy/core/common/cloud/policy_header_service_unittest.cc
+++ b/components/policy/core/common/cloud/policy_header_service_unittest.cc
@@ -53,7 +53,8 @@ class PolicyHeaderServiceTest : public testing::Test {
}
void ValidateHeader(const net::HttpRequestHeaders& headers,
- const std::string& expected_dmtoken) {
+ const std::string& expected_dmtoken,
+ const std::string& expected_policy_token) {
if (expected_dmtoken.empty()) {
EXPECT_TRUE(headers.IsEmpty());
} else {
@@ -72,6 +73,9 @@ class PolicyHeaderServiceTest : public testing::Test {
std::string dm_token;
dict->GetString("user_dmtoken", &dm_token);
EXPECT_EQ(dm_token, expected_dmtoken);
+ std::string policy_token;
+ dict->GetString("user_policy_token", &policy_token);
+ EXPECT_EQ(policy_token, expected_policy_token);
}
}
@@ -94,8 +98,10 @@ TEST_F(PolicyHeaderServiceTest, TestCreationAndShutdown) {
TEST_F(PolicyHeaderServiceTest, TestWithAndWithoutPolicyHeader) {
// Set policy - this should push a header to the PolicyHeaderIOHelper.
scoped_ptr<PolicyData> policy(new PolicyData());
- std::string expected_token = "expected_token";
- policy->set_request_token(expected_token);
+ std::string expected_dmtoken = "expected_dmtoken";
+ std::string expected_policy_token = "expected_dmtoken";
+ policy->set_request_token(expected_dmtoken);
+ policy->set_policy_token(expected_policy_token);
user_store_.SetPolicy(policy.Pass());
task_runner_->RunUntilIdle();
@@ -103,7 +109,8 @@ TEST_F(PolicyHeaderServiceTest, TestWithAndWithoutPolicyHeader) {
net::TestURLRequest request(
GURL(kDMServerURL), net::DEFAULT_PRIORITY, NULL, &context);
helper_->AddPolicyHeaders(&request);
- ValidateHeader(request.extra_request_headers(), expected_token);
+ ValidateHeader(request.extra_request_headers(), expected_dmtoken,
+ expected_policy_token);
// Now blow away the policy data.
user_store_.SetPolicy(scoped_ptr<PolicyData>());
@@ -112,7 +119,7 @@ TEST_F(PolicyHeaderServiceTest, TestWithAndWithoutPolicyHeader) {
net::TestURLRequest request2(
GURL(kDMServerURL), net::DEFAULT_PRIORITY, NULL, &context);
helper_->AddPolicyHeaders(&request2);
- ValidateHeader(request2.extra_request_headers(), "");
+ ValidateHeader(request2.extra_request_headers(), "", "");
}
} // namespace policy
diff --git a/components/policy/proto/device_management_backend.proto b/components/policy/proto/device_management_backend.proto
index 51ee3a6..2908a79 100644
--- a/components/policy/proto/device_management_backend.proto
+++ b/components/policy/proto/device_management_backend.proto
@@ -264,6 +264,11 @@ message PolicyData {
// service object source. This value is combined with invalidation_source to
// form the object id used to register for invalidations to this policy.
optional bytes invalidation_name = 14;
+
+ // Server-provided identifier of the fetched policy. This is to be used
+ // by the client when requesting Policy Posture assertion through an API
+ // call or SAML flow.
+ optional string policy_token = 15;
}
message PolicyFetchResponse {
@@ -306,11 +311,6 @@ message PolicyFetchResponse {
// new_public_key with the embedded public key and
// new_public_key_verification_signature.
optional bytes new_public_key_verification_signature = 7;
-
- // Server-provided identifier of the fetched policy. This is to be used
- // by the client when requesting Policy Posture assertion through an API
- // call or SAML flow.
- optional bytes policy_token = 8;
}
// Request from device to server for reading policies.