Index: webrtc/p2p/client/portallocator_unittest.cc |
diff --git a/webrtc/p2p/client/portallocator_unittest.cc b/webrtc/p2p/client/portallocator_unittest.cc |
index 6940ea17ad2272b5265260f2137f480da1028ef3..cd871b61dcbec8fafff9dc6d030b2b4c8cff12fe 100644 |
--- a/webrtc/p2p/client/portallocator_unittest.cc |
+++ b/webrtc/p2p/client/portallocator_unittest.cc |
@@ -644,8 +644,6 @@ TEST_F(PortAllocatorTest, TestCandidateFilterWithRelayOnly) { |
TEST_F(PortAllocatorTest, TestCandidateFilterWithHostOnly) { |
AddInterface(kClientAddr); |
- allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
allocator().set_candidate_filter(cricket::CF_HOST); |
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
session_->StartGettingPorts(); |
@@ -662,8 +660,6 @@ TEST_F(PortAllocatorTest, TestCandidateFilterWithReflexiveOnly) { |
AddInterface(kPrivateAddr); |
ResetWithNatServer(kStunAddr); |
- allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
allocator().set_candidate_filter(cricket::CF_REFLEXIVE); |
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
session_->StartGettingPorts(); |
@@ -683,8 +679,6 @@ TEST_F(PortAllocatorTest, TestCandidateFilterWithReflexiveOnly) { |
// Host is not behind the NAT. |
TEST_F(PortAllocatorTest, TestCandidateFilterWithReflexiveOnlyAndNoNAT) { |
AddInterface(kClientAddr); |
- allocator().set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
allocator().set_candidate_filter(cricket::CF_REFLEXIVE); |
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
session_->StartGettingPorts(); |
@@ -697,11 +691,8 @@ TEST_F(PortAllocatorTest, TestCandidateFilterWithReflexiveOnlyAndNoNAT) { |
} |
} |
-// Test that when the PORTALLOCATOR_ENABLE_SHARED_UFRAG is enabled we got same |
-// ufrag and pwd for the collected candidates. |
+// Test that we get the same ufrag and pwd for all candidates. |
TEST_F(PortAllocatorTest, TestEnableSharedUfrag) { |
- allocator().set_flags(allocator().flags() | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); |
AddInterface(kClientAddr); |
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
session_->StartGettingPorts(); |
@@ -721,39 +712,12 @@ TEST_F(PortAllocatorTest, TestEnableSharedUfrag) { |
EXPECT_TRUE(candidate_allocation_done_); |
} |
-// Test that when the PORTALLOCATOR_ENABLE_SHARED_UFRAG isn't enabled we got |
-// different ufrag and pwd for the collected candidates. |
-TEST_F(PortAllocatorTest, TestDisableSharedUfrag) { |
- allocator().set_flags(allocator().flags() & |
- ~cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); |
- AddInterface(kClientAddr); |
- EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
- session_->StartGettingPorts(); |
- ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); |
- EXPECT_PRED5(CheckCandidate, candidates_[0], |
- cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", kClientAddr); |
- EXPECT_PRED5(CheckCandidate, candidates_[1], |
- cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", kClientAddr); |
- EXPECT_EQ(4U, ports_.size()); |
- // Port should generate random ufrag and pwd. |
- EXPECT_NE(kIceUfrag0, candidates_[0].username()); |
- EXPECT_NE(kIceUfrag0, candidates_[1].username()); |
- EXPECT_NE(candidates_[0].username(), candidates_[1].username()); |
- EXPECT_NE(kIcePwd0, candidates_[0].password()); |
- EXPECT_NE(kIcePwd0, candidates_[1].password()); |
- EXPECT_NE(candidates_[0].password(), candidates_[1].password()); |
- EXPECT_TRUE(candidate_allocation_done_); |
-} |
- |
-// Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port |
-// is allocated for udp and stun. Also verify there is only one candidate |
-// (local) if stun candidate is same as local candidate, which will be the case |
-// in a public network like the below test. |
+// Test that only one port is allocated for udp and stun. Also verify |
+// there is only one candidate (local) if stun candidate is same as |
+// local candidate, which will be the case in a public network like |
+// the below test. |
TEST_F(PortAllocatorTest, TestSharedSocketWithoutNat) { |
AddInterface(kClientAddr); |
- allocator_->set_flags(allocator().flags() | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
session_->StartGettingPorts(); |
ASSERT_EQ_WAIT(6U, candidates_.size(), kDefaultAllocationTimeout); |
@@ -763,16 +727,13 @@ TEST_F(PortAllocatorTest, TestSharedSocketWithoutNat) { |
EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
} |
-// Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port |
-// is allocated for udp and stun. In this test we should expect both stun and |
-// local candidates as client behind a nat. |
+// Test that only one port is allocated for udp and stun. In this test |
+// we should expect both stun and local candidates as client behind a |
+// nat. |
TEST_F(PortAllocatorTest, TestSharedSocketWithNat) { |
AddInterface(kClientAddr); |
ResetWithNatServer(kStunAddr); |
- allocator_->set_flags(allocator().flags() | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
session_->StartGettingPorts(); |
ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); |
@@ -786,7 +747,7 @@ TEST_F(PortAllocatorTest, TestSharedSocketWithNat) { |
EXPECT_EQ(3U, candidates_.size()); |
} |
-// Test TURN port in shared socket mode with UDP and TCP TURN server addresses. |
+// Test TURN port with UDP and TCP TURN server addresses. |
TEST_F(PortAllocatorTest, TestSharedSocketWithoutNatUsingTurn) { |
turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); |
AddInterface(kClientAddr); |
@@ -796,8 +757,6 @@ TEST_F(PortAllocatorTest, TestSharedSocketWithoutNatUsingTurn) { |
allocator_->set_step_delay(cricket::kMinimumStepDelay); |
allocator_->set_flags(allocator().flags() | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
cricket::PORTALLOCATOR_DISABLE_TCP); |
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
@@ -834,8 +793,6 @@ TEST_F(PortAllocatorTest, TestSharedSocketWithServerAddressResolve) { |
allocator_->set_step_delay(cricket::kMinimumStepDelay); |
allocator_->set_flags(allocator().flags() | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
cricket::PORTALLOCATOR_DISABLE_TCP); |
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
@@ -844,9 +801,8 @@ TEST_F(PortAllocatorTest, TestSharedSocketWithServerAddressResolve) { |
EXPECT_EQ_WAIT(2U, ports_.size(), kDefaultAllocationTimeout); |
} |
-// Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled only one port |
-// is allocated for udp/stun/turn. In this test we should expect all local, |
-// stun and turn candidates. |
+// Test that only one port is allocated for udp/stun/turn. In this |
+// test we should expect all local, stun and turn candidates. |
TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurn) { |
AddInterface(kClientAddr); |
ResetWithNatServer(kStunAddr); |
@@ -854,8 +810,6 @@ TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurn) { |
AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); |
allocator_->set_flags(allocator().flags() | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
cricket::PORTALLOCATOR_DISABLE_TCP); |
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
@@ -878,9 +832,8 @@ TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurn) { |
EXPECT_EQ(1U, ports_[1]->Candidates().size()); |
} |
-// Test that when PORTALLOCATOR_ENABLE_SHARED_SOCKET is enabled and the TURN |
-// server is also used as the STUN server, we should get 'local', 'stun', and |
-// 'relay' candidates. |
+// Test that the TURN server is also used as the STUN server. We |
+// should get 'local', 'stun', and 'relay' candidates. |
TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurnAsStun) { |
AddInterface(kClientAddr); |
// Use an empty SocketAddress to add a NAT without STUN server. |
@@ -893,8 +846,6 @@ TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurnAsStun) { |
// webrtc issue 3537. |
allocator_->set_step_delay(0); |
allocator_->set_flags(allocator().flags() | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
cricket::PORTALLOCATOR_DISABLE_TCP); |
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
@@ -928,8 +879,6 @@ TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurnTcpOnly) { |
AddTurnServers(rtc::SocketAddress(), kTurnTcpIntAddr); |
allocator_->set_flags(allocator().flags() | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
cricket::PORTALLOCATOR_DISABLE_TCP); |
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
@@ -949,46 +898,6 @@ TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurnTcpOnly) { |
EXPECT_EQ(1U, ports_[1]->Candidates().size()); |
} |
-// Test that even when PORTALLOCATOR_ENABLE_SHARED_SOCKET is NOT enabled, the |
-// TURN server is used as the STUN server and we get 'local', 'stun', and |
-// 'relay' candidates. |
-// TODO(deadbeef): Remove this test when support for non-shared socket mode |
-// is removed. |
-TEST_F(PortAllocatorTest, TestNonSharedSocketWithNatUsingTurnAsStun) { |
- AddInterface(kClientAddr); |
- // Use an empty SocketAddress to add a NAT without STUN server. |
- ResetWithNatServer(SocketAddress()); |
- AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); |
- |
- allocator_->set_flags(allocator().flags() | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
- cricket::PORTALLOCATOR_DISABLE_TCP); |
- |
- EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
- session_->StartGettingPorts(); |
- |
- ASSERT_EQ_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout); |
- ASSERT_EQ(3U, ports_.size()); |
- EXPECT_PRED5(CheckCandidate, candidates_[0], |
- cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", |
- kClientAddr); |
- EXPECT_PRED5(CheckCandidate, candidates_[1], |
- cricket::ICE_CANDIDATE_COMPONENT_RTP, "stun", "udp", |
- rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)); |
- EXPECT_PRED5(CheckCandidate, candidates_[2], |
- cricket::ICE_CANDIDATE_COMPONENT_RTP, "relay", "udp", |
- rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)); |
- // Not using shared socket, so the STUN request's server reflexive address |
- // should be different than the TURN request's server reflexive address. |
- EXPECT_NE(candidates_[2].related_address(), candidates_[1].address()); |
- |
- EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); |
- EXPECT_EQ(3U, candidates_.size()); |
- EXPECT_EQ(1U, ports_[0]->Candidates().size()); |
- EXPECT_EQ(1U, ports_[1]->Candidates().size()); |
- EXPECT_EQ(1U, ports_[2]->Candidates().size()); |
-} |
- |
// Test that even when both a STUN and TURN server are configured, the TURN |
// server is used as a STUN server and we get a 'stun' candidate. |
TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurnAndStun) { |
@@ -1000,8 +909,6 @@ TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurnAndStun) { |
AddTurnServers(kTurnUdpIntAddr, rtc::SocketAddress()); |
allocator_->set_flags(allocator().flags() | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
cricket::PORTALLOCATOR_DISABLE_TCP); |
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
@@ -1023,15 +930,12 @@ TEST_F(PortAllocatorTest, TestSharedSocketWithNatUsingTurnAndStun) { |
// that we got a STUN candidate from the TURN server. |
} |
-// This test verifies when PORTALLOCATOR_ENABLE_SHARED_SOCKET flag is enabled |
-// and fail to generate STUN candidate, local UDP candidate is generated |
-// properly. |
+// This test verifies that when we fail to generate a STUN candidate, |
+// we properly generate a local UDP candidate. |
TEST_F(PortAllocatorTest, TestSharedSocketNoUdpAllowed) { |
allocator().set_flags(allocator().flags() | |
cricket::PORTALLOCATOR_DISABLE_RELAY | |
- cricket::PORTALLOCATOR_DISABLE_TCP | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
+ cricket::PORTALLOCATOR_DISABLE_TCP); |
fss_->AddRule(false, rtc::FP_UDP, rtc::FD_ANY, kClientAddr); |
AddInterface(kClientAddr); |
EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
@@ -1049,9 +953,7 @@ TEST_F(PortAllocatorTest, TestSharedSocketNoUdpAllowed) { |
TEST_F(PortAllocatorTest, TestEnableIPv6Addresses) { |
allocator().set_flags(allocator().flags() | |
cricket::PORTALLOCATOR_DISABLE_RELAY | |
- cricket::PORTALLOCATOR_ENABLE_IPV6 | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG | |
- cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET); |
+ cricket::PORTALLOCATOR_ENABLE_IPV6); |
AddInterface(kClientIPv6Addr); |
AddInterface(kClientAddr); |
allocator_->set_step_delay(cricket::kMinimumStepDelay); |
@@ -1109,22 +1011,12 @@ TEST(HttpPortAllocatorTest, TestSessionRequestUrl) { |
rtc::FakeNetworkManager network_manager; |
cricket::HttpPortAllocator alloc(&network_manager, "unit test agent"); |
- // Disable PORTALLOCATOR_ENABLE_SHARED_UFRAG. |
- alloc.set_flags(alloc.flags() & ~cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); |
rtc::scoped_ptr<cricket::HttpPortAllocatorSessionBase> session( |
static_cast<cricket::HttpPortAllocatorSession*>( |
alloc.CreateSessionInternal( |
"test content", 0, kIceUfrag0, kIcePwd0))); |
std::string url = session->GetSessionRequestUrl(); |
LOG(LS_INFO) << "url: " << url; |
- EXPECT_EQ(std::string(cricket::HttpPortAllocator::kCreateSessionURL), url); |
- |
- // Enable PORTALLOCATOR_ENABLE_SHARED_UFRAG. |
- alloc.set_flags(alloc.flags() | cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG); |
- session.reset(static_cast<cricket::HttpPortAllocatorSession*>( |
- alloc.CreateSessionInternal("test content", 0, kIceUfrag0, kIcePwd0))); |
- url = session->GetSessionRequestUrl(); |
- LOG(LS_INFO) << "url: " << url; |
std::vector<std::string> parts; |
rtc::split(url, '?', &parts); |
ASSERT_EQ(2U, parts.size()); |