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

Side by Side Diff: net/proxy/proxy_script_fetcher_impl_unittest.cc

Issue 7204025: Revert 89628 - Revert 89489 - net: don't check revocation when fetching PAC files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/proxy/proxy_script_fetcher_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/proxy/proxy_script_fetcher_impl.h" 5 #include "net/proxy/proxy_script_fetcher_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "net/base/net_util.h" 13 #include "net/base/net_util.h"
14 #include "net/base/load_flags.h"
14 #include "net/base/ssl_config_service_defaults.h" 15 #include "net/base/ssl_config_service_defaults.h"
15 #include "net/base/test_completion_callback.h" 16 #include "net/base/test_completion_callback.h"
16 #include "net/disk_cache/disk_cache.h" 17 #include "net/disk_cache/disk_cache.h"
17 #include "net/http/http_cache.h" 18 #include "net/http/http_cache.h"
18 #include "net/http/http_network_session.h" 19 #include "net/http/http_network_session.h"
19 #include "net/test/test_server.h" 20 #include "net/test/test_server.h"
20 #include "net/url_request/url_request_context_storage.h" 21 #include "net/url_request/url_request_context_storage.h"
22 #include "net/url_request/url_request_job_factory.h"
21 #include "net/url_request/url_request_test_util.h" 23 #include "net/url_request/url_request_test_util.h"
22 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
23 #include "testing/platform_test.h" 25 #include "testing/platform_test.h"
24 26
25 namespace net { 27 namespace net {
26 28
27 // TODO(eroman): 29 // TODO(eroman):
28 // - Test canceling an outstanding request. 30 // - Test canceling an outstanding request.
29 // - Test deleting ProxyScriptFetcher while a request is in progress. 31 // - Test deleting ProxyScriptFetcher while a request is in progress.
30 32
31 namespace { 33 namespace {
32 34
33 const FilePath::CharType kDocRoot[] = 35 const FilePath::CharType kDocRoot[] =
34 FILE_PATH_LITERAL("net/data/proxy_script_fetcher_unittest"); 36 FILE_PATH_LITERAL("net/data/proxy_script_fetcher_unittest");
35 37
36 struct FetchResult { 38 struct FetchResult {
37 int code; 39 int code;
38 string16 text; 40 string16 text;
39 }; 41 };
40 42
43 // CheckNoRevocationFlagSetInterceptor causes a test failure if a request is
44 // seen that doesn't set a load flag to bypass revocation checking.
45 class CheckNoRevocationFlagSetInterceptor :
46 public URLRequestJobFactory::Interceptor {
47 public:
48 virtual URLRequestJob* MaybeIntercept(URLRequest* request) const OVERRIDE {
49 EXPECT_TRUE(request->load_flags() & LOAD_DISABLE_CERT_REVOCATION_CHECKING);
50 return NULL;
51 }
52
53 virtual URLRequestJob* MaybeInterceptRedirect(const GURL& location,
54 URLRequest* request) const {
55 return NULL;
56 }
57
58 virtual URLRequestJob* MaybeInterceptResponse(URLRequest* request) const {
59 return NULL;
60 }
61 };
62
41 // A non-mock URL request which can access http:// and file:// urls. 63 // A non-mock URL request which can access http:// and file:// urls.
42 class RequestContext : public URLRequestContext { 64 class RequestContext : public URLRequestContext {
43 public: 65 public:
44 RequestContext() : ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) { 66 RequestContext() : ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) {
45 ProxyConfig no_proxy; 67 ProxyConfig no_proxy;
46 storage_.set_host_resolver( 68 storage_.set_host_resolver(
47 CreateSystemHostResolver(HostResolver::kDefaultParallelism, 69 CreateSystemHostResolver(HostResolver::kDefaultParallelism,
48 HostResolver::kDefaultRetryAttempts, 70 HostResolver::kDefaultRetryAttempts,
49 NULL)); 71 NULL));
50 storage_.set_cert_verifier(new CertVerifier); 72 storage_.set_cert_verifier(new CertVerifier);
51 storage_.set_proxy_service(ProxyService::CreateFixed(no_proxy)); 73 storage_.set_proxy_service(ProxyService::CreateFixed(no_proxy));
52 storage_.set_ssl_config_service(new SSLConfigServiceDefaults); 74 storage_.set_ssl_config_service(new SSLConfigServiceDefaults);
53 75
54 HttpNetworkSession::Params params; 76 HttpNetworkSession::Params params;
55 params.host_resolver = host_resolver(); 77 params.host_resolver = host_resolver();
56 params.cert_verifier = cert_verifier(); 78 params.cert_verifier = cert_verifier();
57 params.proxy_service = proxy_service(); 79 params.proxy_service = proxy_service();
58 params.ssl_config_service = ssl_config_service(); 80 params.ssl_config_service = ssl_config_service();
59 scoped_refptr<HttpNetworkSession> network_session( 81 scoped_refptr<HttpNetworkSession> network_session(
60 new HttpNetworkSession(params)); 82 new HttpNetworkSession(params));
61 storage_.set_http_transaction_factory(new HttpCache( 83 storage_.set_http_transaction_factory(new HttpCache(
62 network_session, 84 network_session,
63 HttpCache::DefaultBackend::InMemory(0))); 85 HttpCache::DefaultBackend::InMemory(0)));
86 url_request_job_factory_.reset(new URLRequestJobFactory);
87 set_job_factory(url_request_job_factory_.get());
88 url_request_job_factory_->AddInterceptor(
89 new CheckNoRevocationFlagSetInterceptor);
64 } 90 }
65 91
66 private: 92 private:
67 ~RequestContext() { 93 ~RequestContext() {
68 } 94 }
69 95
70 URLRequestContextStorage storage_; 96 URLRequestContextStorage storage_;
97 scoped_ptr<URLRequestJobFactory> url_request_job_factory_;
71 }; 98 };
72 99
73 // Get a file:// url relative to net/data/proxy/proxy_script_fetcher_unittest. 100 // Get a file:// url relative to net/data/proxy/proxy_script_fetcher_unittest.
74 GURL GetTestFileUrl(const std::string& relpath) { 101 GURL GetTestFileUrl(const std::string& relpath) {
75 FilePath path; 102 FilePath path;
76 PathService::Get(base::DIR_SOURCE_ROOT, &path); 103 PathService::Get(base::DIR_SOURCE_ROOT, &path);
77 path = path.AppendASCII("net"); 104 path = path.AppendASCII("net");
78 path = path.AppendASCII("data"); 105 path = path.AppendASCII("data");
79 path = path.AppendASCII("proxy_script_fetcher_unittest"); 106 path = path.AppendASCII("proxy_script_fetcher_unittest");
80 GURL base_url = FilePathToFileURL(path); 107 GURL base_url = FilePathToFileURL(path);
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 { 401 {
375 GURL url(kEncodedUrlBroken); 402 GURL url(kEncodedUrlBroken);
376 string16 text; 403 string16 text;
377 TestCompletionCallback callback; 404 TestCompletionCallback callback;
378 int result = pac_fetcher.Fetch(url, &text, &callback); 405 int result = pac_fetcher.Fetch(url, &text, &callback);
379 EXPECT_EQ(ERR_FAILED, result); 406 EXPECT_EQ(ERR_FAILED, result);
380 } 407 }
381 } 408 }
382 409
383 } // namespace net 410 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_script_fetcher_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698