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

Side by Side Diff: webrtc/p2p/base/dtlstransportchannel_unittest.cc

Issue 2553043004: Revert of Refactoring that removes P2PTransport and DtlsTransport classes. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « webrtc/p2p/base/dtlstransport.h ('k') | webrtc/p2p/base/faketransportcontroller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2011 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
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 13
14 #include "webrtc/p2p/base/dtlstransportchannel.h" 14 #include "webrtc/p2p/base/dtlstransport.h"
15 #include "webrtc/p2p/base/faketransportcontroller.h" 15 #include "webrtc/p2p/base/faketransportcontroller.h"
16 #include "webrtc/p2p/base/packettransportinterface.h" 16 #include "webrtc/p2p/base/packettransportinterface.h"
17 #include "webrtc/base/common.h" 17 #include "webrtc/base/common.h"
18 #include "webrtc/base/dscp.h" 18 #include "webrtc/base/dscp.h"
19 #include "webrtc/base/gunit.h" 19 #include "webrtc/base/gunit.h"
20 #include "webrtc/base/helpers.h" 20 #include "webrtc/base/helpers.h"
21 #include "webrtc/base/ssladapter.h" 21 #include "webrtc/base/ssladapter.h"
22 #include "webrtc/base/sslidentity.h" 22 #include "webrtc/base/sslidentity.h"
23 #include "webrtc/base/sslstreamadapter.h" 23 #include "webrtc/base/sslstreamadapter.h"
24 #include "webrtc/base/stringutils.h" 24 #include "webrtc/base/stringutils.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 return cricket::TransportDescription(std::vector<std::string>(), kIceUfrag1, 57 return cricket::TransportDescription(std::vector<std::string>(), kIceUfrag1,
58 kIcePwd1, cricket::ICEMODE_FULL, role, 58 kIcePwd1, cricket::ICEMODE_FULL, role,
59 fingerprint.get()); 59 fingerprint.get());
60 } 60 }
61 61
62 using cricket::ConnectionRole; 62 using cricket::ConnectionRole;
63 63
64 enum Flags { NF_REOFFER = 0x1, NF_EXPECT_FAILURE = 0x2 }; 64 enum Flags { NF_REOFFER = 0x1, NF_EXPECT_FAILURE = 0x2 };
65 65
66 // TODO(deadbeef): Remove the dependency on JsepTransport. This test should be
67 // testing DtlsTransportChannel by itself, calling methods to set the
68 // configuration directly instead of negotiating TransportDescriptions.
69 class DtlsTestClient : public sigslot::has_slots<> { 66 class DtlsTestClient : public sigslot::has_slots<> {
70 public: 67 public:
71 DtlsTestClient(const std::string& name) : name_(name) {} 68 DtlsTestClient(const std::string& name) : name_(name) {}
72 void CreateCertificate(rtc::KeyType key_type) { 69 void CreateCertificate(rtc::KeyType key_type) {
73 certificate_ = 70 certificate_ =
74 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>( 71 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>(
75 rtc::SSLIdentity::Generate(name_, key_type))); 72 rtc::SSLIdentity::Generate(name_, key_type)));
76 } 73 }
77 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate() { 74 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate() {
78 return certificate_; 75 return certificate_;
79 } 76 }
80 void SetupSrtp() { 77 void SetupSrtp() {
81 ASSERT(certificate_); 78 ASSERT(certificate_);
82 use_dtls_srtp_ = true; 79 use_dtls_srtp_ = true;
83 } 80 }
84 void SetupMaxProtocolVersion(rtc::SSLProtocolVersion version) { 81 void SetupMaxProtocolVersion(rtc::SSLProtocolVersion version) {
82 ASSERT(!transport_);
85 ssl_max_version_ = version; 83 ssl_max_version_ = version;
86 } 84 }
87 void SetupChannels(int count, cricket::IceRole role, int async_delay_ms = 0) { 85 void SetupChannels(int count, cricket::IceRole role, int async_delay_ms = 0) {
88 transport_.reset( 86 transport_.reset(new cricket::DtlsTransport<cricket::FakeTransport>(
89 new cricket::JsepTransport("dtls content name", certificate_)); 87 "dtls content name", nullptr, certificate_));
88 transport_->SetAsync(true);
89 transport_->SetAsyncDelay(async_delay_ms);
90 transport_->SetIceRole(role);
91 transport_->SetIceTiebreaker(
92 (role == cricket::ICEROLE_CONTROLLING) ? 1 : 2);
93
90 for (int i = 0; i < count; ++i) { 94 for (int i = 0; i < count; ++i) {
91 cricket::FakeTransportChannel* fake_ice_channel =
92 new cricket::FakeTransportChannel(transport_->mid(), i);
93 fake_ice_channel->SetAsync(true);
94 fake_ice_channel->SetAsyncDelay(async_delay_ms);
95 // Hook the raw packets so that we can verify they are encrypted.
96 fake_ice_channel->SignalReadPacket.connect(
97 this, &DtlsTestClient::OnFakeTransportChannelReadPacket);
98
99 cricket::DtlsTransportChannelWrapper* channel = 95 cricket::DtlsTransportChannelWrapper* channel =
100 new cricket::DtlsTransportChannelWrapper(fake_ice_channel); 96 static_cast<cricket::DtlsTransportChannelWrapper*>(
101 channel->SetLocalCertificate(certificate_); 97 transport_->CreateChannel(i));
102 channel->SetIceRole(role); 98 ASSERT_TRUE(channel != NULL);
103 channel->SetIceTiebreaker((role == cricket::ICEROLE_CONTROLLING) ? 1 : 2);
104 channel->SetSslMaxProtocolVersion(ssl_max_version_); 99 channel->SetSslMaxProtocolVersion(ssl_max_version_);
105 channel->SignalWritableState.connect(this, 100 channel->SignalWritableState.connect(this,
106 &DtlsTestClient::OnTransportChannelWritableState); 101 &DtlsTestClient::OnTransportChannelWritableState);
107 channel->SignalReadPacket.connect(this, 102 channel->SignalReadPacket.connect(this,
108 &DtlsTestClient::OnTransportChannelReadPacket); 103 &DtlsTestClient::OnTransportChannelReadPacket);
109 channel->SignalSentPacket.connect( 104 channel->SignalSentPacket.connect(
110 this, &DtlsTestClient::OnTransportChannelSentPacket); 105 this, &DtlsTestClient::OnTransportChannelSentPacket);
111 channels_.push_back( 106 channels_.push_back(channel);
112 std::unique_ptr<cricket::DtlsTransportChannelWrapper>(channel)); 107
113 fake_channels_.push_back( 108 // Hook the raw packets so that we can verify they are encrypted.
114 std::unique_ptr<cricket::FakeTransportChannel>(fake_ice_channel)); 109 channel->channel()->SignalReadPacket.connect(
115 transport_->AddChannel(channel, i); 110 this, &DtlsTestClient::OnFakeTransportChannelReadPacket);
116 } 111 }
117 } 112 }
118 113
119 cricket::JsepTransport* transport() { return transport_.get(); } 114 cricket::Transport* transport() { return transport_.get(); }
120 115
121 cricket::FakeTransportChannel* GetFakeChannel(int component) { 116 cricket::FakeTransportChannel* GetFakeChannel(int component) {
122 for (const auto& ch : fake_channels_) { 117 cricket::TransportChannelImpl* ch = transport_->GetChannel(component);
123 if (ch->component() == component) { 118 cricket::DtlsTransportChannelWrapper* wrapper =
124 return ch.get(); 119 static_cast<cricket::DtlsTransportChannelWrapper*>(ch);
125 } 120 return (wrapper) ?
126 } 121 static_cast<cricket::FakeTransportChannel*>(wrapper->channel()) : NULL;
127 return nullptr;
128 } 122 }
129 123
130 cricket::DtlsTransportChannelWrapper* GetDtlsChannel(int component) { 124 cricket::DtlsTransportChannelWrapper* GetDtlsChannel(int component) {
131 for (const auto& ch : channels_) { 125 cricket::TransportChannelImpl* ch = transport_->GetChannel(component);
132 if (ch->component() == component) { 126 return static_cast<cricket::DtlsTransportChannelWrapper*>(ch);
133 return ch.get();
134 }
135 }
136 return nullptr;
137 } 127 }
138 128
139 // Offer DTLS if we have an identity; pass in a remote fingerprint only if 129 // Offer DTLS if we have an identity; pass in a remote fingerprint only if
140 // both sides support DTLS. 130 // both sides support DTLS.
141 void Negotiate(DtlsTestClient* peer, cricket::ContentAction action, 131 void Negotiate(DtlsTestClient* peer, cricket::ContentAction action,
142 ConnectionRole local_role, ConnectionRole remote_role, 132 ConnectionRole local_role, ConnectionRole remote_role,
143 int flags) { 133 int flags) {
144 Negotiate(certificate_, certificate_ ? peer->certificate_ : nullptr, action, 134 Negotiate(certificate_, certificate_ ? peer->certificate_ : nullptr, action,
145 local_role, remote_role, flags); 135 local_role, remote_role, flags);
146 } 136 }
147 137
148 void MaybeSetSrtpCryptoSuites() { 138 void MaybeSetSrtpCryptoSuites() {
149 if (!use_dtls_srtp_) { 139 if (!use_dtls_srtp_) {
150 return; 140 return;
151 } 141 }
152 std::vector<int> ciphers; 142 std::vector<int> ciphers;
153 ciphers.push_back(rtc::SRTP_AES128_CM_SHA1_80); 143 ciphers.push_back(rtc::SRTP_AES128_CM_SHA1_80);
154 // SRTP ciphers will be set only in the beginning. 144 // SRTP ciphers will be set only in the beginning.
155 for (const auto& channel : channels_) { 145 for (cricket::DtlsTransportChannelWrapper* channel : channels_) {
156 EXPECT_TRUE(channel->SetSrtpCryptoSuites(ciphers)); 146 EXPECT_TRUE(channel->SetSrtpCryptoSuites(ciphers));
157 } 147 }
158 } 148 }
159 149
160 void SetLocalTransportDescription( 150 void SetLocalTransportDescription(
161 const rtc::scoped_refptr<rtc::RTCCertificate>& cert, 151 const rtc::scoped_refptr<rtc::RTCCertificate>& cert,
162 cricket::ContentAction action, 152 cricket::ContentAction action,
163 ConnectionRole role, 153 ConnectionRole role,
164 int flags) { 154 int flags) {
165 // If |NF_EXPECT_FAILURE| is set, expect SRTD or SLTD to fail when 155 // If |NF_EXPECT_FAILURE| is set, expect SRTD or SLTD to fail when
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 SetRemoteTransportDescription(remote_cert, cricket::CA_OFFER, remote_role, 195 SetRemoteTransportDescription(remote_cert, cricket::CA_OFFER, remote_role,
206 flags); 196 flags);
207 // If remote if the offerer and has no DTLS support, answer will be 197 // If remote if the offerer and has no DTLS support, answer will be
208 // without any fingerprint. 198 // without any fingerprint.
209 SetLocalTransportDescription(remote_cert ? local_cert : nullptr, 199 SetLocalTransportDescription(remote_cert ? local_cert : nullptr,
210 cricket::CA_ANSWER, local_role, flags); 200 cricket::CA_ANSWER, local_role, flags);
211 } 201 }
212 } 202 }
213 203
214 bool Connect(DtlsTestClient* peer, bool asymmetric) { 204 bool Connect(DtlsTestClient* peer, bool asymmetric) {
215 for (auto& channel : fake_channels_) { 205 transport_->SetDestination(peer->transport_.get(), asymmetric);
216 channel->SetDestination(peer->GetFakeChannel(channel->component()),
217 asymmetric);
218 }
219 return true; 206 return true;
220 } 207 }
221 208
222 bool all_channels_writable() const { 209 bool all_channels_writable() const {
223 if (channels_.empty()) { 210 if (channels_.empty()) {
224 return false; 211 return false;
225 } 212 }
226 for (const auto& channel : channels_) { 213 for (cricket::DtlsTransportChannelWrapper* channel : channels_) {
227 if (!channel->writable()) { 214 if (!channel->writable()) {
228 return false; 215 return false;
229 } 216 }
230 } 217 }
231 return true; 218 return true;
232 } 219 }
233 220
234 bool all_raw_channels_writable() const { 221 bool all_raw_channels_writable() const {
235 if (channels_.empty()) { 222 if (channels_.empty()) {
236 return false; 223 return false;
237 } 224 }
238 for (const auto& channel : channels_) { 225 for (cricket::DtlsTransportChannelWrapper* channel : channels_) {
239 if (!channel->channel()->writable()) { 226 if (!channel->channel()->writable()) {
240 return false; 227 return false;
241 } 228 }
242 } 229 }
243 return true; 230 return true;
244 } 231 }
245 232
246 int received_dtls_client_hellos() const { 233 int received_dtls_client_hellos() const {
247 return received_dtls_client_hellos_; 234 return received_dtls_client_hellos_;
248 } 235 }
(...skipping 13 matching lines...) Expand all
262 if (role == rtc::SSL_CLIENT) { 249 if (role == rtc::SSL_CLIENT) {
263 ASSERT_EQ(0, received_dtls_client_hellos_); 250 ASSERT_EQ(0, received_dtls_client_hellos_);
264 ASSERT_GT(received_dtls_server_hellos_, 0); 251 ASSERT_GT(received_dtls_server_hellos_, 0);
265 } else { 252 } else {
266 ASSERT_GT(received_dtls_client_hellos_, 0); 253 ASSERT_GT(received_dtls_client_hellos_, 0);
267 ASSERT_EQ(0, received_dtls_server_hellos_); 254 ASSERT_EQ(0, received_dtls_server_hellos_);
268 } 255 }
269 } 256 }
270 257
271 void CheckSrtp(int expected_crypto_suite) { 258 void CheckSrtp(int expected_crypto_suite) {
272 for (const auto& channel : channels_) { 259 for (std::vector<cricket::DtlsTransportChannelWrapper*>::iterator it =
260 channels_.begin(); it != channels_.end(); ++it) {
273 int crypto_suite; 261 int crypto_suite;
274 262
275 bool rv = channel->GetSrtpCryptoSuite(&crypto_suite); 263 bool rv = (*it)->GetSrtpCryptoSuite(&crypto_suite);
276 if (negotiated_dtls() && expected_crypto_suite) { 264 if (negotiated_dtls() && expected_crypto_suite) {
277 ASSERT_TRUE(rv); 265 ASSERT_TRUE(rv);
278 266
279 ASSERT_EQ(crypto_suite, expected_crypto_suite); 267 ASSERT_EQ(crypto_suite, expected_crypto_suite);
280 } else { 268 } else {
281 ASSERT_FALSE(rv); 269 ASSERT_FALSE(rv);
282 } 270 }
283 } 271 }
284 } 272 }
285 273
286 void CheckSsl() { 274 void CheckSsl() {
287 for (const auto& channel : channels_) { 275 for (std::vector<cricket::DtlsTransportChannelWrapper*>::iterator it =
276 channels_.begin(); it != channels_.end(); ++it) {
288 int cipher; 277 int cipher;
289 278
290 bool rv = channel->GetSslCipherSuite(&cipher); 279 bool rv = (*it)->GetSslCipherSuite(&cipher);
291 if (negotiated_dtls()) { 280 if (negotiated_dtls()) {
292 ASSERT_TRUE(rv); 281 ASSERT_TRUE(rv);
293 282
294 EXPECT_TRUE( 283 EXPECT_TRUE(
295 rtc::SSLStreamAdapter::IsAcceptableCipher(cipher, rtc::KT_DEFAULT)); 284 rtc::SSLStreamAdapter::IsAcceptableCipher(cipher, rtc::KT_DEFAULT));
296 } else { 285 } else {
297 ASSERT_FALSE(rv); 286 ASSERT_FALSE(rv);
298 } 287 }
299 } 288 }
300 } 289 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 ASSERT_TRUE(VerifyEncryptedPacket(data, size)); 416 ASSERT_TRUE(VerifyEncryptedPacket(data, size));
428 } else if (IsRtpLeadByte(data[0])) { 417 } else if (IsRtpLeadByte(data[0])) {
429 ASSERT_TRUE(VerifyPacket(data, size, NULL)); 418 ASSERT_TRUE(VerifyPacket(data, size, NULL));
430 } 419 }
431 } 420 }
432 } 421 }
433 422
434 private: 423 private:
435 std::string name_; 424 std::string name_;
436 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; 425 rtc::scoped_refptr<rtc::RTCCertificate> certificate_;
437 std::vector<std::unique_ptr<cricket::FakeTransportChannel>> fake_channels_; 426 std::unique_ptr<cricket::FakeTransport> transport_;
438 std::vector<std::unique_ptr<cricket::DtlsTransportChannelWrapper>> channels_; 427 std::vector<cricket::DtlsTransportChannelWrapper*> channels_;
439 std::unique_ptr<cricket::JsepTransport> transport_;
440 size_t packet_size_ = 0u; 428 size_t packet_size_ = 0u;
441 std::set<int> received_; 429 std::set<int> received_;
442 bool use_dtls_srtp_ = false; 430 bool use_dtls_srtp_ = false;
443 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12; 431 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12;
444 int received_dtls_client_hellos_ = 0; 432 int received_dtls_client_hellos_ = 0;
445 int received_dtls_server_hellos_ = 0; 433 int received_dtls_server_hellos_ = 0;
446 rtc::SentPacket sent_packet_; 434 rtc::SentPacket sent_packet_;
447 }; 435 };
448 436
449 // Base class for DtlsTransportChannelTest and DtlsEventOrderingTest, which 437 // Base class for DtlsTransportChannelTest and DtlsEventOrderingTest, which
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 } 814 }
827 815
828 // Testing with the legacy DTLS client which doesn't use setup attribute. 816 // Testing with the legacy DTLS client which doesn't use setup attribute.
829 // In this case legacy is the answerer. 817 // In this case legacy is the answerer.
830 TEST_F(DtlsTransportChannelTest, TestDtlsSetupWithLegacyAsAnswerer) { 818 TEST_F(DtlsTransportChannelTest, TestDtlsSetupWithLegacyAsAnswerer) {
831 MAYBE_SKIP_TEST(HaveDtlsSrtp); 819 MAYBE_SKIP_TEST(HaveDtlsSrtp);
832 PrepareDtls(true, true, rtc::KT_DEFAULT); 820 PrepareDtls(true, true, rtc::KT_DEFAULT);
833 NegotiateWithLegacy(); 821 NegotiateWithLegacy();
834 rtc::SSLRole channel1_role; 822 rtc::SSLRole channel1_role;
835 rtc::SSLRole channel2_role; 823 rtc::SSLRole channel2_role;
836 client1_.transport()->GetSslRole(&channel1_role); 824 EXPECT_TRUE(client1_.transport()->GetSslRole(&channel1_role));
837 client2_.transport()->GetSslRole(&channel2_role); 825 EXPECT_TRUE(client2_.transport()->GetSslRole(&channel2_role));
838 EXPECT_EQ(rtc::SSL_SERVER, channel1_role); 826 EXPECT_EQ(rtc::SSL_SERVER, channel1_role);
839 EXPECT_EQ(rtc::SSL_CLIENT, channel2_role); 827 EXPECT_EQ(rtc::SSL_CLIENT, channel2_role);
840 } 828 }
841 829
842 // Testing re offer/answer after the session is estbalished. Roles will be 830 // Testing re offer/answer after the session is estbalished. Roles will be
843 // kept same as of the previous negotiation. 831 // kept same as of the previous negotiation.
844 TEST_F(DtlsTransportChannelTest, TestDtlsReOfferFromOfferer) { 832 TEST_F(DtlsTransportChannelTest, TestDtlsReOfferFromOfferer) {
845 MAYBE_SKIP_TEST(HaveDtlsSrtp); 833 MAYBE_SKIP_TEST(HaveDtlsSrtp);
846 SetChannelCount(2); 834 SetChannelCount(2);
847 PrepareDtls(true, true, rtc::KT_DEFAULT); 835 PrepareDtls(true, true, rtc::KT_DEFAULT);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 rtc::scoped_refptr<rtc::RTCCertificate> certificate2; 925 rtc::scoped_refptr<rtc::RTCCertificate> certificate2;
938 std::unique_ptr<rtc::SSLCertificate> remote_cert1; 926 std::unique_ptr<rtc::SSLCertificate> remote_cert1;
939 std::unique_ptr<rtc::SSLCertificate> remote_cert2; 927 std::unique_ptr<rtc::SSLCertificate> remote_cert2;
940 928
941 // After negotiation, each side has a distinct local certificate, but still no 929 // After negotiation, each side has a distinct local certificate, but still no
942 // remote certificate, because connection has not yet occurred. 930 // remote certificate, because connection has not yet occurred.
943 ASSERT_TRUE(client1_.transport()->GetLocalCertificate(&certificate1)); 931 ASSERT_TRUE(client1_.transport()->GetLocalCertificate(&certificate1));
944 ASSERT_TRUE(client2_.transport()->GetLocalCertificate(&certificate2)); 932 ASSERT_TRUE(client2_.transport()->GetLocalCertificate(&certificate2));
945 ASSERT_NE(certificate1->ssl_certificate().ToPEMString(), 933 ASSERT_NE(certificate1->ssl_certificate().ToPEMString(),
946 certificate2->ssl_certificate().ToPEMString()); 934 certificate2->ssl_certificate().ToPEMString());
947 ASSERT_FALSE(client1_.GetDtlsChannel(0)->GetRemoteSSLCertificate()); 935 ASSERT_FALSE(client1_.transport()->GetRemoteSSLCertificate());
948 ASSERT_FALSE(client2_.GetDtlsChannel(0)->GetRemoteSSLCertificate()); 936 ASSERT_FALSE(client2_.transport()->GetRemoteSSLCertificate());
949 } 937 }
950 938
951 // Test Certificates state after connection. 939 // Test Certificates state after connection.
952 TEST_F(DtlsTransportChannelTest, TestCertificatesAfterConnect) { 940 TEST_F(DtlsTransportChannelTest, TestCertificatesAfterConnect) {
953 MAYBE_SKIP_TEST(HaveDtls); 941 MAYBE_SKIP_TEST(HaveDtls);
954 PrepareDtls(true, true, rtc::KT_DEFAULT); 942 PrepareDtls(true, true, rtc::KT_DEFAULT);
955 ASSERT_TRUE(Connect()); 943 ASSERT_TRUE(Connect());
956 944
957 rtc::scoped_refptr<rtc::RTCCertificate> certificate1; 945 rtc::scoped_refptr<rtc::RTCCertificate> certificate1;
958 rtc::scoped_refptr<rtc::RTCCertificate> certificate2; 946 rtc::scoped_refptr<rtc::RTCCertificate> certificate2;
959 947
960 // After connection, each side has a distinct local certificate. 948 // After connection, each side has a distinct local certificate.
961 ASSERT_TRUE(client1_.transport()->GetLocalCertificate(&certificate1)); 949 ASSERT_TRUE(client1_.transport()->GetLocalCertificate(&certificate1));
962 ASSERT_TRUE(client2_.transport()->GetLocalCertificate(&certificate2)); 950 ASSERT_TRUE(client2_.transport()->GetLocalCertificate(&certificate2));
963 ASSERT_NE(certificate1->ssl_certificate().ToPEMString(), 951 ASSERT_NE(certificate1->ssl_certificate().ToPEMString(),
964 certificate2->ssl_certificate().ToPEMString()); 952 certificate2->ssl_certificate().ToPEMString());
965 953
966 // Each side's remote certificate is the other side's local certificate. 954 // Each side's remote certificate is the other side's local certificate.
967 std::unique_ptr<rtc::SSLCertificate> remote_cert1 = 955 std::unique_ptr<rtc::SSLCertificate> remote_cert1 =
968 client1_.GetDtlsChannel(0)->GetRemoteSSLCertificate(); 956 client1_.transport()->GetRemoteSSLCertificate();
969 ASSERT_TRUE(remote_cert1); 957 ASSERT_TRUE(remote_cert1);
970 ASSERT_EQ(remote_cert1->ToPEMString(), 958 ASSERT_EQ(remote_cert1->ToPEMString(),
971 certificate2->ssl_certificate().ToPEMString()); 959 certificate2->ssl_certificate().ToPEMString());
972 std::unique_ptr<rtc::SSLCertificate> remote_cert2 = 960 std::unique_ptr<rtc::SSLCertificate> remote_cert2 =
973 client2_.GetDtlsChannel(0)->GetRemoteSSLCertificate(); 961 client2_.transport()->GetRemoteSSLCertificate();
974 ASSERT_TRUE(remote_cert2); 962 ASSERT_TRUE(remote_cert2);
975 ASSERT_EQ(remote_cert2->ToPEMString(), 963 ASSERT_EQ(remote_cert2->ToPEMString(),
976 certificate1->ssl_certificate().ToPEMString()); 964 certificate1->ssl_certificate().ToPEMString());
977 } 965 }
978 966
979 // Test that packets are retransmitted according to the expected schedule. 967 // Test that packets are retransmitted according to the expected schedule.
980 // Each time a timeout occurs, the retransmission timer should be doubled up to 968 // Each time a timeout occurs, the retransmission timer should be doubled up to
981 // 60 seconds. The timer defaults to 1 second, but for WebRTC we should be 969 // 60 seconds. The timer defaults to 1 second, but for WebRTC we should be
982 // initializing it to 50ms. 970 // initializing it to 50ms.
983 TEST_F(DtlsTransportChannelTest, TestRetransmissionSchedule) { 971 TEST_F(DtlsTransportChannelTest, TestRetransmissionSchedule) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 std::vector<DtlsTransportEvent>{ 1171 std::vector<DtlsTransportEvent>{
1184 CALLER_RECEIVES_CLIENTHELLO, CALLER_RECEIVES_FINGERPRINT, 1172 CALLER_RECEIVES_CLIENTHELLO, CALLER_RECEIVES_FINGERPRINT,
1185 CALLER_WRITABLE, HANDSHAKE_FINISHES}, 1173 CALLER_WRITABLE, HANDSHAKE_FINISHES},
1186 std::vector<DtlsTransportEvent>{ 1174 std::vector<DtlsTransportEvent>{
1187 CALLER_RECEIVES_CLIENTHELLO, CALLER_WRITABLE, 1175 CALLER_RECEIVES_CLIENTHELLO, CALLER_WRITABLE,
1188 CALLER_RECEIVES_FINGERPRINT, HANDSHAKE_FINISHES}, 1176 CALLER_RECEIVES_FINGERPRINT, HANDSHAKE_FINISHES},
1189 std::vector<DtlsTransportEvent>{CALLER_RECEIVES_CLIENTHELLO, 1177 std::vector<DtlsTransportEvent>{CALLER_RECEIVES_CLIENTHELLO,
1190 CALLER_WRITABLE, HANDSHAKE_FINISHES, 1178 CALLER_WRITABLE, HANDSHAKE_FINISHES,
1191 CALLER_RECEIVES_FINGERPRINT}), 1179 CALLER_RECEIVES_FINGERPRINT}),
1192 ::testing::Bool())); 1180 ::testing::Bool()));
OLDNEW
« no previous file with comments | « webrtc/p2p/base/dtlstransport.h ('k') | webrtc/p2p/base/faketransportcontroller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698