OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/base64.h" | 5 #include "base/base64.h" |
6 #include "base/json/json_reader.h" | 6 #include "base/json/json_reader.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/test/test_simple_task_runner.h" | 8 #include "base/test/test_simple_task_runner.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 10 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 // Notify observers. | 30 // Notify observers. |
31 NotifyStoreLoaded(); | 31 NotifyStoreLoaded(); |
32 } | 32 } |
33 }; | 33 }; |
34 | 34 |
35 class PolicyHeaderServiceTest : public testing::Test { | 35 class PolicyHeaderServiceTest : public testing::Test { |
36 public: | 36 public: |
37 PolicyHeaderServiceTest() { | 37 PolicyHeaderServiceTest() { |
38 task_runner_ = make_scoped_refptr(new base::TestSimpleTaskRunner()); | 38 task_runner_ = make_scoped_refptr(new base::TestSimpleTaskRunner()); |
39 } | 39 } |
40 virtual ~PolicyHeaderServiceTest() {} | 40 ~PolicyHeaderServiceTest() override {} |
41 | 41 |
42 virtual void SetUp() override { | 42 void SetUp() override { |
43 service_.reset(new PolicyHeaderService(kDMServerURL, | 43 service_.reset(new PolicyHeaderService(kDMServerURL, |
44 kPolicyVerificationKeyHash, | 44 kPolicyVerificationKeyHash, |
45 &user_store_, | 45 &user_store_, |
46 &device_store_)); | 46 &device_store_)); |
47 helper_ = service_->CreatePolicyHeaderIOHelper(task_runner_).Pass(); | 47 helper_ = service_->CreatePolicyHeaderIOHelper(task_runner_).Pass(); |
48 } | 48 } |
49 | 49 |
50 virtual void TearDown() override { | 50 void TearDown() override { |
51 task_runner_->RunUntilIdle(); | 51 task_runner_->RunUntilIdle(); |
52 // Helper should outlive the service. | 52 // Helper should outlive the service. |
53 service_.reset(); | 53 service_.reset(); |
54 helper_.reset(); | 54 helper_.reset(); |
55 } | 55 } |
56 | 56 |
57 void ValidateHeader(const net::HttpRequestHeaders& headers, | 57 void ValidateHeader(const net::HttpRequestHeaders& headers, |
58 const std::string& expected_dmtoken, | 58 const std::string& expected_dmtoken, |
59 const std::string& expected_policy_token) { | 59 const std::string& expected_policy_token) { |
60 if (expected_dmtoken.empty()) { | 60 if (expected_dmtoken.empty()) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 user_store_.SetPolicy(scoped_ptr<PolicyData>()); | 118 user_store_.SetPolicy(scoped_ptr<PolicyData>()); |
119 task_runner_->RunUntilIdle(); | 119 task_runner_->RunUntilIdle(); |
120 | 120 |
121 scoped_ptr<net::URLRequest> request2(context.CreateRequest( | 121 scoped_ptr<net::URLRequest> request2(context.CreateRequest( |
122 GURL(kDMServerURL), net::DEFAULT_PRIORITY, NULL, NULL)); | 122 GURL(kDMServerURL), net::DEFAULT_PRIORITY, NULL, NULL)); |
123 helper_->AddPolicyHeaders(request2->url(), request2.get()); | 123 helper_->AddPolicyHeaders(request2->url(), request2.get()); |
124 ValidateHeader(request2->extra_request_headers(), "", ""); | 124 ValidateHeader(request2->extra_request_headers(), "", ""); |
125 } | 125 } |
126 | 126 |
127 } // namespace policy | 127 } // namespace policy |
OLD | NEW |