OLD | NEW |
---|---|
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 void FailTest(int /* result */) { | 28 void FailTest(int /* result */) { |
28 FAIL(); | 29 FAIL(); |
29 } | 30 } |
31 #endif // !defined(USE_OPENSSL) | |
30 | 32 |
31 // Simple task runner that refuses to actually post any tasks. This simulates | 33 // Simple task runner that refuses to actually post any tasks. This simulates |
32 // a TaskRunner that has been shutdown, by returning false for any attempt to | 34 // a TaskRunner that has been shutdown, by returning false for any attempt to |
33 // add new tasks. | 35 // add new tasks. |
34 class FailingTaskRunner : public base::TaskRunner { | 36 class FailingTaskRunner : public base::TaskRunner { |
35 public: | 37 public: |
36 FailingTaskRunner() {} | 38 FailingTaskRunner() {} |
37 | 39 |
38 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | 40 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, |
39 const base::Closure& task, | 41 const base::Closure& task, |
40 base::TimeDelta delay) OVERRIDE { | 42 base::TimeDelta delay) OVERRIDE { |
41 return false; | 43 return false; |
42 } | 44 } |
43 | 45 |
44 virtual bool RunsTasksOnCurrentThread() const OVERRIDE { return true; } | 46 virtual bool RunsTasksOnCurrentThread() const OVERRIDE { return true; } |
45 | 47 |
46 protected: | 48 protected: |
47 virtual ~FailingTaskRunner() {} | 49 virtual ~FailingTaskRunner() {} |
48 | 50 |
49 private: | 51 private: |
50 DISALLOW_COPY_AND_ASSIGN(FailingTaskRunner); | 52 DISALLOW_COPY_AND_ASSIGN(FailingTaskRunner); |
51 }; | 53 }; |
52 | 54 |
53 class ServerBoundCertServiceTest : public testing::Test { | 55 class ServerBoundCertServiceTest : public testing::Test { |
Nico
2013/11/10 05:07:09
optional: If you move this class to line 119, ever
hans
2013/11/11 19:29:51
Done.
| |
54 public: | 56 public: |
55 ServerBoundCertServiceTest() | 57 ServerBoundCertServiceTest() |
56 : service_(new ServerBoundCertService( | 58 : service_(new ServerBoundCertService( |
57 new DefaultServerBoundCertStore(NULL), | 59 new DefaultServerBoundCertStore(NULL), |
58 base::MessageLoopProxy::current())) { | 60 base::MessageLoopProxy::current())) { |
59 } | 61 } |
60 | 62 |
61 protected: | 63 protected: |
62 scoped_ptr<ServerBoundCertService> service_; | 64 scoped_ptr<ServerBoundCertService> service_; |
63 }; | 65 }; |
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
770 EXPECT_EQ(private_key1, private_key2); | 772 EXPECT_EQ(private_key1, private_key2); |
771 EXPECT_FALSE(request_handle1.is_active()); | 773 EXPECT_FALSE(request_handle1.is_active()); |
772 EXPECT_FALSE(request_handle2.is_active()); | 774 EXPECT_FALSE(request_handle2.is_active()); |
773 } | 775 } |
774 | 776 |
775 #endif // !defined(USE_OPENSSL) | 777 #endif // !defined(USE_OPENSSL) |
776 | 778 |
777 } // namespace | 779 } // namespace |
778 | 780 |
779 } // namespace net | 781 } // namespace net |
OLD | NEW |