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

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

Issue 1547373002: Cease all future TURN requests when a TURN refresh request fails. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: 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/turnport.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 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 ASSERT_TRUE(turn_port_ != nullptr); 302 ASSERT_TRUE(turn_port_ != nullptr);
303 turn_port_->PrepareAddress(); 303 turn_port_->PrepareAddress();
304 ASSERT_TRUE_WAIT(turn_ready_, kTimeout); 304 ASSERT_TRUE_WAIT(turn_ready_, kTimeout);
305 305
306 CreateUdpPort(); 306 CreateUdpPort();
307 udp_port_->PrepareAddress(); 307 udp_port_->PrepareAddress();
308 ASSERT_TRUE_WAIT(udp_ready_, kTimeout); 308 ASSERT_TRUE_WAIT(udp_ready_, kTimeout);
309 } 309 }
310 310
311 bool CheckConnectionDestroyed() { 311 bool CheckConnectionDestroyed() {
312 turn_port_->FlushRequests(); 312 turn_port_->FlushRequests(cricket::kAllRequests);
313 rtc::Thread::Current()->ProcessMessages(50); 313 rtc::Thread::Current()->ProcessMessages(50);
314 return connection_destroyed_; 314 return connection_destroyed_;
315 } 315 }
316 316
317 void TestTurnAlternateServer(cricket::ProtocolType protocol_type) { 317 void TestTurnAlternateServer(cricket::ProtocolType protocol_type) {
318 std::vector<rtc::SocketAddress> redirect_addresses; 318 std::vector<rtc::SocketAddress> redirect_addresses;
319 redirect_addresses.push_back(kTurnAlternateIntAddr); 319 redirect_addresses.push_back(kTurnAlternateIntAddr);
320 320
321 cricket::TestTurnRedirector redirector(redirect_addresses); 321 cricket::TestTurnRedirector redirector(redirect_addresses);
322 322
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 EXPECT_EQ(first_addr, turn_port_->socket()->GetLocalAddress()); 686 EXPECT_EQ(first_addr, turn_port_->socket()->GetLocalAddress());
687 687
688 EXPECT_TRUE_WAIT(turn_ready_, kTimeout); 688 EXPECT_TRUE_WAIT(turn_ready_, kTimeout);
689 689
690 // Verifies that the new port has a different address now. 690 // Verifies that the new port has a different address now.
691 EXPECT_NE(first_addr, turn_port_->socket()->GetLocalAddress()); 691 EXPECT_NE(first_addr, turn_port_->socket()->GetLocalAddress());
692 } 692 }
693 693
694 TEST_F(TurnPortTest, TestRefreshRequestGetsErrorResponse) { 694 TEST_F(TurnPortTest, TestRefreshRequestGetsErrorResponse) {
695 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); 695 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr);
696 turn_port_->PrepareAddress(); 696 PrepareTurnAndUdpPorts();
697 EXPECT_TRUE_WAIT(turn_ready_, kTimeout); 697 turn_port_->CreateConnection(udp_port_->Candidates()[0],
698 Port::ORIGIN_MESSAGE);
698 // Set bad credentials. 699 // Set bad credentials.
699 cricket::RelayCredentials bad_credentials("bad_user", "bad_pwd"); 700 cricket::RelayCredentials bad_credentials("bad_user", "bad_pwd");
700 turn_port_->set_credentials(bad_credentials); 701 turn_port_->set_credentials(bad_credentials);
701 turn_refresh_success_ = false; 702 turn_refresh_success_ = false;
702 // This sends out the first RefreshRequest with correct credentials. 703 // This sends out the first RefreshRequest with correct credentials.
703 // When this succeeds, it will schedule a new RefreshRequest with the bad 704 // When this succeeds, it will schedule a new RefreshRequest with the bad
704 // credential. 705 // credential.
705 turn_port_->FlushRequests(); 706 turn_port_->FlushRequests(cricket::TURN_REFRESH_REQUEST);
706 EXPECT_TRUE_WAIT(turn_refresh_success_, kTimeout); 707 EXPECT_TRUE_WAIT(turn_refresh_success_, kTimeout);
707 // Flush it again, it will receive a bad response. 708 // Flush it again, it will receive a bad response.
708 turn_port_->FlushRequests(); 709 turn_port_->FlushRequests(cricket::TURN_REFRESH_REQUEST);
709 EXPECT_TRUE_WAIT(!turn_refresh_success_, kTimeout); 710 EXPECT_TRUE_WAIT(!turn_refresh_success_, kTimeout);
711 EXPECT_TRUE_WAIT(!turn_port_->connected(), kTimeout);
710 EXPECT_TRUE(turn_port_->connections().empty()); 712 EXPECT_TRUE(turn_port_->connections().empty());
711 EXPECT_FALSE(turn_port_->connected()); 713 EXPECT_FALSE(turn_port_->HasRequests());
712 } 714 }
713 715
714 // Test that CreateConnection will return null if port becomes disconnected. 716 // Test that CreateConnection will return null if port becomes disconnected.
715 TEST_F(TurnPortTest, TestCreateConnectionWhenSocketClosed) { 717 TEST_F(TurnPortTest, TestCreateConnectionWhenSocketClosed) {
716 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP); 718 turn_server_.AddInternalSocket(kTurnTcpIntAddr, cricket::PROTO_TCP);
717 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr); 719 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnTcpProtoAddr);
718 PrepareTurnAndUdpPorts(); 720 PrepareTurnAndUdpPorts();
719 // Create a connection. 721 // Create a connection.
720 Connection* conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0], 722 Connection* conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0],
721 Port::ORIGIN_MESSAGE); 723 Port::ORIGIN_MESSAGE);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 Port::ORIGIN_MESSAGE); 835 Port::ORIGIN_MESSAGE);
834 ConnectConnectionDestroyedSignal(conn); 836 ConnectConnectionDestroyedSignal(conn);
835 ASSERT_TRUE(conn != NULL); 837 ASSERT_TRUE(conn != NULL);
836 ASSERT_TRUE_WAIT(turn_create_permission_success_, kTimeout); 838 ASSERT_TRUE_WAIT(turn_create_permission_success_, kTimeout);
837 turn_create_permission_success_ = false; 839 turn_create_permission_success_ = false;
838 // A create-permission-request should be pending. 840 // A create-permission-request should be pending.
839 // After the next create-permission-response is received, it will schedule 841 // After the next create-permission-response is received, it will schedule
840 // another request with bad_ufrag and bad_pwd. 842 // another request with bad_ufrag and bad_pwd.
841 cricket::RelayCredentials bad_credentials("bad_user", "bad_pwd"); 843 cricket::RelayCredentials bad_credentials("bad_user", "bad_pwd");
842 turn_port_->set_credentials(bad_credentials); 844 turn_port_->set_credentials(bad_credentials);
843 turn_port_->FlushRequests(); 845 turn_port_->FlushRequests(cricket::kAllRequests);
844 ASSERT_TRUE_WAIT(turn_create_permission_success_, kTimeout); 846 ASSERT_TRUE_WAIT(turn_create_permission_success_, kTimeout);
845 // Flush the requests again; the create-permission-request will fail. 847 // Flush the requests again; the create-permission-request will fail.
846 turn_port_->FlushRequests(); 848 turn_port_->FlushRequests(cricket::kAllRequests);
847 EXPECT_TRUE_WAIT(!turn_create_permission_success_, kTimeout); 849 EXPECT_TRUE_WAIT(!turn_create_permission_success_, kTimeout);
848 EXPECT_TRUE_WAIT(connection_destroyed_, kTimeout); 850 EXPECT_TRUE_WAIT(connection_destroyed_, kTimeout);
849 } 851 }
850 852
851 TEST_F(TurnPortTest, TestChannelBindGetErrorResponse) { 853 TEST_F(TurnPortTest, TestChannelBindGetErrorResponse) {
852 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr); 854 CreateTurnPort(kTurnUsername, kTurnPassword, kTurnUdpProtoAddr);
853 PrepareTurnAndUdpPorts(); 855 PrepareTurnAndUdpPorts();
854 Connection* conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0], 856 Connection* conn1 = turn_port_->CreateConnection(udp_port_->Candidates()[0],
855 Port::ORIGIN_MESSAGE); 857 Port::ORIGIN_MESSAGE);
856 ASSERT_TRUE(conn1 != nullptr); 858 ASSERT_TRUE(conn1 != nullptr);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 turn_port_->PrepareAddress(); 987 turn_port_->PrepareAddress();
986 ASSERT_TRUE_WAIT(turn_error_, kTimeout); 988 ASSERT_TRUE_WAIT(turn_error_, kTimeout);
987 EXPECT_TRUE(turn_port_->Candidates().empty()); 989 EXPECT_TRUE(turn_port_->Candidates().empty());
988 turn_port_.reset(); 990 turn_port_.reset();
989 rtc::Thread::Current()->Post(this, MSG_TESTFINISH); 991 rtc::Thread::Current()->Post(this, MSG_TESTFINISH);
990 // Waiting for above message to be processed. 992 // Waiting for above message to be processed.
991 ASSERT_TRUE_WAIT(test_finish_, kTimeout); 993 ASSERT_TRUE_WAIT(test_finish_, kTimeout);
992 EXPECT_EQ(last_fd_count, GetFDCount()); 994 EXPECT_EQ(last_fd_count, GetFDCount());
993 } 995 }
994 #endif 996 #endif
OLDNEW
« no previous file with comments | « webrtc/p2p/base/turnport.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698