| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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); | 86 EXPECT_TRUE_WAIT(store_->HasFreeIdentityForTesting(rtc::KT_RSA), kTimeoutMs); |
| 87 | 87 |
| 88 store_->RequestIdentity(rtc::KT_RSA, observer_.get()); | 88 store_->RequestIdentity(rtc::KeyParams(rtc::KT_RSA), |
| 89 rtc::Optional<uint64_t>(), |
| 90 observer_.get()); |
| 89 EXPECT_TRUE_WAIT(observer_->LastRequestSucceeded(), kTimeoutMs); | 91 EXPECT_TRUE_WAIT(observer_->LastRequestSucceeded(), kTimeoutMs); |
| 90 | 92 |
| 91 EXPECT_TRUE_WAIT(store_->HasFreeIdentityForTesting(rtc::KT_RSA), kTimeoutMs); | 93 EXPECT_TRUE_WAIT(store_->HasFreeIdentityForTesting(rtc::KT_RSA), kTimeoutMs); |
| 92 | 94 |
| 93 observer_->Reset(); | 95 observer_->Reset(); |
| 94 | 96 |
| 95 // Verifies that the callback is async when a free identity is ready. | 97 // Verifies that the callback is async when a free identity is ready. |
| 96 store_->RequestIdentity(rtc::KT_RSA, observer_.get()); | 98 store_->RequestIdentity(rtc::KeyParams(rtc::KT_RSA), |
| 99 rtc::Optional<uint64_t>(), |
| 100 observer_.get()); |
| 97 EXPECT_FALSE(observer_->call_back_called()); | 101 EXPECT_FALSE(observer_->call_back_called()); |
| 98 EXPECT_TRUE_WAIT(observer_->LastRequestSucceeded(), kTimeoutMs); | 102 EXPECT_TRUE_WAIT(observer_->LastRequestSucceeded(), kTimeoutMs); |
| 99 } | 103 } |
| 100 | 104 |
| 101 TEST_F(DtlsIdentityStoreTest, RequestIdentitySuccessECDSA) { | 105 TEST_F(DtlsIdentityStoreTest, RequestIdentitySuccessECDSA) { |
| 102 // Since store currently does not preemptively generate free ECDSA identities | 106 // Since store currently does not preemptively generate free ECDSA identities |
| 103 // we do not invoke HasFreeIdentityForTesting between requests. | 107 // we do not invoke HasFreeIdentityForTesting between requests. |
| 104 | 108 |
| 105 store_->RequestIdentity(rtc::KT_ECDSA, observer_.get()); | 109 store_->RequestIdentity(rtc::KeyParams(rtc::KT_ECDSA), |
| 110 rtc::Optional<uint64_t>(), |
| 111 observer_.get()); |
| 106 EXPECT_TRUE_WAIT(observer_->LastRequestSucceeded(), kTimeoutMs); | 112 EXPECT_TRUE_WAIT(observer_->LastRequestSucceeded(), kTimeoutMs); |
| 107 | 113 |
| 108 observer_->Reset(); | 114 observer_->Reset(); |
| 109 | 115 |
| 110 // Verifies that the callback is async when a free identity is ready. | 116 // Verifies that the callback is async when a free identity is ready. |
| 111 store_->RequestIdentity(rtc::KT_ECDSA, observer_.get()); | 117 store_->RequestIdentity(rtc::KeyParams(rtc::KT_ECDSA), |
| 118 rtc::Optional<uint64_t>(), |
| 119 observer_.get()); |
| 112 EXPECT_FALSE(observer_->call_back_called()); | 120 EXPECT_FALSE(observer_->call_back_called()); |
| 113 EXPECT_TRUE_WAIT(observer_->LastRequestSucceeded(), kTimeoutMs); | 121 EXPECT_TRUE_WAIT(observer_->LastRequestSucceeded(), kTimeoutMs); |
| 114 } | 122 } |
| 115 | 123 |
| 116 TEST_F(DtlsIdentityStoreTest, DeleteStoreEarlyNoCrashRSA) { | 124 TEST_F(DtlsIdentityStoreTest, DeleteStoreEarlyNoCrashRSA) { |
| 117 EXPECT_FALSE(store_->HasFreeIdentityForTesting(rtc::KT_RSA)); | 125 EXPECT_FALSE(store_->HasFreeIdentityForTesting(rtc::KT_RSA)); |
| 118 | 126 |
| 119 store_->RequestIdentity(rtc::KT_RSA, observer_.get()); | 127 store_->RequestIdentity(rtc::KeyParams(rtc::KT_RSA), |
| 128 rtc::Optional<uint64_t>(), |
| 129 observer_.get()); |
| 120 store_.reset(); | 130 store_.reset(); |
| 121 | 131 |
| 122 worker_thread_->Stop(); | 132 worker_thread_->Stop(); |
| 123 EXPECT_FALSE(observer_->call_back_called()); | 133 EXPECT_FALSE(observer_->call_back_called()); |
| 124 } | 134 } |
| 125 | 135 |
| 126 TEST_F(DtlsIdentityStoreTest, DeleteStoreEarlyNoCrashECDSA) { | 136 TEST_F(DtlsIdentityStoreTest, DeleteStoreEarlyNoCrashECDSA) { |
| 127 EXPECT_FALSE(store_->HasFreeIdentityForTesting(rtc::KT_ECDSA)); | 137 EXPECT_FALSE(store_->HasFreeIdentityForTesting(rtc::KT_ECDSA)); |
| 128 | 138 |
| 129 store_->RequestIdentity(rtc::KT_ECDSA, observer_.get()); | 139 store_->RequestIdentity(rtc::KeyParams(rtc::KT_ECDSA), |
| 140 rtc::Optional<uint64_t>(), |
| 141 observer_.get()); |
| 130 store_.reset(); | 142 store_.reset(); |
| 131 | 143 |
| 132 worker_thread_->Stop(); | 144 worker_thread_->Stop(); |
| 133 EXPECT_FALSE(observer_->call_back_called()); | 145 EXPECT_FALSE(observer_->call_back_called()); |
| 134 } | 146 } |
| 135 | 147 |
| OLD | NEW |