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

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

Issue 1868353004: Update prflx candidates' generation when setting ICE credentials. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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') | webrtc/p2p/base/port.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 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 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 1186
1187 // Test that we properly create a connection on a STUN ping from unknown address 1187 // Test that we properly create a connection on a STUN ping from unknown address
1188 // when the signaling is slow. 1188 // when the signaling is slow.
1189 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignaling) { 1189 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignaling) {
1190 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, 1190 ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags,
1191 kDefaultPortAllocatorFlags); 1191 kDefaultPortAllocatorFlags);
1192 // Emulate no remote credentials coming in. 1192 // Emulate no remote credentials coming in.
1193 set_clear_remote_candidates_ufrag_pwd(false); 1193 set_clear_remote_candidates_ufrag_pwd(false);
1194 CreateChannels(1); 1194 CreateChannels(1);
1195 // Only have remote credentials come in for ep2, not ep1. 1195 // Only have remote credentials come in for ep2, not ep1.
1196 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); 1196 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]);
Taylor Brandstetter 2016/04/09 01:12:57 I think "3" was just a typo here. This test doesn'
1197 1197
1198 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive 1198 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive
1199 // candidate. 1199 // candidate.
1200 PauseCandidates(1); 1200 PauseCandidates(1);
1201 1201
1202 // The caller should have the best connection connected to the peer reflexive 1202 // The caller should have the best connection connected to the peer reflexive
1203 // candidate. 1203 // candidate.
1204 const cricket::Connection* best_connection = NULL; 1204 const cricket::Connection* best_connection = NULL;
1205 WAIT((best_connection = ep1_ch1()->best_connection()) != NULL, 2000); 1205 WAIT((best_connection = ep1_ch1()->best_connection()) != NULL, 2000);
1206 EXPECT_EQ("prflx", ep1_ch1()->best_connection()->remote_candidate().type()); 1206 EXPECT_EQ("prflx", ep1_ch1()->best_connection()->remote_candidate().type());
1207 1207
1208 // Because we don't have a remote pwd, we don't ping yet. 1208 // Because we don't have a remote pwd, we don't ping yet.
1209 EXPECT_EQ(kIceUfrag[1], 1209 EXPECT_EQ(kIceUfrag[1],
1210 ep1_ch1()->best_connection()->remote_candidate().username()); 1210 ep1_ch1()->best_connection()->remote_candidate().username());
1211 EXPECT_EQ("", ep1_ch1()->best_connection()->remote_candidate().password()); 1211 EXPECT_EQ("", ep1_ch1()->best_connection()->remote_candidate().password());
1212 // Because we don't have ICE credentials yet, we don't know the generation.
1213 EXPECT_EQ(0u, ep1_ch1()->best_connection()->remote_candidate().generation());
1212 EXPECT_TRUE(nullptr == ep1_ch1()->FindNextPingableConnection()); 1214 EXPECT_TRUE(nullptr == ep1_ch1()->FindNextPingableConnection());
1213 1215
1216 // Add two sets of remote ICE credentials, so that the ones used by the
1217 // candidate will be generation 1 instead of 0.
1218 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]);
1214 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); 1219 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]);
1215 ResumeCandidates(1); 1220 // After setting the remote ICE credentials, the password and generation
1216 1221 // of the peer reflexive candidate should be updated.
1217 EXPECT_EQ(kIcePwd[1], 1222 EXPECT_EQ(kIcePwd[1],
1218 ep1_ch1()->best_connection()->remote_candidate().password()); 1223 ep1_ch1()->best_connection()->remote_candidate().password());
1224 EXPECT_EQ(1u, ep1_ch1()->best_connection()->remote_candidate().generation());
1219 EXPECT_TRUE(nullptr != ep1_ch1()->FindNextPingableConnection()); 1225 EXPECT_TRUE(nullptr != ep1_ch1()->FindNextPingableConnection());
1220 1226
1227 ResumeCandidates(1);
1228
1221 WAIT(ep2_ch1()->best_connection() != NULL, 2000); 1229 WAIT(ep2_ch1()->best_connection() != NULL, 2000);
1222 // Verify ep1's best connection is updated to use the 'local' candidate. 1230 // Verify ep1's best connection is updated to use the 'local' candidate.
1223 EXPECT_EQ_WAIT( 1231 EXPECT_EQ_WAIT(
1224 "local", 1232 "local",
1225 ep1_ch1()->best_connection()->remote_candidate().type(), 1233 ep1_ch1()->best_connection()->remote_candidate().type(),
1226 2000); 1234 2000);
1227 EXPECT_EQ(best_connection, ep1_ch1()->best_connection()); 1235 EXPECT_EQ(best_connection, ep1_ch1()->best_connection());
1228 DestroyChannels(); 1236 DestroyChannels();
1229 } 1237 }
1230 1238
1231 // Test that we properly create a connection on a STUN ping from unknown address 1239 // Test that we properly create a connection on a STUN ping from unknown address
1232 // when the signaling is slow and the end points are behind NAT. 1240 // when the signaling is slow and the end points are behind NAT.
1233 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignalingWithNAT) { 1241 TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignalingWithNAT) {
1234 ConfigureEndpoints(OPEN, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, 1242 ConfigureEndpoints(OPEN, NAT_SYMMETRIC, kDefaultPortAllocatorFlags,
1235 kDefaultPortAllocatorFlags); 1243 kDefaultPortAllocatorFlags);
1236 // Emulate no remote credentials coming in. 1244 // Emulate no remote credentials coming in.
1237 set_clear_remote_candidates_ufrag_pwd(false); 1245 set_clear_remote_candidates_ufrag_pwd(false);
1238 CreateChannels(1); 1246 CreateChannels(1);
1239 // Only have remote credentials come in for ep2, not ep1. 1247 // Only have remote credentials come in for ep2, not ep1.
1240 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); 1248 ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]);
1241 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive 1249 // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive
1242 // candidate. 1250 // candidate.
1243 PauseCandidates(1); 1251 PauseCandidates(1);
1244 1252
1245 // The caller should have the best connection connected to the peer reflexive 1253 // The caller should have the best connection connected to the peer reflexive
1246 // candidate. 1254 // candidate.
1247 WAIT(ep1_ch1()->best_connection() != NULL, 2000); 1255 WAIT(ep1_ch1()->best_connection() != NULL, 2000);
1248 EXPECT_EQ("prflx", ep1_ch1()->best_connection()->remote_candidate().type()); 1256 EXPECT_EQ("prflx", ep1_ch1()->best_connection()->remote_candidate().type());
1249 1257
1250 // Because we don't have a remote pwd, we don't ping yet. 1258 // Because we don't have a remote pwd, we don't ping yet.
1251 EXPECT_EQ(kIceUfrag[1], 1259 EXPECT_EQ(kIceUfrag[1],
1252 ep1_ch1()->best_connection()->remote_candidate().username()); 1260 ep1_ch1()->best_connection()->remote_candidate().username());
1253 EXPECT_EQ("", ep1_ch1()->best_connection()->remote_candidate().password()); 1261 EXPECT_EQ("", ep1_ch1()->best_connection()->remote_candidate().password());
1262 // Because we don't have ICE credentials yet, we don't know the generation.
1263 EXPECT_EQ(0u, ep1_ch1()->best_connection()->remote_candidate().generation());
1254 EXPECT_TRUE(nullptr == ep1_ch1()->FindNextPingableConnection()); 1264 EXPECT_TRUE(nullptr == ep1_ch1()->FindNextPingableConnection());
1255 1265
1266 // Add two sets of remote ICE credentials, so that the ones used by the
1267 // candidate will be generation 1 instead of 0.
1268 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]);
1256 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); 1269 ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]);
1257 ResumeCandidates(1); 1270 // After setting the remote ICE credentials, the password and generation
1258 1271 // of the peer reflexive candidate should be updated.
1259 EXPECT_EQ(kIcePwd[1], 1272 EXPECT_EQ(kIcePwd[1],
1260 ep1_ch1()->best_connection()->remote_candidate().password()); 1273 ep1_ch1()->best_connection()->remote_candidate().password());
1261 EXPECT_TRUE(nullptr != ep1_ch1()->FindNextPingableConnection()); 1274 EXPECT_EQ(1u, ep1_ch1()->best_connection()->remote_candidate().generation());
1275
1276 ResumeCandidates(1);
1262 1277
1263 const cricket::Connection* best_connection = NULL; 1278 const cricket::Connection* best_connection = NULL;
1264 WAIT((best_connection = ep2_ch1()->best_connection()) != NULL, 2000); 1279 WAIT((best_connection = ep2_ch1()->best_connection()) != NULL, 2000);
1265 1280
1266 // Wait to verify the connection is not culled. 1281 // Wait to verify the connection is not culled.
1267 WAIT(ep1_ch1()->writable(), 2000); 1282 WAIT(ep1_ch1()->writable(), 2000);
1268 EXPECT_EQ(ep2_ch1()->best_connection(), best_connection); 1283 EXPECT_EQ(ep2_ch1()->best_connection(), best_connection);
1269 EXPECT_EQ("prflx", ep1_ch1()->best_connection()->remote_candidate().type()); 1284 EXPECT_EQ("prflx", ep1_ch1()->best_connection()->remote_candidate().type());
1270 DestroyChannels(); 1285 DestroyChannels();
1271 } 1286 }
(...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after
2780 2795
2781 // TCP Relay/Relay is the next. 2796 // TCP Relay/Relay is the next.
2782 VerifyNextPingableConnection(cricket::RELAY_PORT_TYPE, 2797 VerifyNextPingableConnection(cricket::RELAY_PORT_TYPE,
2783 cricket::RELAY_PORT_TYPE, 2798 cricket::RELAY_PORT_TYPE,
2784 cricket::TCP_PROTOCOL_NAME); 2799 cricket::TCP_PROTOCOL_NAME);
2785 2800
2786 // Finally, Local/Relay will be pinged. 2801 // Finally, Local/Relay will be pinged.
2787 VerifyNextPingableConnection(cricket::LOCAL_PORT_TYPE, 2802 VerifyNextPingableConnection(cricket::LOCAL_PORT_TYPE,
2788 cricket::RELAY_PORT_TYPE); 2803 cricket::RELAY_PORT_TYPE);
2789 } 2804 }
OLDNEW
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.cc ('k') | webrtc/p2p/base/port.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698