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..ad6d64eeb53294df0550c16c1287970fbaa0fa4c 100644 |
--- a/webrtc/p2p/base/turnport_unittest.cc |
+++ b/webrtc/p2p/base/turnport_unittest.cc |
@@ -605,6 +605,35 @@ TEST_F(TurnPortTest, TestTurnAllocateBadPassword) { |
ASSERT_EQ(0U, turn_port_->Candidates().size()); |
} |
+// Tests that TURN port NONCE will be reset even when receiving an |
pthatcher1
2016/01/19 01:48:38
even when => when
honghaiz3
2016/01/20 00:54:38
Done.
|
+// ALLOCATE MISMATCH error. |
+TEST_F(TurnPortTest, TestTurnAllocateNonceRestAfterAllocateMismatch) { |
+ // 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()); |
+ // Clear connected_ flag on turnport to suppress the release of |
+ // the allocation. |
+ turn_port_->OnSocketClose(turn_port_->socket(), 0); |
+ |
+ std::string old_nonce = turn_port_->nonce(); |
+ std::string old_hash = turn_port_->hash(); |
+ // Forces the socket server to assign the same port. |
+ ss_->SetNextPortForTesting(first_addr.port()); |
+ turn_ready_ = false; |
+ CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); |
+ |
+ // These are needed in order to check that the client will reset NONCE when |
+ // receiving ALLOCATE_MISMATCH error. |
+ turn_port_->set_nonce(old_nonce); |
+ turn_port_->set_hash(old_hash); |
pthatcher1
2016/01/19 01:48:38
Instead of altering the nonce+hash of the client,
honghaiz3
2016/01/20 00:54:38
Done. We cannot directly change the NONCE but the
|
+ turn_port_->PrepareAddress(); |
+ |
+ EXPECT_TRUE_WAIT(turn_ready_, kTimeout); |
+ EXPECT_NE(old_nonce, turn_port_->nonce()); |
+} |
+ |
// Tests that a new local address is created after |
// STUN_ERROR_ALLOCATION_MISMATCH. |
TEST_F(TurnPortTest, TestTurnAllocateMismatch) { |
@@ -623,6 +652,7 @@ TEST_F(TurnPortTest, TestTurnAllocateMismatch) { |
turn_ready_ = false; |
CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); |
+ |
turn_port_->PrepareAddress(); |
// Verifies that the new port has the same address. |