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

Unified Diff: webrtc/p2p/base/turnport_unittest.cc

Issue 1595613004: Reset TURN port NONCE when a new socket is created. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Addressed comments 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/p2p/base/turnport_unittest.cc
diff --git a/webrtc/p2p/base/turnport_unittest.cc b/webrtc/p2p/base/turnport_unittest.cc
index 916162575fee803093aff79ea89afde02cae5902..dd73ff7be3466c2d58b408e873694570eeebe4eb 100644
--- a/webrtc/p2p/base/turnport_unittest.cc
+++ b/webrtc/p2p/base/turnport_unittest.cc
@@ -605,6 +605,39 @@ TEST_F(TurnPortTest, TestTurnAllocateBadPassword) {
ASSERT_EQ(0U, turn_port_->Candidates().size());
}
+// Tests that TURN port NONCE will be reset when receiving an ALLOCATE MISMATCH
pthatcher1 2016/01/29 17:37:46 NONCE => nonce, here and below
honghaiz3 2016/01/29 18:46:36 Done.
+// error.
+TEST_F(TurnPortTest, TestTurnAllocateNonceResetAfterAllocateMismatch) {
+ // Do a normal allocation first.
+ CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr);
+ turn_port_->PrepareAddress();
+ EXPECT_TRUE_WAIT(turn_ready_, kTimeout);
+ rtc::SocketAddress first_addr(turn_port_->socket()->GetLocalAddress());
+ // Destroy the turnport while keeping the drop probability to 1 to
+ // suppress the release of the allocation at the server.
+ ss_->set_drop_probability(1.0);
+ turn_port_.reset();
+ rtc::Thread::Current()->ProcessMessages(0);
+ ss_->set_drop_probability(0.0);
pthatcher1 2016/01/29 17:37:46 What's the point of doing a normal allocation firs
honghaiz3 2016/01/29 18:46:36 The first allocation is needed to generate the mis
+
+ // Force the socket server to assign the same port.
+ ss_->SetNextPortForTesting(first_addr.port());
+ turn_ready_ = false;
+ CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr);
+
+ // It is expected that the turn port will first get a NONCE from the server
+ // using timestamp |now| but then get an allocate mismatch error and receive
+ // an even newer NONCE based on the system clock. |now| is chosen so that
+ // the two NONCEs generated by the server will be different.
+ uint32_t now = rtc::Time() - 1;
pthatcher1 2016/01/29 17:37:46 Well it's not really "now", is it? Isn't it "befo
honghaiz3 2016/01/29 18:46:36 Done.
+ turn_server_.server()->SetTimestampForNextNonce(now);
+ std::string next_nonce = turn_server_.server()->GenerateNonce(now);
pthatcher1 2016/01/29 17:37:46 Wouldn't a better name be first_nonce?
honghaiz3 2016/01/29 18:46:36 Done.
+ turn_port_->PrepareAddress();
+
+ EXPECT_TRUE_WAIT(turn_ready_, kTimeout);
+ EXPECT_NE(next_nonce, turn_port_->nonce());
+}
+
// Tests that a new local address is created after
// STUN_ERROR_ALLOCATION_MISMATCH.
TEST_F(TurnPortTest, TestTurnAllocateMismatch) {

Powered by Google App Engine
This is Rietveld 408576698