| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/policy/cloud_policy_cache.h" | 5 #include "chrome/browser/policy/cloud_policy_cache.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 EXPECT_TRUE( | 76 EXPECT_TRUE( |
| 77 settings.SerializeToString(signed_response.mutable_policy_value())); | 77 settings.SerializeToString(signed_response.mutable_policy_value())); |
| 78 } | 78 } |
| 79 signed_response.set_timestamp( | 79 signed_response.set_timestamp( |
| 80 (timestamp - base::Time::UnixEpoch()).InMilliseconds()); | 80 (timestamp - base::Time::UnixEpoch()).InMilliseconds()); |
| 81 std::string serialized_signed_response; | 81 std::string serialized_signed_response; |
| 82 EXPECT_TRUE(signed_response.SerializeToString(&serialized_signed_response)); | 82 EXPECT_TRUE(signed_response.SerializeToString(&serialized_signed_response)); |
| 83 | 83 |
| 84 em::PolicyFetchResponse* response = new em::PolicyFetchResponse; | 84 em::PolicyFetchResponse* response = new em::PolicyFetchResponse; |
| 85 response->set_policy_data(serialized_signed_response); | 85 response->set_policy_data(serialized_signed_response); |
| 86 // TODO(jkummerow): Set proper certificate_chain and signature (when | 86 // TODO(jkummerow): Set proper new_public_key and signature (when |
| 87 // implementing support for signature verification). | 87 // implementing support for signature verification). |
| 88 response->set_policy_data_signature("TODO"); | 88 response->set_policy_data_signature("TODO"); |
| 89 response->add_certificate_chain("TODO"); | 89 response->set_new_public_key("TODO"); |
| 90 return response; | 90 return response; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void WritePolicy(const em::PolicyFetchResponse& policy) { | 93 void WritePolicy(const em::PolicyFetchResponse& policy) { |
| 94 std::string data; | 94 std::string data; |
| 95 em::CachedCloudPolicyResponse cached_policy; | 95 em::CachedCloudPolicyResponse cached_policy; |
| 96 cached_policy.mutable_cloud_policy()->CopyFrom(policy); | 96 cached_policy.mutable_cloud_policy()->CopyFrom(policy); |
| 97 EXPECT_TRUE(cached_policy.SerializeToString(&data)); | 97 EXPECT_TRUE(cached_policy.SerializeToString(&data)); |
| 98 int size = static_cast<int>(data.size()); | 98 int size = static_cast<int>(data.size()); |
| 99 EXPECT_EQ(size, file_util::WriteFile(test_file(), data.c_str(), size)); | 99 EXPECT_EQ(size, file_util::WriteFile(test_file(), data.c_str(), size)); |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 em::DevicePolicyResponse policy; | 642 em::DevicePolicyResponse policy; |
| 643 AddStringPolicy(&policy, "HomepageLocation", "http://www.example.com"); | 643 AddStringPolicy(&policy, "HomepageLocation", "http://www.example.com"); |
| 644 scoped_ptr<Value> decoded(DecodeDevicePolicy(policy)); | 644 scoped_ptr<Value> decoded(DecodeDevicePolicy(policy)); |
| 645 DictionaryValue expected; | 645 DictionaryValue expected; |
| 646 expected.Set("HomepageLocation", | 646 expected.Set("HomepageLocation", |
| 647 Value::CreateStringValue("http://www.example.com")); | 647 Value::CreateStringValue("http://www.example.com")); |
| 648 EXPECT_TRUE(expected.Equals(decoded.get())); | 648 EXPECT_TRUE(expected.Equals(decoded.get())); |
| 649 } | 649 } |
| 650 | 650 |
| 651 } // namespace policy | 651 } // namespace policy |
| OLD | NEW |