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

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 3812007: Support restriction the TLS cipher selection in test_server.py (Closed)
Patch Set: Rebase to trunk Created 10 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 unified diff | Download patch
« no previous file with comments | « net/tools/testserver/testserver.py ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/url_request/url_request_unittest.h" 5 #include "net/url_request/url_request_unittest.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <shlobj.h> 10 #include <shlobj.h>
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 MessageLoop::current()->Run(); 303 MessageLoop::current()->Run();
304 304
305 EXPECT_EQ(1, d.response_started_count()); 305 EXPECT_EQ(1, d.response_started_count());
306 EXPECT_FALSE(d.received_data_before_response()); 306 EXPECT_FALSE(d.received_data_before_response());
307 EXPECT_NE(0, d.bytes_received()); 307 EXPECT_NE(0, d.bytes_received());
308 CheckSSLInfo(r.ssl_info()); 308 CheckSSLInfo(r.ssl_info());
309 } 309 }
310 } 310 }
311 311
312 TEST_F(HTTPSRequestTest, HTTPSMismatchedTest) { 312 TEST_F(HTTPSRequestTest, HTTPSMismatchedTest) {
313 net::TestServer test_server(net::TestServer::TYPE_HTTPS_MISMATCHED_HOSTNAME, 313 net::TestServer::HTTPSOptions https_options(
314 net::TestServer::HTTPSOptions::CERT_MISMATCHED_NAME);
315 net::TestServer test_server(https_options,
314 FilePath(FILE_PATH_LITERAL("net/data/ssl"))); 316 FilePath(FILE_PATH_LITERAL("net/data/ssl")));
315 ASSERT_TRUE(test_server.Start()); 317 ASSERT_TRUE(test_server.Start());
316 318
317 bool err_allowed = true; 319 bool err_allowed = true;
318 for (int i = 0; i < 2 ; i++, err_allowed = !err_allowed) { 320 for (int i = 0; i < 2 ; i++, err_allowed = !err_allowed) {
319 TestDelegate d; 321 TestDelegate d;
320 { 322 {
321 d.set_allow_certificate_errors(err_allowed); 323 d.set_allow_certificate_errors(err_allowed);
322 TestURLRequest r(test_server.GetURL(""), &d); 324 TestURLRequest r(test_server.GetURL(""), &d);
323 325
324 r.Start(); 326 r.Start();
325 EXPECT_TRUE(r.is_pending()); 327 EXPECT_TRUE(r.is_pending());
326 328
327 MessageLoop::current()->Run(); 329 MessageLoop::current()->Run();
328 330
329 EXPECT_EQ(1, d.response_started_count()); 331 EXPECT_EQ(1, d.response_started_count());
330 EXPECT_FALSE(d.received_data_before_response()); 332 EXPECT_FALSE(d.received_data_before_response());
331 EXPECT_TRUE(d.have_certificate_errors()); 333 EXPECT_TRUE(d.have_certificate_errors());
332 if (err_allowed) { 334 if (err_allowed) {
333 EXPECT_NE(0, d.bytes_received()); 335 EXPECT_NE(0, d.bytes_received());
334 CheckSSLInfo(r.ssl_info()); 336 CheckSSLInfo(r.ssl_info());
335 } else { 337 } else {
336 EXPECT_EQ(0, d.bytes_received()); 338 EXPECT_EQ(0, d.bytes_received());
337 } 339 }
338 } 340 }
339 } 341 }
340 } 342 }
341 343
342 TEST_F(HTTPSRequestTest, HTTPSExpiredTest) { 344 TEST_F(HTTPSRequestTest, HTTPSExpiredTest) {
343 net::TestServer test_server(net::TestServer::TYPE_HTTPS_EXPIRED_CERTIFICATE, 345 net::TestServer::HTTPSOptions https_options(
346 net::TestServer::HTTPSOptions::CERT_EXPIRED);
347 net::TestServer test_server(https_options,
344 FilePath(FILE_PATH_LITERAL("net/data/ssl"))); 348 FilePath(FILE_PATH_LITERAL("net/data/ssl")));
345 ASSERT_TRUE(test_server.Start()); 349 ASSERT_TRUE(test_server.Start());
346 350
347 // Iterate from false to true, just so that we do the opposite of the 351 // Iterate from false to true, just so that we do the opposite of the
348 // previous test in order to increase test coverage. 352 // previous test in order to increase test coverage.
349 bool err_allowed = false; 353 bool err_allowed = false;
350 for (int i = 0; i < 2 ; i++, err_allowed = !err_allowed) { 354 for (int i = 0; i < 2 ; i++, err_allowed = !err_allowed) {
351 TestDelegate d; 355 TestDelegate d;
352 { 356 {
353 d.set_allow_certificate_errors(err_allowed); 357 d.set_allow_certificate_errors(err_allowed);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 }; 395 };
392 396
393 } // namespace 397 } // namespace
394 398
395 // TODO(davidben): Test the rest of the code. Specifically, 399 // TODO(davidben): Test the rest of the code. Specifically,
396 // - Filtering which certificates to select. 400 // - Filtering which certificates to select.
397 // - Sending a certificate back. 401 // - Sending a certificate back.
398 // - Getting a certificate request in an SSL renegotiation sending the 402 // - Getting a certificate request in an SSL renegotiation sending the
399 // HTTP request. 403 // HTTP request.
400 TEST_F(HTTPSRequestTest, ClientAuthTest) { 404 TEST_F(HTTPSRequestTest, ClientAuthTest) {
401 net::TestServer test_server(net::TestServer::TYPE_HTTPS_CLIENT_AUTH, 405 net::TestServer::HTTPSOptions https_options;
406 https_options.request_client_certificate = true;
407 net::TestServer test_server(https_options,
402 FilePath(FILE_PATH_LITERAL("net/data/ssl"))); 408 FilePath(FILE_PATH_LITERAL("net/data/ssl")));
403 ASSERT_TRUE(test_server.Start()); 409 ASSERT_TRUE(test_server.Start());
404 410
405 SSLClientAuthTestDelegate d; 411 SSLClientAuthTestDelegate d;
406 { 412 {
407 TestURLRequest r(test_server.GetURL(""), &d); 413 TestURLRequest r(test_server.GetURL(""), &d);
408 414
409 r.Start(); 415 r.Start();
410 EXPECT_TRUE(r.is_pending()); 416 EXPECT_TRUE(r.is_pending());
411 417
(...skipping 2213 matching lines...) Expand 10 before | Expand all | Expand 10 after
2625 TestURLRequest 2631 TestURLRequest
2626 req(test_server_.GetURL("echoheaderoverride?Accept-Charset"), &d); 2632 req(test_server_.GetURL("echoheaderoverride?Accept-Charset"), &d);
2627 req.set_context(new TestURLRequestContext()); 2633 req.set_context(new TestURLRequestContext());
2628 net::HttpRequestHeaders headers; 2634 net::HttpRequestHeaders headers;
2629 headers.SetHeader(net::HttpRequestHeaders::kAcceptCharset, "koi-8r"); 2635 headers.SetHeader(net::HttpRequestHeaders::kAcceptCharset, "koi-8r");
2630 req.SetExtraRequestHeaders(headers); 2636 req.SetExtraRequestHeaders(headers);
2631 req.Start(); 2637 req.Start();
2632 MessageLoop::current()->Run(); 2638 MessageLoop::current()->Run();
2633 EXPECT_EQ(std::string("koi-8r"), d.data_received()); 2639 EXPECT_EQ(std::string("koi-8r"), d.data_received());
2634 } 2640 }
OLDNEW
« no previous file with comments | « net/tools/testserver/testserver.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698