Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2012 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 #if defined(WEBRTC_POSIX) | 10 #if defined(WEBRTC_POSIX) |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 using cricket::Connection; | 37 using cricket::Connection; |
| 38 using cricket::Port; | 38 using cricket::Port; |
| 39 using cricket::PortInterface; | 39 using cricket::PortInterface; |
| 40 using cricket::TurnPort; | 40 using cricket::TurnPort; |
| 41 using cricket::UDPPort; | 41 using cricket::UDPPort; |
| 42 | 42 |
| 43 static const SocketAddress kLocalAddr1("11.11.11.11", 0); | 43 static const SocketAddress kLocalAddr1("11.11.11.11", 0); |
| 44 static const SocketAddress kLocalAddr2("22.22.22.22", 0); | 44 static const SocketAddress kLocalAddr2("22.22.22.22", 0); |
| 45 static const SocketAddress kLocalIPv6Addr( | 45 static const SocketAddress kLocalIPv6Addr( |
| 46 "2401:fa00:4:1000:be30:5bff:fee5:c3", 0); | 46 "2401:fa00:4:1000:be30:5bff:fee5:c3", 0); |
| 47 static const SocketAddress kLocalIPv6Addr2( | |
| 48 "2401:fa00:4:2000:be30:5bff:fee5:d4", 0); | |
| 47 static const SocketAddress kTurnUdpIntAddr("99.99.99.3", | 49 static const SocketAddress kTurnUdpIntAddr("99.99.99.3", |
| 48 cricket::TURN_SERVER_PORT); | 50 cricket::TURN_SERVER_PORT); |
| 49 static const SocketAddress kTurnTcpIntAddr("99.99.99.4", | 51 static const SocketAddress kTurnTcpIntAddr("99.99.99.4", |
| 50 cricket::TURN_SERVER_PORT); | 52 cricket::TURN_SERVER_PORT); |
| 51 static const SocketAddress kTurnUdpExtAddr("99.99.99.5", 0); | 53 static const SocketAddress kTurnUdpExtAddr("99.99.99.5", 0); |
| 52 static const SocketAddress kTurnAlternateIntAddr("99.99.99.6", | 54 static const SocketAddress kTurnAlternateIntAddr("99.99.99.6", |
| 53 cricket::TURN_SERVER_PORT); | 55 cricket::TURN_SERVER_PORT); |
| 54 static const SocketAddress kTurnIntAddr("99.99.99.7", | 56 static const SocketAddress kTurnIntAddr("99.99.99.7", |
| 55 cricket::TURN_SERVER_PORT); | 57 cricket::TURN_SERVER_PORT); |
| 56 static const SocketAddress kTurnIPv6IntAddr( | 58 static const SocketAddress kTurnIPv6IntAddr( |
| 57 "2400:4030:2:2c00:be30:abcd:efab:cdef", | 59 "2400:4030:2:2c00:be30:abcd:efab:cdef", |
| 58 cricket::TURN_SERVER_PORT); | 60 cricket::TURN_SERVER_PORT); |
| 59 static const SocketAddress kTurnUdpIPv6IntAddr( | 61 static const SocketAddress kTurnUdpIPv6IntAddr( |
| 60 "2400:4030:1:2c00:be30:abcd:efab:cdef", cricket::TURN_SERVER_PORT); | 62 "2400:4030:1:2c00:be30:abcd:efab:cdef", cricket::TURN_SERVER_PORT); |
| 61 static const SocketAddress kTurnUdpIPv6ExtAddr( | |
| 62 "2620:0:1000:1b03:2e41:38ff:fea6:f2a4", 0); | |
| 63 | 63 |
| 64 static const char kIceUfrag1[] = "TESTICEUFRAG0001"; | 64 static const char kIceUfrag1[] = "TESTICEUFRAG0001"; |
| 65 static const char kIceUfrag2[] = "TESTICEUFRAG0002"; | 65 static const char kIceUfrag2[] = "TESTICEUFRAG0002"; |
| 66 static const char kIcePwd1[] = "TESTICEPWD00000000000001"; | 66 static const char kIcePwd1[] = "TESTICEPWD00000000000001"; |
| 67 static const char kIcePwd2[] = "TESTICEPWD00000000000002"; | 67 static const char kIcePwd2[] = "TESTICEPWD00000000000002"; |
| 68 static const char kTurnUsername[] = "test"; | 68 static const char kTurnUsername[] = "test"; |
| 69 static const char kTurnPassword[] = "test"; | 69 static const char kTurnPassword[] = "test"; |
| 70 static const char kTestOrigin[] = "http://example.com"; | 70 static const char kTestOrigin[] = "http://example.com"; |
| 71 static const unsigned int kTimeout = 1000; | 71 static const unsigned int kTimeout = 1000; |
| 72 | 72 |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 turn_port_->PrepareAddress(); | 581 turn_port_->PrepareAddress(); |
| 582 EXPECT_TRUE_WAIT(turn_error_, kTimeout); | 582 EXPECT_TRUE_WAIT(turn_error_, kTimeout); |
| 583 // As VSS doesn't provide a DNS resolution, name resolve will fail. TurnPort | 583 // As VSS doesn't provide a DNS resolution, name resolve will fail. TurnPort |
| 584 // will proceed in creating a TCP socket which will fail as there is no | 584 // will proceed in creating a TCP socket which will fail as there is no |
| 585 // server on the above domain and error will be set to SOCKET_ERROR. | 585 // server on the above domain and error will be set to SOCKET_ERROR. |
| 586 EXPECT_EQ(SOCKET_ERROR, turn_port_->error()); | 586 EXPECT_EQ(SOCKET_ERROR, turn_port_->error()); |
| 587 } | 587 } |
| 588 | 588 |
| 589 // In case of UDP on address resolve failure, TurnPort will not create socket | 589 // In case of UDP on address resolve failure, TurnPort will not create socket |
| 590 // and return allocate failure. | 590 // and return allocate failure. |
| 591 TEST_F(TurnPortTest, DISABLED_TestTurnUdpOnAdressResolveFailure) { | 591 TEST_F(TurnPortTest, DISABLED_TestTurnUdpOnAddressResolveFailure) { |
| 592 CreateTurnPort(kTurnUsername, kTurnPassword, cricket::ProtocolAddress( | 592 CreateTurnPort(kTurnUsername, kTurnPassword, cricket::ProtocolAddress( |
|
pthatcher1
2016/06/21 05:26:54
Can we un-DISABLED the test?
honghaiz3
2016/06/21 18:36:06
Will do this in a separate CL, as it was typically
| |
| 593 rtc::SocketAddress("www.webrtc-blah-blah.com", 3478), | 593 rtc::SocketAddress("www.webrtc-blah-blah.com", 3478), |
| 594 cricket::PROTO_UDP)); | 594 cricket::PROTO_UDP)); |
| 595 turn_port_->PrepareAddress(); | 595 turn_port_->PrepareAddress(); |
| 596 EXPECT_TRUE_WAIT(turn_error_, kTimeout); | 596 EXPECT_TRUE_WAIT(turn_error_, kTimeout); |
| 597 // Error from turn port will not be socket error. | 597 // Error from turn port will not be socket error. |
| 598 EXPECT_NE(SOCKET_ERROR, turn_port_->error()); | 598 EXPECT_NE(SOCKET_ERROR, turn_port_->error()); |
| 599 } | 599 } |
| 600 | 600 |
| 601 // Try to do a TURN allocation with an invalid password. | 601 // Try to do a TURN allocation with an invalid password. |
| 602 TEST_F(TurnPortTest, TestTurnAllocateBadPassword) { | 602 TEST_F(TurnPortTest, TestTurnAllocateBadPassword) { |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 976 CreateTurnPort(kLocalIPv6Addr, kTurnUsername, kTurnPassword, | 976 CreateTurnPort(kLocalIPv6Addr, kTurnUsername, kTurnPassword, |
| 977 kTurnUdpIPv6ProtoAddr); | 977 kTurnUdpIPv6ProtoAddr); |
| 978 turn_port_->PrepareAddress(); | 978 turn_port_->PrepareAddress(); |
| 979 EXPECT_TRUE_WAIT(turn_ready_, kTimeout); | 979 EXPECT_TRUE_WAIT(turn_ready_, kTimeout); |
| 980 ASSERT_EQ(1U, turn_port_->Candidates().size()); | 980 ASSERT_EQ(1U, turn_port_->Candidates().size()); |
| 981 EXPECT_EQ(kTurnUdpExtAddr.ipaddr(), | 981 EXPECT_EQ(kTurnUdpExtAddr.ipaddr(), |
| 982 turn_port_->Candidates()[0].address().ipaddr()); | 982 turn_port_->Candidates()[0].address().ipaddr()); |
| 983 EXPECT_NE(0, turn_port_->Candidates()[0].address().port()); | 983 EXPECT_NE(0, turn_port_->Candidates()[0].address().port()); |
| 984 } | 984 } |
| 985 | 985 |
| 986 // Tests that the local and remote candidate address family should match when | |
|
pthatcher1
2016/06/21 05:26:54
family = families
honghaiz3
2016/06/21 18:36:06
Done.
| |
| 987 // a connection is created. Specially if a turn port has an IPv6 address, its | |
|
pthatcher1
2016/06/21 05:26:54
Specially -> Specifically,
?
Taylor Brandstetter
2016/06/21 17:20:31
Can you capitalize TURN consistently here and belo
honghaiz3
2016/06/21 18:36:06
Done.
| |
| 988 // local candidate will still be an IPv4 address and it can only create | |
| 989 // connections with IPv4 remote candidates. | |
| 990 TEST_F(TurnPortTest, TestCandidateAddressFamilyMatch) { | |
| 991 rtc::ScopedFakeClock clock; | |
|
Taylor Brandstetter
2016/06/21 17:20:31
I don't know why the fake clock is necessary here.
honghaiz3
2016/06/21 18:36:06
If we have to wait for some state change with a ti
Taylor Brandstetter
2016/06/21 19:26:48
The general solution in that case is to use a long
honghaiz3
2016/06/21 20:06:49
Removed the fake clock but keep the kTimeout. I th
| |
| 992 turn_server_.AddInternalSocket(kTurnUdpIPv6IntAddr, cricket::PROTO_UDP); | |
| 993 | |
| 994 CreateTurnPort(kLocalIPv6Addr, kTurnUsername, kTurnPassword, | |
| 995 kTurnUdpIPv6ProtoAddr); | |
| 996 turn_port_->PrepareAddress(); | |
| 997 EXPECT_TRUE_SIMULATED_WAIT(turn_ready_, kTimeout, clock); | |
| 998 ASSERT_EQ(1U, turn_port_->Candidates().size()); | |
| 999 | |
| 1000 // Create an IPv4 port. Its candidate will match the Turn candidate. | |
|
pthatcher1
2016/06/21 05:26:54
TURN
honghaiz3
2016/06/21 18:36:06
Done.
| |
| 1001 CreateUdpPort(); | |
|
Taylor Brandstetter
2016/06/21 17:20:31
Why do you need to create actual remote ports? Cou
honghaiz3
2016/06/21 18:36:06
Done.
| |
| 1002 udp_port_->PrepareAddress(); | |
| 1003 EXPECT_TRUE_SIMULATED_WAIT(udp_ready_, kTimeout); | |
| 1004 Connection* conn = turn_port_->CreateConnection(udp_port_->Candidates()[0], | |
| 1005 Port::ORIGIN_MESSAGE); | |
| 1006 EXPECT_TRUE(conn != nullptr); | |
|
Taylor Brandstetter
2016/06/21 17:20:31
EXPECT_NE(nullptr, conn)?
honghaiz3
2016/06/21 18:36:06
Done.
| |
| 1007 | |
| 1008 // Create an IPv6 UDP port. Its candidate won't match the Turn candidate. | |
|
pthatcher1
2016/06/21 05:26:54
TURN
honghaiz3
2016/06/21 18:36:06
Done.
| |
| 1009 CreateUdpPort(kLocalIPv6Addr2); | |
| 1010 udp_port_->PrepareAddress(); | |
| 1011 EXPECT_TRUE_SIMULATED_WAIT(udp_ready_, kTimeout); | |
| 1012 conn = turn_port_->CreateConnection(udp_port_->Candidates()[0], | |
| 1013 Port::ORIGIN_MESSAGE); | |
| 1014 EXPECT_TRUE(conn == nullptr); | |
|
Taylor Brandstetter
2016/06/21 17:20:31
EXPECT_EQ(nullptr, conn)?
honghaiz3
2016/06/21 18:36:06
Done.
| |
| 1015 } | |
| 1016 | |
| 986 TEST_F(TurnPortTest, TestOriginHeader) { | 1017 TEST_F(TurnPortTest, TestOriginHeader) { |
| 987 CreateTurnPortWithOrigin(kLocalAddr1, kTurnUsername, kTurnPassword, | 1018 CreateTurnPortWithOrigin(kLocalAddr1, kTurnUsername, kTurnPassword, |
| 988 kTurnUdpProtoAddr, kTestOrigin); | 1019 kTurnUdpProtoAddr, kTestOrigin); |
| 989 turn_port_->PrepareAddress(); | 1020 turn_port_->PrepareAddress(); |
| 990 EXPECT_TRUE_WAIT(turn_ready_, kTimeout); | 1021 EXPECT_TRUE_WAIT(turn_ready_, kTimeout); |
| 991 ASSERT_GT(turn_server_.server()->allocations().size(), 0U); | 1022 ASSERT_GT(turn_server_.server()->allocations().size(), 0U); |
| 992 SocketAddress local_address = turn_port_->GetLocalAddress(); | 1023 SocketAddress local_address = turn_port_->GetLocalAddress(); |
| 993 ASSERT_TRUE(turn_server_.FindAllocation(local_address) != NULL); | 1024 ASSERT_TRUE(turn_server_.FindAllocation(local_address) != NULL); |
| 994 EXPECT_EQ(kTestOrigin, turn_server_.FindAllocation(local_address)->origin()); | 1025 EXPECT_EQ(kTestOrigin, turn_server_.FindAllocation(local_address)->origin()); |
| 995 } | 1026 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1057 turn_port_->PrepareAddress(); | 1088 turn_port_->PrepareAddress(); |
| 1058 ASSERT_TRUE_WAIT(turn_error_, kResolverTimeout); | 1089 ASSERT_TRUE_WAIT(turn_error_, kResolverTimeout); |
| 1059 EXPECT_TRUE(turn_port_->Candidates().empty()); | 1090 EXPECT_TRUE(turn_port_->Candidates().empty()); |
| 1060 turn_port_.reset(); | 1091 turn_port_.reset(); |
| 1061 rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TESTFINISH); | 1092 rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TESTFINISH); |
| 1062 // Waiting for above message to be processed. | 1093 // Waiting for above message to be processed. |
| 1063 ASSERT_TRUE_WAIT(test_finish_, kTimeout); | 1094 ASSERT_TRUE_WAIT(test_finish_, kTimeout); |
| 1064 EXPECT_EQ(last_fd_count, GetFDCount()); | 1095 EXPECT_EQ(last_fd_count, GetFDCount()); |
| 1065 } | 1096 } |
| 1066 #endif | 1097 #endif |
| OLD | NEW |