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

Unified Diff: net/test/url_request/url_request_mock_data_job.cc

Issue 1459993003: [Cronet] Continue UrlRequest with NULL certificate if Client cert is requested. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Helen's comments. Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/test/url_request/url_request_mock_data_job.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/test/url_request/url_request_mock_data_job.cc
diff --git a/net/test/url_request/url_request_mock_data_job.cc b/net/test/url_request/url_request_mock_data_job.cc
index b9ef385bcd2d54ba8c1f9d2f648f41a84cab5056..3b3f9d36e756efd42208fe92209f1f575cfc4014 100644
--- a/net/test/url_request/url_request_mock_data_job.cc
+++ b/net/test/url_request/url_request_mock_data_job.cc
@@ -15,6 +15,7 @@
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
+#include "net/ssl/ssl_cert_request_info.h"
#include "net/url_request/url_request_filter.h"
namespace net {
@@ -47,16 +48,25 @@ int GetRepeatCountFromRequest(const URLRequest& request) {
return repeat_count;
}
+// Gets the requestcert flag from URL.
+bool GetRequestClientCertificate(const URLRequest& request) {
+ std::string ignored_value;
+ return GetValueForKeyInQuery(request.url(), "requestcert", &ignored_value);
+}
+
GURL GetMockUrl(const std::string& scheme,
const std::string& hostname,
const std::string& data,
- int data_repeat_count) {
+ int data_repeat_count,
+ bool request_client_certificate) {
DCHECK_GT(data_repeat_count, 0);
std::string url(scheme + "://" + hostname + "/");
url.append("?data=");
url.append(data);
url.append("&repeat=");
url.append(base::IntToString(data_repeat_count));
+ if (request_client_certificate)
+ url += "&requestcert=1";
return GURL(url);
}
@@ -71,7 +81,8 @@ class MockJobInterceptor : public URLRequestInterceptor {
NetworkDelegate* network_delegate) const override {
return new URLRequestMockDataJob(request, network_delegate,
GetDataFromRequest(*request),
- GetRepeatCountFromRequest(*request));
+ GetRepeatCountFromRequest(*request),
+ GetRequestClientCertificate(*request));
}
private:
@@ -83,9 +94,11 @@ class MockJobInterceptor : public URLRequestInterceptor {
URLRequestMockDataJob::URLRequestMockDataJob(URLRequest* request,
NetworkDelegate* network_delegate,
const std::string& data,
- int data_repeat_count)
+ int data_repeat_count,
+ bool request_client_certificate)
: URLRequestJob(request, network_delegate),
data_offset_(0),
+ request_client_certificate_(request_client_certificate),
weak_factory_(this) {
DCHECK_GT(data_repeat_count, 0);
for (int i = 0; i < data_repeat_count; ++i) {
@@ -118,6 +131,13 @@ int URLRequestMockDataJob::GetResponseCode() const {
return info.headers->response_code();
}
+void URLRequestMockDataJob::ContinueWithCertificate(
+ X509Certificate* client_cert,
+ SSLPrivateKey* client_private_key) {
+ DCHECK(request_client_certificate_);
+ NotifyHeadersComplete();
+}
+
// Public virtual version.
void URLRequestMockDataJob::GetResponseInfo(HttpResponseInfo* info) {
// Forward to private const version.
@@ -142,6 +162,11 @@ void URLRequestMockDataJob::StartAsync() {
return;
set_expected_content_size(data_.length());
+ if (request_client_certificate_) {
+ scoped_refptr<SSLCertRequestInfo> request_all(new SSLCertRequestInfo());
+ NotifyCertificateRequested(request_all.get());
+ return;
+ }
NotifyHeadersComplete();
}
@@ -173,12 +198,16 @@ GURL URLRequestMockDataJob::GetMockHttpsUrl(const std::string& data,
return GetMockHttpsUrlForHostname(kMockHostname, data, repeat_count);
}
+GURL URLRequestMockDataJob::GetMockUrlForClientCertificateRequest() {
+ return GetMockUrl("https", kMockHostname, "data", 1, true);
+}
+
// static
GURL URLRequestMockDataJob::GetMockHttpUrlForHostname(
const std::string& hostname,
const std::string& data,
int repeat_count) {
- return GetMockUrl("http", hostname, data, repeat_count);
+ return GetMockUrl("http", hostname, data, repeat_count, false);
}
// static
@@ -186,7 +215,7 @@ GURL URLRequestMockDataJob::GetMockHttpsUrlForHostname(
const std::string& hostname,
const std::string& data,
int repeat_count) {
- return GetMockUrl("https", hostname, data, repeat_count);
+ return GetMockUrl("https", hostname, data, repeat_count, false);
}
} // namespace net
« no previous file with comments | « net/test/url_request/url_request_mock_data_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698