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 #ifndef COMPONENTS_COMPONENT_UPDATER_TEST_URL_REQUEST_POST_INTERCEPTOR_H_ | 5 #ifndef COMPONENTS_UPDATE_CLIENT_TEST_URL_REQUEST_POST_INTERCEPTOR_H_ |
6 #define COMPONENTS_COMPONENT_UPDATER_TEST_URL_REQUEST_POST_INTERCEPTOR_H_ | 6 #define COMPONENTS_UPDATE_CLIENT_TEST_URL_REQUEST_POST_INTERCEPTOR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <map> | 9 #include <map> |
10 #include <queue> | 10 #include <queue> |
11 #include <string> | 11 #include <string> |
12 #include <utility> | 12 #include <utility> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 class FilePath; | 21 class FilePath; |
22 class SequencedTaskRunner; | 22 class SequencedTaskRunner; |
23 } | 23 } |
24 | 24 |
25 namespace net { | 25 namespace net { |
26 class URLRequest; | 26 class URLRequest; |
27 } | 27 } |
28 | 28 |
29 namespace component_updater { | 29 namespace update_client { |
30 | |
31 // component 1 has extension id "jebgalgnebhfojomionfpkfelancnnkf", and | |
32 // the RSA public key the following hash: | |
33 const uint8_t jebg_hash[] = {0x94, 0x16, 0x0b, 0x6d, 0x41, 0x75, 0xe9, 0xec, | |
34 0x8e, 0xd5, 0xfa, 0x54, 0xb0, 0xd2, 0xdd, 0xa5, | |
35 0x6e, 0x05, 0x6b, 0xe8, 0x73, 0x47, 0xf6, 0xc4, | |
36 0x11, 0x9f, 0xbc, 0xb3, 0x09, 0xb3, 0x5b, 0x40}; | |
37 // component 2 has extension id "abagagagagagagagagagagagagagagag", and | |
38 // the RSA public key the following hash: | |
39 const uint8_t abag_hash[] = {0x01, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, | |
40 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, | |
41 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, | |
42 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01}; | |
43 // component 3 has extension id "ihfokbkgjpifnbbojhneepfflplebdkc", and | |
44 // the RSA public key the following hash: | |
45 const uint8_t ihfo_hash[] = {0x87, 0x5e, 0xa1, 0xa6, 0x9f, 0x85, 0xd1, 0x1e, | |
46 0x97, 0xd4, 0x4f, 0x55, 0xbf, 0xb4, 0x13, 0xa2, | |
47 0xe7, 0xc5, 0xc8, 0xf5, 0x60, 0x19, 0x78, 0x1b, | |
48 0x6d, 0xe9, 0x4c, 0xeb, 0x96, 0x05, 0x42, 0x17}; | |
49 | 30 |
50 // Intercepts requests to a file path, counts them, and captures the body of | 31 // Intercepts requests to a file path, counts them, and captures the body of |
51 // the requests. Optionally, for each request, it can return a canned response | 32 // the requests. Optionally, for each request, it can return a canned response |
52 // from a given file. The class maintains a queue of expectations, and returns | 33 // from a given file. The class maintains a queue of expectations, and returns |
53 // one and only one response for each request that matches and it is | 34 // one and only one response for each request that matches and it is |
54 // intercepted. | 35 // intercepted. |
55 class URLRequestPostInterceptor { | 36 class URLRequestPostInterceptor { |
56 public: | 37 public: |
57 // Allows a generic string maching interface when setting up expectations. | 38 // Allows a generic string maching interface when setting up expectations. |
58 class RequestMatcher { | 39 class RequestMatcher { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 public: | 153 public: |
173 explicit PartialMatch(const std::string& expected) : expected_(expected) {} | 154 explicit PartialMatch(const std::string& expected) : expected_(expected) {} |
174 bool Match(const std::string& actual) const override; | 155 bool Match(const std::string& actual) const override; |
175 | 156 |
176 private: | 157 private: |
177 const std::string expected_; | 158 const std::string expected_; |
178 | 159 |
179 DISALLOW_COPY_AND_ASSIGN(PartialMatch); | 160 DISALLOW_COPY_AND_ASSIGN(PartialMatch); |
180 }; | 161 }; |
181 | 162 |
182 } // namespace component_updater | 163 } // namespace update_client |
183 | 164 |
184 #endif // COMPONENTS_COMPONENT_UPDATER_TEST_URL_REQUEST_POST_INTERCEPTOR_H_ | 165 #endif // COMPONENTS_UPDATE_CLIENT_TEST_URL_REQUEST_POST_INTERCEPTOR_H_ |
OLD | NEW |