OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 static void TearDownTestCase() { | 76 static void TearDownTestCase() { |
77 rtc::CleanupSSL(); | 77 rtc::CleanupSSL(); |
78 } | 78 } |
79 | 79 |
80 rtc::scoped_ptr<rtc::Thread> worker_thread_; | 80 rtc::scoped_ptr<rtc::Thread> worker_thread_; |
81 rtc::scoped_ptr<DtlsIdentityStoreImpl> store_; | 81 rtc::scoped_ptr<DtlsIdentityStoreImpl> store_; |
82 rtc::scoped_refptr<MockDtlsIdentityRequestObserver> observer_; | 82 rtc::scoped_refptr<MockDtlsIdentityRequestObserver> observer_; |
83 }; | 83 }; |
84 | 84 |
85 TEST_F(DtlsIdentityStoreTest, RequestIdentitySuccessRSA) { | 85 TEST_F(DtlsIdentityStoreTest, RequestIdentitySuccessRSA) { |
86 EXPECT_TRUE_WAIT(store_->HasFreeIdentityForTesting(rtc::KT_RSA), kTimeoutMs); | |
87 | |
88 store_->RequestIdentity(rtc::KeyParams(rtc::KT_RSA), | 86 store_->RequestIdentity(rtc::KeyParams(rtc::KT_RSA), |
89 rtc::Optional<uint64_t>(), | 87 rtc::Optional<uint64_t>(), |
90 observer_.get()); | 88 observer_.get()); |
91 EXPECT_TRUE_WAIT(observer_->LastRequestSucceeded(), kTimeoutMs); | 89 EXPECT_TRUE_WAIT(observer_->LastRequestSucceeded(), kTimeoutMs); |
92 | 90 |
93 EXPECT_TRUE_WAIT(store_->HasFreeIdentityForTesting(rtc::KT_RSA), kTimeoutMs); | 91 EXPECT_TRUE_WAIT(store_->HasFreeIdentityForTesting(rtc::KT_RSA), kTimeoutMs); |
94 | 92 |
95 observer_->Reset(); | 93 observer_->Reset(); |
96 | 94 |
97 // Verifies that the callback is async when a free identity is ready. | 95 // Verifies that the callback is async when a free identity is ready. |
98 store_->RequestIdentity(rtc::KeyParams(rtc::KT_RSA), | 96 store_->RequestIdentity(rtc::KeyParams(rtc::KT_RSA), |
99 rtc::Optional<uint64_t>(), | 97 rtc::Optional<uint64_t>(), |
100 observer_.get()); | 98 observer_.get()); |
101 EXPECT_FALSE(observer_->call_back_called()); | 99 EXPECT_FALSE(observer_->call_back_called()); |
102 EXPECT_TRUE_WAIT(observer_->LastRequestSucceeded(), kTimeoutMs); | 100 EXPECT_TRUE_WAIT(observer_->LastRequestSucceeded(), kTimeoutMs); |
103 } | 101 } |
104 | 102 |
105 TEST_F(DtlsIdentityStoreTest, RequestIdentitySuccessECDSA) { | 103 TEST_F(DtlsIdentityStoreTest, RequestIdentitySuccessECDSA) { |
106 // Since store currently does not preemptively generate free ECDSA identities | |
107 // we do not invoke HasFreeIdentityForTesting between requests. | |
108 | |
109 store_->RequestIdentity(rtc::KeyParams(rtc::KT_ECDSA), | 104 store_->RequestIdentity(rtc::KeyParams(rtc::KT_ECDSA), |
110 rtc::Optional<uint64_t>(), | 105 rtc::Optional<uint64_t>(), |
111 observer_.get()); | 106 observer_.get()); |
112 EXPECT_TRUE_WAIT(observer_->LastRequestSucceeded(), kTimeoutMs); | 107 EXPECT_TRUE_WAIT(observer_->LastRequestSucceeded(), kTimeoutMs); |
113 | 108 |
| 109 // Since store currently does not preemptively generate free ECDSA identities |
| 110 // we do not invoke HasFreeIdentityForTesting between requests. |
| 111 |
114 observer_->Reset(); | 112 observer_->Reset(); |
115 | 113 |
116 // Verifies that the callback is async when a free identity is ready. | 114 // Verifies that the callback is async when a free identity is ready. |
117 store_->RequestIdentity(rtc::KeyParams(rtc::KT_ECDSA), | 115 store_->RequestIdentity(rtc::KeyParams(rtc::KT_ECDSA), |
118 rtc::Optional<uint64_t>(), | 116 rtc::Optional<uint64_t>(), |
119 observer_.get()); | 117 observer_.get()); |
120 EXPECT_FALSE(observer_->call_back_called()); | 118 EXPECT_FALSE(observer_->call_back_called()); |
121 EXPECT_TRUE_WAIT(observer_->LastRequestSucceeded(), kTimeoutMs); | 119 EXPECT_TRUE_WAIT(observer_->LastRequestSucceeded(), kTimeoutMs); |
122 } | 120 } |
123 | 121 |
(...skipping 14 matching lines...) Expand all Loading... |
138 | 136 |
139 store_->RequestIdentity(rtc::KeyParams(rtc::KT_ECDSA), | 137 store_->RequestIdentity(rtc::KeyParams(rtc::KT_ECDSA), |
140 rtc::Optional<uint64_t>(), | 138 rtc::Optional<uint64_t>(), |
141 observer_.get()); | 139 observer_.get()); |
142 store_.reset(); | 140 store_.reset(); |
143 | 141 |
144 worker_thread_->Stop(); | 142 worker_thread_->Stop(); |
145 EXPECT_FALSE(observer_->call_back_called()); | 143 EXPECT_FALSE(observer_->call_back_called()); |
146 } | 144 } |
147 | 145 |
OLD | NEW |