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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
598 } | 598 } |
599 | 599 |
600 // Try to do a TURN allocation with an invalid password. | 600 // Try to do a TURN allocation with an invalid password. |
601 TEST_F(TurnPortTest, TestTurnAllocateBadPassword) { | 601 TEST_F(TurnPortTest, TestTurnAllocateBadPassword) { |
602 CreateTurnPort(kTurnUsername, "bad", kTurnUdpProtoAddr); | 602 CreateTurnPort(kTurnUsername, "bad", kTurnUdpProtoAddr); |
603 turn_port_->PrepareAddress(); | 603 turn_port_->PrepareAddress(); |
604 EXPECT_TRUE_WAIT(turn_error_, kTimeout); | 604 EXPECT_TRUE_WAIT(turn_error_, kTimeout); |
605 ASSERT_EQ(0U, turn_port_->Candidates().size()); | 605 ASSERT_EQ(0U, turn_port_->Candidates().size()); |
606 } | 606 } |
607 | 607 |
608 // Tests that TURN port NONCE will be reset when receiving an ALLOCATE MISMATCH | |
609 // error. | |
610 TEST_F(TurnPortTest, TestTurnAllocateNonceRestAfterAllocateMismatch) { | |
Taylor Brandstetter
2016/01/26 02:02:06
"NonceReset" instead of "NonceRest"
honghaiz3
2016/01/27 01:45:23
Done.
| |
611 // Do a normal allocation first. | |
612 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); | |
613 turn_port_->PrepareAddress(); | |
614 EXPECT_TRUE_WAIT(turn_ready_, kTimeout); | |
615 rtc::SocketAddress first_addr(turn_port_->socket()->GetLocalAddress()); | |
616 // Clear connected_ flag on turnport to suppress the release of | |
617 // the allocation. | |
618 turn_port_->OnSocketClose(turn_port_->socket(), 0); | |
Taylor Brandstetter
2016/01/26 02:02:06
I don't think it's ideal to call "OnSocketClose" i
honghaiz3
2016/01/27 01:45:23
Done.
| |
619 | |
620 // Force the socket server to assign the same port. | |
621 ss_->SetNextPortForTesting(first_addr.port()); | |
622 turn_ready_ = false; | |
623 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); | |
624 | |
625 // Make sure the next timestamp will be different from |now|, so that the two | |
626 // NONCE generated by the server will be different. | |
Taylor Brandstetter
2016/01/26 02:02:06
I would also add a comment saying: "It's expected
honghaiz3
2016/01/27 01:45:23
Done. Text is slightly different though.
| |
627 uint32_t now = rtc::Time() - 1; | |
628 turn_server_.server()->SetTimestampForNextNonce(now); | |
629 std::string next_nonce = turn_server_.server()->GenerateNonce(now); | |
630 turn_port_->PrepareAddress(); | |
631 | |
632 EXPECT_TRUE_WAIT(turn_ready_, kTimeout); | |
633 EXPECT_NE(next_nonce, turn_port_->nonce()); | |
634 } | |
635 | |
608 // Tests that a new local address is created after | 636 // Tests that a new local address is created after |
609 // STUN_ERROR_ALLOCATION_MISMATCH. | 637 // STUN_ERROR_ALLOCATION_MISMATCH. |
610 TEST_F(TurnPortTest, TestTurnAllocateMismatch) { | 638 TEST_F(TurnPortTest, TestTurnAllocateMismatch) { |
611 // Do a normal allocation first. | 639 // Do a normal allocation first. |
612 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); | 640 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); |
613 turn_port_->PrepareAddress(); | 641 turn_port_->PrepareAddress(); |
614 EXPECT_TRUE_WAIT(turn_ready_, kTimeout); | 642 EXPECT_TRUE_WAIT(turn_ready_, kTimeout); |
615 rtc::SocketAddress first_addr(turn_port_->socket()->GetLocalAddress()); | 643 rtc::SocketAddress first_addr(turn_port_->socket()->GetLocalAddress()); |
616 | 644 |
617 // Clear connected_ flag on turnport to suppress the release of | 645 // Clear connected_ flag on turnport to suppress the release of |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
991 turn_port_->PrepareAddress(); | 1019 turn_port_->PrepareAddress(); |
992 ASSERT_TRUE_WAIT(turn_error_, kResolverTimeout); | 1020 ASSERT_TRUE_WAIT(turn_error_, kResolverTimeout); |
993 EXPECT_TRUE(turn_port_->Candidates().empty()); | 1021 EXPECT_TRUE(turn_port_->Candidates().empty()); |
994 turn_port_.reset(); | 1022 turn_port_.reset(); |
995 rtc::Thread::Current()->Post(this, MSG_TESTFINISH); | 1023 rtc::Thread::Current()->Post(this, MSG_TESTFINISH); |
996 // Waiting for above message to be processed. | 1024 // Waiting for above message to be processed. |
997 ASSERT_TRUE_WAIT(test_finish_, kTimeout); | 1025 ASSERT_TRUE_WAIT(test_finish_, kTimeout); |
998 EXPECT_EQ(last_fd_count, GetFDCount()); | 1026 EXPECT_EQ(last_fd_count, GetFDCount()); |
999 } | 1027 } |
1000 #endif | 1028 #endif |
OLD | NEW |