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

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

Issue 1353713002: Remove GICE (again). (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Undo .gclient Created 5 years, 3 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
« no previous file with comments | « webrtc/p2p/base/dtlstransportchannel.h ('k') | webrtc/p2p/base/fakesession.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
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 enum Flags { NF_REOFFER = 0x1, NF_EXPECT_FAILURE = 0x2 }; 44 enum Flags { NF_REOFFER = 0x1, NF_EXPECT_FAILURE = 0x2 };
45 45
46 class DtlsTestClient : public sigslot::has_slots<> { 46 class DtlsTestClient : public sigslot::has_slots<> {
47 public: 47 public:
48 DtlsTestClient(const std::string& name, 48 DtlsTestClient(const std::string& name,
49 rtc::Thread* signaling_thread, 49 rtc::Thread* signaling_thread,
50 rtc::Thread* worker_thread) : 50 rtc::Thread* worker_thread) :
51 name_(name), 51 name_(name),
52 signaling_thread_(signaling_thread), 52 signaling_thread_(signaling_thread),
53 worker_thread_(worker_thread), 53 worker_thread_(worker_thread),
54 protocol_(cricket::ICEPROTO_GOOGLE),
55 packet_size_(0), 54 packet_size_(0),
56 use_dtls_srtp_(false), 55 use_dtls_srtp_(false),
57 ssl_max_version_(rtc::SSL_PROTOCOL_DTLS_10), 56 ssl_max_version_(rtc::SSL_PROTOCOL_DTLS_10),
58 negotiated_dtls_(false), 57 negotiated_dtls_(false),
59 received_dtls_client_hello_(false), 58 received_dtls_client_hello_(false),
60 received_dtls_server_hello_(false) { 59 received_dtls_server_hello_(false) {
61 } 60 }
62 void CreateCertificate(rtc::KeyType key_type) { 61 void CreateCertificate(rtc::KeyType key_type) {
63 certificate_ = rtc::RTCCertificate::Create( 62 certificate_ = rtc::RTCCertificate::Create(
64 rtc::scoped_ptr<rtc::SSLIdentity>( 63 rtc::scoped_ptr<rtc::SSLIdentity>(
65 rtc::SSLIdentity::Generate(name_, key_type)).Pass()); 64 rtc::SSLIdentity::Generate(name_, key_type)).Pass());
66 } 65 }
67 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate() { 66 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate() {
68 return certificate_; 67 return certificate_;
69 } 68 }
70 void SetIceProtocol(cricket::TransportProtocol proto) {
71 protocol_ = proto;
72 }
73 void SetupSrtp() { 69 void SetupSrtp() {
74 ASSERT(certificate_); 70 ASSERT(certificate_);
75 use_dtls_srtp_ = true; 71 use_dtls_srtp_ = true;
76 } 72 }
77 void SetupMaxProtocolVersion(rtc::SSLProtocolVersion version) { 73 void SetupMaxProtocolVersion(rtc::SSLProtocolVersion version) {
78 ASSERT(transport_.get() == NULL); 74 ASSERT(transport_.get() == NULL);
79 ssl_max_version_ = version; 75 ssl_max_version_ = version;
80 } 76 }
81 void SetupChannels(int count, cricket::IceRole role) { 77 void SetupChannels(int count, cricket::IceRole role) {
82 transport_.reset(new cricket::DtlsTransport<cricket::FakeTransport>( 78 transport_.reset(new cricket::DtlsTransport<cricket::FakeTransport>(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 if (use_dtls_srtp_ && !(flags & NF_REOFFER)) { 155 if (use_dtls_srtp_ && !(flags & NF_REOFFER)) {
160 // SRTP ciphers will be set only in the beginning. 156 // SRTP ciphers will be set only in the beginning.
161 for (std::vector<cricket::DtlsTransportChannelWrapper*>::iterator it = 157 for (std::vector<cricket::DtlsTransportChannelWrapper*>::iterator it =
162 channels_.begin(); it != channels_.end(); ++it) { 158 channels_.begin(); it != channels_.end(); ++it) {
163 std::vector<std::string> ciphers; 159 std::vector<std::string> ciphers;
164 ciphers.push_back(AES_CM_128_HMAC_SHA1_80); 160 ciphers.push_back(AES_CM_128_HMAC_SHA1_80);
165 ASSERT_TRUE((*it)->SetSrtpCiphers(ciphers)); 161 ASSERT_TRUE((*it)->SetSrtpCiphers(ciphers));
166 } 162 }
167 } 163 }
168 164
169 std::string transport_type = (protocol_ == cricket::ICEPROTO_GOOGLE) ?
170 cricket::NS_GINGLE_P2P : cricket::NS_JINGLE_ICE_UDP;
171 cricket::TransportDescription local_desc( 165 cricket::TransportDescription local_desc(
172 transport_type, std::vector<std::string>(), kIceUfrag1, kIcePwd1, 166 std::vector<std::string>(), kIceUfrag1, kIcePwd1,
173 cricket::ICEMODE_FULL, local_role, 167 cricket::ICEMODE_FULL, local_role,
174 // If remote if the offerer and has no DTLS support, answer will be 168 // If remote if the offerer and has no DTLS support, answer will be
175 // without any fingerprint. 169 // without any fingerprint.
176 (action == cricket::CA_ANSWER && !remote_cert) ? 170 (action == cricket::CA_ANSWER && !remote_cert) ?
177 NULL : local_fingerprint.get(), 171 NULL : local_fingerprint.get(),
178 cricket::Candidates()); 172 cricket::Candidates());
179 173
180 cricket::TransportDescription remote_desc( 174 cricket::TransportDescription remote_desc(
181 transport_type, std::vector<std::string>(), kIceUfrag1, kIcePwd1, 175 std::vector<std::string>(), kIceUfrag1, kIcePwd1,
182 cricket::ICEMODE_FULL, remote_role, remote_fingerprint.get(), 176 cricket::ICEMODE_FULL, remote_role, remote_fingerprint.get(),
183 cricket::Candidates()); 177 cricket::Candidates());
184 178
185 bool expect_success = (flags & NF_EXPECT_FAILURE) ? false : true; 179 bool expect_success = (flags & NF_EXPECT_FAILURE) ? false : true;
186 // If |expect_success| is false, expect SRTD or SLTD to fail when 180 // If |expect_success| is false, expect SRTD or SLTD to fail when
187 // content action is CA_ANSWER. 181 // content action is CA_ANSWER.
188 if (action == cricket::CA_OFFER) { 182 if (action == cricket::CA_OFFER) {
189 ASSERT_TRUE(transport_->SetLocalTransportDescription( 183 ASSERT_TRUE(transport_->SetLocalTransportDescription(
190 local_desc, cricket::CA_OFFER, NULL)); 184 local_desc, cricket::CA_OFFER, NULL));
191 ASSERT_EQ(expect_success, transport_->SetRemoteTransportDescription( 185 ASSERT_EQ(expect_success, transport_->SetRemoteTransportDescription(
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 ASSERT_TRUE(VerifyPacket(data, size, NULL)); 367 ASSERT_TRUE(VerifyPacket(data, size, NULL));
374 } 368 }
375 } 369 }
376 } 370 }
377 } 371 }
378 372
379 private: 373 private:
380 std::string name_; 374 std::string name_;
381 rtc::Thread* signaling_thread_; 375 rtc::Thread* signaling_thread_;
382 rtc::Thread* worker_thread_; 376 rtc::Thread* worker_thread_;
383
384 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; 377 rtc::scoped_refptr<rtc::RTCCertificate> certificate_;
385 cricket::TransportProtocol protocol_;
386
387 rtc::scoped_ptr<cricket::FakeTransport> transport_; 378 rtc::scoped_ptr<cricket::FakeTransport> transport_;
388 std::vector<cricket::DtlsTransportChannelWrapper*> channels_; 379 std::vector<cricket::DtlsTransportChannelWrapper*> channels_;
389 size_t packet_size_; 380 size_t packet_size_;
390 std::set<int> received_; 381 std::set<int> received_;
391 bool use_dtls_srtp_; 382 bool use_dtls_srtp_;
392 rtc::SSLProtocolVersion ssl_max_version_; 383 rtc::SSLProtocolVersion ssl_max_version_;
393 bool negotiated_dtls_; 384 bool negotiated_dtls_;
394 bool received_dtls_client_hello_; 385 bool received_dtls_client_hello_;
395 bool received_dtls_server_hello_; 386 bool received_dtls_server_hello_;
396 }; 387 };
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 DtlsTestClient client1_; 539 DtlsTestClient client1_;
549 DtlsTestClient client2_; 540 DtlsTestClient client2_;
550 int channel_ct_; 541 int channel_ct_;
551 bool use_dtls_; 542 bool use_dtls_;
552 bool use_dtls_srtp_; 543 bool use_dtls_srtp_;
553 rtc::SSLProtocolVersion ssl_expected_version_; 544 rtc::SSLProtocolVersion ssl_expected_version_;
554 }; 545 };
555 546
556 // Test that transport negotiation of ICE, no DTLS works properly. 547 // Test that transport negotiation of ICE, no DTLS works properly.
557 TEST_F(DtlsTransportChannelTest, TestChannelSetupIce) { 548 TEST_F(DtlsTransportChannelTest, TestChannelSetupIce) {
558 client1_.SetIceProtocol(cricket::ICEPROTO_RFC5245);
559 client2_.SetIceProtocol(cricket::ICEPROTO_RFC5245);
560 Negotiate(); 549 Negotiate();
561 cricket::FakeTransportChannel* channel1 = client1_.GetFakeChannel(0); 550 cricket::FakeTransportChannel* channel1 = client1_.GetFakeChannel(0);
562 cricket::FakeTransportChannel* channel2 = client2_.GetFakeChannel(0); 551 cricket::FakeTransportChannel* channel2 = client2_.GetFakeChannel(0);
563 ASSERT_TRUE(channel1 != NULL);
564 ASSERT_TRUE(channel2 != NULL);
565 EXPECT_EQ(cricket::ICEROLE_CONTROLLING, channel1->GetIceRole());
566 EXPECT_EQ(1U, channel1->IceTiebreaker());
567 EXPECT_EQ(cricket::ICEPROTO_RFC5245, channel1->protocol());
568 EXPECT_EQ(kIceUfrag1, channel1->ice_ufrag());
569 EXPECT_EQ(kIcePwd1, channel1->ice_pwd());
570 EXPECT_EQ(cricket::ICEROLE_CONTROLLED, channel2->GetIceRole());
571 EXPECT_EQ(2U, channel2->IceTiebreaker());
572 EXPECT_EQ(cricket::ICEPROTO_RFC5245, channel2->protocol());
573 }
574
575 // Test that transport negotiation of GICE, no DTLS works properly.
576 TEST_F(DtlsTransportChannelTest, TestChannelSetupGice) {
577 client1_.SetIceProtocol(cricket::ICEPROTO_GOOGLE);
578 client2_.SetIceProtocol(cricket::ICEPROTO_GOOGLE);
579 Negotiate();
580 cricket::FakeTransportChannel* channel1 = client1_.GetFakeChannel(0);
581 cricket::FakeTransportChannel* channel2 = client2_.GetFakeChannel(0);
582 ASSERT_TRUE(channel1 != NULL); 552 ASSERT_TRUE(channel1 != NULL);
583 ASSERT_TRUE(channel2 != NULL); 553 ASSERT_TRUE(channel2 != NULL);
584 EXPECT_EQ(cricket::ICEROLE_CONTROLLING, channel1->GetIceRole()); 554 EXPECT_EQ(cricket::ICEROLE_CONTROLLING, channel1->GetIceRole());
585 EXPECT_EQ(1U, channel1->IceTiebreaker()); 555 EXPECT_EQ(1U, channel1->IceTiebreaker());
586 EXPECT_EQ(cricket::ICEPROTO_GOOGLE, channel1->protocol());
587 EXPECT_EQ(kIceUfrag1, channel1->ice_ufrag()); 556 EXPECT_EQ(kIceUfrag1, channel1->ice_ufrag());
588 EXPECT_EQ(kIcePwd1, channel1->ice_pwd()); 557 EXPECT_EQ(kIcePwd1, channel1->ice_pwd());
589 EXPECT_EQ(cricket::ICEROLE_CONTROLLED, channel2->GetIceRole()); 558 EXPECT_EQ(cricket::ICEROLE_CONTROLLED, channel2->GetIceRole());
590 EXPECT_EQ(2U, channel2->IceTiebreaker()); 559 EXPECT_EQ(2U, channel2->IceTiebreaker());
591 EXPECT_EQ(cricket::ICEPROTO_GOOGLE, channel2->protocol());
592 } 560 }
593 561
594 // Connect without DTLS, and transfer some data. 562 // Connect without DTLS, and transfer some data.
595 TEST_F(DtlsTransportChannelTest, TestTransfer) { 563 TEST_F(DtlsTransportChannelTest, TestTransfer) {
596 ASSERT_TRUE(Connect()); 564 ASSERT_TRUE(Connect());
597 TestTransfer(0, 1000, 100, false); 565 TestTransfer(0, 1000, 100, false);
598 } 566 }
599 567
600 // Create two channels without DTLS, and transfer some data. 568 // Create two channels without DTLS, and transfer some data.
601 TEST_F(DtlsTransportChannelTest, TestTransferTwoChannels) { 569 TEST_F(DtlsTransportChannelTest, TestTransferTwoChannels) {
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 // Each side's remote certificate is the other side's local certificate. 869 // Each side's remote certificate is the other side's local certificate.
902 ASSERT_TRUE( 870 ASSERT_TRUE(
903 client1_.transport()->GetRemoteSSLCertificate(remote_cert1.accept())); 871 client1_.transport()->GetRemoteSSLCertificate(remote_cert1.accept()));
904 ASSERT_EQ(remote_cert1->ToPEMString(), 872 ASSERT_EQ(remote_cert1->ToPEMString(),
905 certificate2->ssl_certificate().ToPEMString()); 873 certificate2->ssl_certificate().ToPEMString());
906 ASSERT_TRUE( 874 ASSERT_TRUE(
907 client2_.transport()->GetRemoteSSLCertificate(remote_cert2.accept())); 875 client2_.transport()->GetRemoteSSLCertificate(remote_cert2.accept()));
908 ASSERT_EQ(remote_cert2->ToPEMString(), 876 ASSERT_EQ(remote_cert2->ToPEMString(),
909 certificate1->ssl_certificate().ToPEMString()); 877 certificate1->ssl_certificate().ToPEMString());
910 } 878 }
OLDNEW
« no previous file with comments | « webrtc/p2p/base/dtlstransportchannel.h ('k') | webrtc/p2p/base/fakesession.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698