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

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

Issue 2294373002: Certificate Transparency: Remove the obsolete invalid sct status. (Closed)
Patch Set: Use uint32_t as enum base Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_response_info.h" 5 #include "net/http/http_response_info.h"
6 6
7 #include "base/pickle.h" 7 #include "base/pickle.h"
8 #include "net/cert/signed_certificate_timestamp.h"
9 #include "net/cert/signed_certificate_timestamp_and_status.h"
8 #include "net/http/http_response_headers.h" 10 #include "net/http/http_response_headers.h"
11 #include "net/test/ct_test_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
10 13
11 namespace net { 14 namespace net {
12 15
13 namespace { 16 namespace {
14 17
15 class HttpResponseInfoTest : public testing::Test { 18 class HttpResponseInfoTest : public testing::Test {
16 protected: 19 protected:
17 void SetUp() override { 20 void SetUp() override {
18 response_info_.headers = new HttpResponseHeaders(""); 21 response_info_.headers = new HttpResponseHeaders("");
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 EXPECT_TRUE(response_info_clone.async_revalidation_required); 86 EXPECT_TRUE(response_info_clone.async_revalidation_required);
84 } 87 }
85 88
86 TEST_F(HttpResponseInfoTest, AsyncRevalidationRequiredNotPersisted) { 89 TEST_F(HttpResponseInfoTest, AsyncRevalidationRequiredNotPersisted) {
87 response_info_.async_revalidation_required = true; 90 response_info_.async_revalidation_required = true;
88 net::HttpResponseInfo restored_response_info; 91 net::HttpResponseInfo restored_response_info;
89 PickleAndRestore(response_info_, &restored_response_info); 92 PickleAndRestore(response_info_, &restored_response_info);
90 EXPECT_FALSE(restored_response_info.async_revalidation_required); 93 EXPECT_FALSE(restored_response_info.async_revalidation_required);
91 } 94 }
92 95
96 TEST_F(HttpResponseInfoTest, FailsInitFromPickleWithInvalidSCTStatus) {
97 // A valid certificate is needed for ssl_info.is_valid() to be true
98 // so that the SCTs would be serialized.
99 const std::string der_test_cert(net::ct::GetDerEncodedX509Cert());
100 response_info_.ssl_info.cert = net::X509Certificate::CreateFromBytes(
101 der_test_cert.data(), der_test_cert.length());
102
103 scoped_refptr<ct::SignedCertificateTimestamp> sct;
104 ct::GetX509CertSCT(&sct);
105
106 response_info_.ssl_info.signed_certificate_timestamps.push_back(
107 SignedCertificateTimestampAndStatus(
108 sct, ct::SCTVerifyStatus::SCT_STATUS_LOG_UNKNOWN));
109
110 base::Pickle pickle;
111 response_info_.Persist(&pickle, false, false);
112 bool truncated = false;
113 net::HttpResponseInfo restored_response_info;
114 EXPECT_TRUE(restored_response_info.InitFromPickle(pickle, &truncated));
115
116 response_info_.ssl_info.signed_certificate_timestamps.push_back(
117 SignedCertificateTimestampAndStatus(sct,
118 static_cast<ct::SCTVerifyStatus>(2)));
119 base::Pickle pickle_invalid;
120 response_info_.Persist(&pickle_invalid, false, false);
121 net::HttpResponseInfo restored_invalid_response;
122 EXPECT_FALSE(
123 restored_invalid_response.InitFromPickle(pickle_invalid, &truncated));
124 }
125
93 } // namespace 126 } // namespace
94 127
95 } // namespace net 128 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_response_info.cc ('k') | net/net.gypi » ('j') | net/net.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698