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

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

Issue 1549633004: Fill the remote pwd in ice candidates when an ICE credential is received. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix a type conversion issue. Created 4 years, 11 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/p2ptransportchannel.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 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 1894
1895 // Add a candidate with the current ufrag, its pwd and generation will be 1895 // Add a candidate with the current ufrag, its pwd and generation will be
1896 // assigned, even if the generation is not set. 1896 // assigned, even if the generation is not set.
1897 ch.AddRemoteCandidate(CreateCandidate("3.3.3.3", 3, 0, kIceUfrag[2])); 1897 ch.AddRemoteCandidate(CreateCandidate("3.3.3.3", 3, 0, kIceUfrag[2]));
1898 cricket::Connection* conn3 = nullptr; 1898 cricket::Connection* conn3 = nullptr;
1899 ASSERT_TRUE_WAIT((conn3 = GetConnectionTo(&ch, "3.3.3.3", 3)) != nullptr, 1899 ASSERT_TRUE_WAIT((conn3 = GetConnectionTo(&ch, "3.3.3.3", 3)) != nullptr,
1900 3000); 1900 3000);
1901 const cricket::Candidate& new_candidate = conn3->remote_candidate(); 1901 const cricket::Candidate& new_candidate = conn3->remote_candidate();
1902 EXPECT_EQ(kIcePwd[2], new_candidate.password()); 1902 EXPECT_EQ(kIcePwd[2], new_candidate.password());
1903 EXPECT_EQ(1U, new_candidate.generation()); 1903 EXPECT_EQ(1U, new_candidate.generation());
1904
1905 // Check that the pwd of all remote candidates are properly assigned.
1906 for (const cricket::RemoteCandidate& candidate : ch.remote_candidates()) {
1907 EXPECT_TRUE(candidate.username() == kIceUfrag[1] ||
1908 candidate.username() == kIceUfrag[2]);
1909 if (candidate.username() == kIceUfrag[1]) {
1910 EXPECT_EQ(kIcePwd[1], candidate.password());
1911 } else if (candidate.username() == kIceUfrag[2]) {
1912 EXPECT_EQ(kIcePwd[2], candidate.password());
1913 }
1914 }
1904 } 1915 }
1905 1916
1906 TEST_F(P2PTransportChannelPingTest, ConnectionResurrection) { 1917 TEST_F(P2PTransportChannelPingTest, ConnectionResurrection) {
1907 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); 1918 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
1908 cricket::P2PTransportChannel ch("connection resurrection", 1, nullptr, &pa); 1919 cricket::P2PTransportChannel ch("connection resurrection", 1, nullptr, &pa);
1909 PrepareChannel(&ch); 1920 PrepareChannel(&ch);
1910 ch.Connect(); 1921 ch.Connect();
1911 ch.MaybeStartGathering(); 1922 ch.MaybeStartGathering();
1912 1923
1913 // Create conn1 and keep track of original candidate priority. 1924 // Create conn1 and keep track of original candidate priority.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 EXPECT_EQ(conn3, ch.best_connection()); 2044 EXPECT_EQ(conn3, ch.best_connection());
2034 // The best connection switches after conn4 becomes writable. 2045 // The best connection switches after conn4 becomes writable.
2035 conn4->ReceivedPingResponse(); 2046 conn4->ReceivedPingResponse();
2036 EXPECT_EQ(conn4, ch.best_connection()); 2047 EXPECT_EQ(conn4, ch.best_connection());
2037 } 2048 }
2038 2049
2039 // The controlled side will select a connection as the "best connection" based 2050 // The controlled side will select a connection as the "best connection" based
2040 // on requests from an unknown address before the controlling side nominates 2051 // on requests from an unknown address before the controlling side nominates
2041 // a connection, and will nominate a connection from an unknown address if the 2052 // a connection, and will nominate a connection from an unknown address if the
2042 // request contains the use_candidate attribute. Plus, it will also sends back 2053 // request contains the use_candidate attribute. Plus, it will also sends back
2043 // a ping response. 2054 // a ping response and set the ICE pwd in the remote candidate appropriately.
2044 TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) { 2055 TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) {
2045 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); 2056 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
2046 cricket::P2PTransportChannel ch("receiving state change", 1, nullptr, &pa); 2057 cricket::P2PTransportChannel ch("receiving state change", 1, nullptr, &pa);
2047 PrepareChannel(&ch); 2058 PrepareChannel(&ch);
2048 ch.SetIceRole(cricket::ICEROLE_CONTROLLED); 2059 ch.SetIceRole(cricket::ICEROLE_CONTROLLED);
2049 ch.Connect(); 2060 ch.Connect();
2050 ch.MaybeStartGathering(); 2061 ch.MaybeStartGathering();
2051 // A minimal STUN message with prflx priority. 2062 // A minimal STUN message with prflx priority.
2052 cricket::IceMessage request; 2063 cricket::IceMessage request;
2053 request.SetType(cricket::STUN_BINDING_REQUEST); 2064 request.SetType(cricket::STUN_BINDING_REQUEST);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2098 new cricket::StunByteStringAttribute(cricket::STUN_ATTR_USE_CANDIDATE)); 2109 new cricket::StunByteStringAttribute(cricket::STUN_ATTR_USE_CANDIDATE));
2099 port->SignalUnknownAddress(port, rtc::SocketAddress("4.4.4.4", 4), 2110 port->SignalUnknownAddress(port, rtc::SocketAddress("4.4.4.4", 4),
2100 cricket::PROTO_UDP, &request, kIceUfrag[1], false); 2111 cricket::PROTO_UDP, &request, kIceUfrag[1], false);
2101 cricket::Connection* conn4 = WaitForConnectionTo(&ch, "4.4.4.4", 4); 2112 cricket::Connection* conn4 = WaitForConnectionTo(&ch, "4.4.4.4", 4);
2102 ASSERT_TRUE(conn4 != nullptr); 2113 ASSERT_TRUE(conn4 != nullptr);
2103 EXPECT_TRUE(port->sent_binding_response()); 2114 EXPECT_TRUE(port->sent_binding_response());
2104 // conn4 is not the best connection yet because it is not writable. 2115 // conn4 is not the best connection yet because it is not writable.
2105 EXPECT_EQ(conn2, ch.best_connection()); 2116 EXPECT_EQ(conn2, ch.best_connection());
2106 conn4->ReceivedPingResponse(); // Become writable. 2117 conn4->ReceivedPingResponse(); // Become writable.
2107 EXPECT_EQ(conn4, ch.best_connection()); 2118 EXPECT_EQ(conn4, ch.best_connection());
2119
2120 // Test that the request from an unknown address contains a ufrag from an old
2121 // generation.
2122 port->set_sent_binding_response(false);
2123 ch.SetRemoteIceCredentials(kIceUfrag[2], kIcePwd[2]);
2124 ch.SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]);
2125 port->SignalUnknownAddress(port, rtc::SocketAddress("5.5.5.5", 5),
2126 cricket::PROTO_UDP, &request, kIceUfrag[2], false);
2127 cricket::Connection* conn5 = WaitForConnectionTo(&ch, "5.5.5.5", 5);
2128 ASSERT_TRUE(conn5 != nullptr);
2129 EXPECT_TRUE(port->sent_binding_response());
2130 EXPECT_EQ(kIcePwd[2], conn5->remote_candidate().password());
2108 } 2131 }
2109 2132
2110 // The controlled side will select a connection as the "best connection" 2133 // The controlled side will select a connection as the "best connection"
2111 // based on media received until the controlling side nominates a connection, 2134 // based on media received until the controlling side nominates a connection,
2112 // at which point the controlled side will select that connection as 2135 // at which point the controlled side will select that connection as
2113 // the "best connection". 2136 // the "best connection".
2114 TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) { 2137 TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) {
2115 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); 2138 cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
2116 cricket::P2PTransportChannel ch("receiving state change", 1, nullptr, &pa); 2139 cricket::P2PTransportChannel ch("receiving state change", 1, nullptr, &pa);
2117 PrepareChannel(&ch); 2140 PrepareChannel(&ch);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 // It should stop getting ports after a new connection becomes strongly 2349 // It should stop getting ports after a new connection becomes strongly
2327 // connected. 2350 // connected.
2328 ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]); 2351 ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]);
2329 ch.MaybeStartGathering(); 2352 ch.MaybeStartGathering();
2330 ch.AddRemoteCandidate(CreateCandidate("2.2.2.2", 2, 100)); 2353 ch.AddRemoteCandidate(CreateCandidate("2.2.2.2", 2, 100));
2331 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); 2354 cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2);
2332 ASSERT_TRUE(conn2 != nullptr); 2355 ASSERT_TRUE(conn2 != nullptr);
2333 conn2->ReceivedPingResponse(); // Becomes writable and receiving 2356 conn2->ReceivedPingResponse(); // Becomes writable and receiving
2334 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); 2357 EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts());
2335 } 2358 }
OLDNEW
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698