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

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 7969023: For the SSL cert status, convert anonymous enum that gives bit values into a typedefed uint32. Th... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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/base/x509_certificate_win.cc ('k') | net/http/http_response_info.cc » ('j') | 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/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 4209 matching lines...) Expand 10 before | Expand all | Expand 10 after
4220 new HttpNetworkTransaction(CreateSession(&session_deps))); 4220 new HttpNetworkTransaction(CreateSession(&session_deps)));
4221 4221
4222 // Setup some state (which we expect ResetStateForRestart() will clear). 4222 // Setup some state (which we expect ResetStateForRestart() will clear).
4223 trans->read_buf_ = new IOBuffer(15); 4223 trans->read_buf_ = new IOBuffer(15);
4224 trans->read_buf_len_ = 15; 4224 trans->read_buf_len_ = 15;
4225 trans->request_headers_.SetHeader("Authorization", "NTLM"); 4225 trans->request_headers_.SetHeader("Authorization", "NTLM");
4226 4226
4227 // Setup state in response_ 4227 // Setup state in response_
4228 HttpResponseInfo* response = &trans->response_; 4228 HttpResponseInfo* response = &trans->response_;
4229 response->auth_challenge = new AuthChallengeInfo(); 4229 response->auth_challenge = new AuthChallengeInfo();
4230 response->ssl_info.cert_status = -15; 4230 response->ssl_info.cert_status = static_cast<CertStatus>(-1); // Nonsensical.
4231 response->response_time = base::Time::Now(); 4231 response->response_time = base::Time::Now();
4232 response->was_cached = true; // (Wouldn't ever actually be true...) 4232 response->was_cached = true; // (Wouldn't ever actually be true...)
4233 4233
4234 { // Setup state for response_.vary_data 4234 { // Setup state for response_.vary_data
4235 HttpRequestInfo request; 4235 HttpRequestInfo request;
4236 std::string temp("HTTP/1.1 200 OK\nVary: foo, bar\n\n"); 4236 std::string temp("HTTP/1.1 200 OK\nVary: foo, bar\n\n");
4237 std::replace(temp.begin(), temp.end(), '\n', '\0'); 4237 std::replace(temp.begin(), temp.end(), '\n', '\0');
4238 scoped_refptr<HttpResponseHeaders> headers(new HttpResponseHeaders(temp)); 4238 scoped_refptr<HttpResponseHeaders> headers(new HttpResponseHeaders(temp));
4239 request.extra_headers.SetHeader("Foo", "1"); 4239 request.extra_headers.SetHeader("Foo", "1");
4240 request.extra_headers.SetHeader("bar", "23"); 4240 request.extra_headers.SetHeader("bar", "23");
4241 EXPECT_TRUE(response->vary_data.Init(request, *headers)); 4241 EXPECT_TRUE(response->vary_data.Init(request, *headers));
4242 } 4242 }
4243 4243
4244 // Cause the above state to be reset. 4244 // Cause the above state to be reset.
4245 trans->ResetStateForRestart(); 4245 trans->ResetStateForRestart();
4246 4246
4247 // Verify that the state that needed to be reset, has been reset. 4247 // Verify that the state that needed to be reset, has been reset.
4248 EXPECT_TRUE(trans->read_buf_.get() == NULL); 4248 EXPECT_TRUE(trans->read_buf_.get() == NULL);
4249 EXPECT_EQ(0, trans->read_buf_len_); 4249 EXPECT_EQ(0, trans->read_buf_len_);
4250 EXPECT_TRUE(trans->request_headers_.IsEmpty()); 4250 EXPECT_TRUE(trans->request_headers_.IsEmpty());
4251 EXPECT_TRUE(response->auth_challenge.get() == NULL); 4251 EXPECT_TRUE(response->auth_challenge.get() == NULL);
4252 EXPECT_TRUE(response->headers.get() == NULL); 4252 EXPECT_TRUE(response->headers.get() == NULL);
4253 EXPECT_FALSE(response->was_cached); 4253 EXPECT_FALSE(response->was_cached);
4254 EXPECT_EQ(0, response->ssl_info.cert_status); 4254 EXPECT_EQ(0U, response->ssl_info.cert_status);
4255 EXPECT_FALSE(response->vary_data.is_valid()); 4255 EXPECT_FALSE(response->vary_data.is_valid());
4256 } 4256 }
4257 4257
4258 // Test HTTPS connections to a site with a bad certificate 4258 // Test HTTPS connections to a site with a bad certificate
4259 TEST_F(HttpNetworkTransactionTest, HTTPSBadCertificate) { 4259 TEST_F(HttpNetworkTransactionTest, HTTPSBadCertificate) {
4260 HttpRequestInfo request; 4260 HttpRequestInfo request;
4261 request.method = "GET"; 4261 request.method = "GET";
4262 request.url = GURL("https://www.google.com/"); 4262 request.url = GURL("https://www.google.com/");
4263 request.load_flags = 0; 4263 request.load_flags = 0;
4264 4264
(...skipping 4633 matching lines...) Expand 10 before | Expand all | Expand 10 after
8898 EXPECT_TRUE(response->was_fetched_via_spdy); 8898 EXPECT_TRUE(response->was_fetched_via_spdy);
8899 EXPECT_TRUE(response->was_npn_negotiated); 8899 EXPECT_TRUE(response->was_npn_negotiated);
8900 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data)); 8900 ASSERT_EQ(OK, ReadTransaction(&trans2, &response_data));
8901 EXPECT_EQ("hello!", response_data); 8901 EXPECT_EQ("hello!", response_data);
8902 8902
8903 HttpStreamFactory::set_next_protos(""); 8903 HttpStreamFactory::set_next_protos("");
8904 HttpStreamFactory::set_use_alternate_protocols(false); 8904 HttpStreamFactory::set_use_alternate_protocols(false);
8905 } 8905 }
8906 8906
8907 } // namespace net 8907 } // namespace net
OLDNEW
« no previous file with comments | « net/base/x509_certificate_win.cc ('k') | net/http/http_response_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698