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

Side by Side Diff: net/ssl/server_bound_cert_service_unittest.cc

Issue 206453002: Introduce USE_OPENSSL_CERTS for certificate handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ssl/server_bound_cert_service.h" 5 #include "net/ssl/server_bound_cert_service.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/message_loop/message_loop_proxy.h" 13 #include "base/message_loop/message_loop_proxy.h"
14 #include "base/task_runner.h" 14 #include "base/task_runner.h"
15 #include "crypto/ec_private_key.h" 15 #include "crypto/ec_private_key.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/base/test_completion_callback.h" 17 #include "net/base/test_completion_callback.h"
18 #include "net/cert/asn1_util.h" 18 #include "net/cert/asn1_util.h"
19 #include "net/cert/x509_certificate.h" 19 #include "net/cert/x509_certificate.h"
20 #include "net/ssl/default_server_bound_cert_store.h" 20 #include "net/ssl/default_server_bound_cert_store.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 namespace net { 23 namespace net {
24 24
25 namespace { 25 namespace {
26 26
27 #if !defined(USE_OPENSSL) 27 #if !defined(USE_OPENSSL_CERTS) && !defined(OS_ANDROID)
28 void FailTest(int /* result */) { 28 void FailTest(int /* result */) {
29 FAIL(); 29 FAIL();
30 } 30 }
31 31
32 // Simple task runner that refuses to actually post any tasks. This simulates 32 // Simple task runner that refuses to actually post any tasks. This simulates
33 // a TaskRunner that has been shutdown, by returning false for any attempt to 33 // a TaskRunner that has been shutdown, by returning false for any attempt to
34 // add new tasks. 34 // add new tasks.
35 class FailingTaskRunner : public base::TaskRunner { 35 class FailingTaskRunner : public base::TaskRunner {
36 public: 36 public:
37 FailingTaskRunner() {} 37 FailingTaskRunner() {}
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 cert_count_ = 1; 110 cert_count_ = 1;
111 base::MessageLoop::current()->PostTask(FROM_HERE, 111 base::MessageLoop::current()->PostTask(FROM_HERE,
112 base::Bind(callback_, 112 base::Bind(callback_,
113 err, 113 err,
114 server_identifier_, 114 server_identifier_,
115 expiration_time, 115 expiration_time,
116 private_key, 116 private_key,
117 cert)); 117 cert));
118 } 118 }
119 119
120 #endif // !defined(USE_OPENSSL) 120 #endif // !defined(USE_OPENSSL_CERTS) && !defined(OS_ANDROID)
121 121
122 class ServerBoundCertServiceTest : public testing::Test { 122 class ServerBoundCertServiceTest : public testing::Test {
123 public: 123 public:
124 ServerBoundCertServiceTest() 124 ServerBoundCertServiceTest()
125 : service_(new ServerBoundCertService( 125 : service_(new ServerBoundCertService(
126 new DefaultServerBoundCertStore(NULL), 126 new DefaultServerBoundCertStore(NULL),
127 base::MessageLoopProxy::current())) { 127 base::MessageLoopProxy::current())) {
128 } 128 }
129 129
130 protected: 130 protected:
(...skipping 13 matching lines...) Expand all
144 ServerBoundCertService::GetDomainForHost("appspot.com")); 144 ServerBoundCertService::GetDomainForHost("appspot.com"));
145 EXPECT_EQ("google.com", 145 EXPECT_EQ("google.com",
146 ServerBoundCertService::GetDomainForHost("www.mail.google.com")); 146 ServerBoundCertService::GetDomainForHost("www.mail.google.com"));
147 EXPECT_EQ("goto", 147 EXPECT_EQ("goto",
148 ServerBoundCertService::GetDomainForHost("goto")); 148 ServerBoundCertService::GetDomainForHost("goto"));
149 EXPECT_EQ("127.0.0.1", 149 EXPECT_EQ("127.0.0.1",
150 ServerBoundCertService::GetDomainForHost("127.0.0.1")); 150 ServerBoundCertService::GetDomainForHost("127.0.0.1"));
151 } 151 }
152 152
153 // See http://crbug.com/91512 - implement OpenSSL version of CreateSelfSigned. 153 // See http://crbug.com/91512 - implement OpenSSL version of CreateSelfSigned.
154 #if !defined(USE_OPENSSL) 154 #if !defined(USE_OPENSSL_CERTS) && !defined(OS_ANDROID)
mattm 2014/03/20 23:40:24 It looks like crbug.com/91512 was fixed. Can these
haavardm 2014/03/21 13:08:21 Thanks, I wasn't aware of that. I'll try to remove
155 155
156 TEST_F(ServerBoundCertServiceTest, GetCacheMiss) { 156 TEST_F(ServerBoundCertServiceTest, GetCacheMiss) {
157 std::string host("encrypted.google.com"); 157 std::string host("encrypted.google.com");
158 158
159 int error; 159 int error;
160 TestCompletionCallback callback; 160 TestCompletionCallback callback;
161 ServerBoundCertService::RequestHandle request_handle; 161 ServerBoundCertService::RequestHandle request_handle;
162 162
163 // Synchronous completion, because the store is initialized. 163 // Synchronous completion, because the store is initialized.
164 std::string private_key, der_cert; 164 std::string private_key, der_cert;
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 EXPECT_EQ(1u, service_->workers_created()); 768 EXPECT_EQ(1u, service_->workers_created());
769 EXPECT_EQ(1u, service_->inflight_joins()); 769 EXPECT_EQ(1u, service_->inflight_joins());
770 EXPECT_FALSE(der_cert1.empty()); 770 EXPECT_FALSE(der_cert1.empty());
771 EXPECT_EQ(der_cert1, der_cert2); 771 EXPECT_EQ(der_cert1, der_cert2);
772 EXPECT_FALSE(private_key1.empty()); 772 EXPECT_FALSE(private_key1.empty());
773 EXPECT_EQ(private_key1, private_key2); 773 EXPECT_EQ(private_key1, private_key2);
774 EXPECT_FALSE(request_handle1.is_active()); 774 EXPECT_FALSE(request_handle1.is_active());
775 EXPECT_FALSE(request_handle2.is_active()); 775 EXPECT_FALSE(request_handle2.is_active());
776 } 776 }
777 777
778 #endif // !defined(USE_OPENSSL) 778 #endif // !defined(USE_OPENSSL_CERTS) && !defined(OS_ANDROID)
779 779
780 } // namespace 780 } // namespace
781 781
782 } // namespace net 782 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698