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

Side by Side Diff: webrtc/p2p/client/portallocator_unittest.cc

Issue 1311153003: Add check to prevent TURN usage if the protocol is not allowed. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: 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/client/basicportallocator.cc ('k') | no next file » | 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 2009 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2009 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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 ResetWithStunServerNoNat(kStunAddr); 599 ResetWithStunServerNoNat(kStunAddr);
600 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 600 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
601 session_->set_flags(cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE); 601 session_->set_flags(cricket::PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE);
602 // Expect to see 2 ports: STUN and TCP ports, localhost candidate and STUN 602 // Expect to see 2 ports: STUN and TCP ports, localhost candidate and STUN
603 // candidate. 603 // candidate.
604 CheckDisableAdapterEnumeration(2U, rtc::GetLoopbackIP(AF_INET), 604 CheckDisableAdapterEnumeration(2U, rtc::GetLoopbackIP(AF_INET),
605 kClientAddr.ipaddr(), rtc::IPAddress(), 605 kClientAddr.ipaddr(), rtc::IPAddress(),
606 rtc::IPAddress()); 606 rtc::IPAddress());
607 } 607 }
608 608
609 // Test that we disable relay over UDP, and only TCP is used when connecting to
610 // the relay server.
611 TEST_F(PortAllocatorTest, TestDisableUdpTurn) {
612 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP);
613 AddInterface(kClientAddr);
614 ResetWithStunServerAndNat(kStunAddr);
615 AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr);
616 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
617 session_->set_flags(cricket::PORTALLOCATOR_DISABLE_UDP_RELAY |
618 cricket::PORTALLOCATOR_DISABLE_UDP |
619 cricket::PORTALLOCATOR_DISABLE_STUN |
620 cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET);
621
622 session_->StartGettingPorts();
623 EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout);
624
625 // Expect to see 2 ports and 2 candidates - TURN/TCP and TCP ports, TCP and
626 // TURN/TCP candidates.
627 EXPECT_EQ(2U, ports_.size());
628 EXPECT_EQ(2U, candidates_.size());
629 EXPECT_PRED5(CheckCandidate, candidates_[0],
630 cricket::ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp",
631 kTurnUdpExtAddr);
632 // The TURN candidate should use TCP to contact the TURN server.
633 EXPECT_EQ(cricket::TCP_PROTOCOL_NAME, candidates_[0].relay_protocol());
634 EXPECT_PRED5(CheckCandidate, candidates_[1],
635 cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "tcp",
636 kClientAddr);
637 }
638
609 // Disable for asan, see 639 // Disable for asan, see
610 // https://code.google.com/p/webrtc/issues/detail?id=4743 for details. 640 // https://code.google.com/p/webrtc/issues/detail?id=4743 for details.
611 #if !defined(ADDRESS_SANITIZER) 641 #if !defined(ADDRESS_SANITIZER)
612 642
613 // Test that we can get OnCandidatesAllocationDone callback when all the ports 643 // Test that we can get OnCandidatesAllocationDone callback when all the ports
614 // are disabled. 644 // are disabled.
615 TEST_F(PortAllocatorTest, TestDisableAllPorts) { 645 TEST_F(PortAllocatorTest, TestDisableAllPorts) {
616 AddInterface(kClientAddr); 646 AddInterface(kClientAddr);
617 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 647 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
618 session_->set_flags(cricket::PORTALLOCATOR_DISABLE_UDP | 648 session_->set_flags(cricket::PORTALLOCATOR_DISABLE_UDP |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 AllocationSequenceForTest alloc_sequence( 1317 AllocationSequenceForTest alloc_sequence(
1288 static_cast<cricket::BasicPortAllocatorSession*>(session_.get()), 1318 static_cast<cricket::BasicPortAllocatorSession*>(session_.get()),
1289 &network1, &config, flag); 1319 &network1, &config, flag);
1290 // This simply tests it will not crash if udp_socket_ in the 1320 // This simply tests it will not crash if udp_socket_ in the
1291 // AllocationSequence is null, which is chosen in the constructor. 1321 // AllocationSequence is null, which is chosen in the constructor.
1292 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); 1322 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN);
1293 relay_server.ports.push_back( 1323 relay_server.ports.push_back(
1294 cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP, false)); 1324 cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP, false));
1295 alloc_sequence.CreateTurnPort(relay_server); 1325 alloc_sequence.CreateTurnPort(relay_server);
1296 } 1326 }
OLDNEW
« no previous file with comments | « webrtc/p2p/client/basicportallocator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698