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

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

Issue 2770903003: Accept remote offers with current DTLS role, rather than "actpass". (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2015 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // change its role/tie-breaker when it does an ICE restart. 265 // change its role/tie-breaker when it does an ICE restart.
266 transport2->fake_ice_transport()->SignalRoleConflict( 266 transport2->fake_ice_transport()->SignalRoleConflict(
267 transport2->fake_ice_transport()); 267 transport2->fake_ice_transport());
268 EXPECT_EQ(ICEROLE_CONTROLLING, 268 EXPECT_EQ(ICEROLE_CONTROLLING,
269 transport1->fake_ice_transport()->GetIceRole()); 269 transport1->fake_ice_transport()->GetIceRole());
270 EXPECT_EQ(ICEROLE_CONTROLLING, 270 EXPECT_EQ(ICEROLE_CONTROLLING,
271 transport2->fake_ice_transport()->GetIceRole()); 271 transport2->fake_ice_transport()->GetIceRole());
272 } 272 }
273 273
274 TEST_F(TransportControllerTest, TestGetSslRole) { 274 TEST_F(TransportControllerTest, TestGetSslRole) {
275 FakeDtlsTransport* transport = CreateFakeDtlsTransport("audio", 1);
276 ASSERT_NE(nullptr, transport);
277 ASSERT_TRUE(transport->SetSslRole(rtc::SSL_CLIENT));
278 rtc::SSLRole role; 275 rtc::SSLRole role;
276 CreateFakeDtlsTransport("audio", 1);
277
278 // Should return false before role has been negotiated.
279 EXPECT_FALSE(transport_controller_->GetSslRole("audio", &role));
280
281 // To negotiate an SSL role, need to set a local certificate, and
282 // local/remote transport descriptions with DTLS info.
283 rtc::scoped_refptr<rtc::RTCCertificate> certificate =
284 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>(
285 rtc::SSLIdentity::Generate("testing", rtc::KT_ECDSA)));
286 std::unique_ptr<rtc::SSLFingerprint> fingerprint(
287 rtc::SSLFingerprint::CreateFromCertificate(certificate));
288 transport_controller_->SetLocalCertificate(certificate);
289
290 // Set the same fingerprint on both sides since the remote fingerprint
291 // doesn't really matter for this test.
292 TransportDescription local_desc(std::vector<std::string>(), kIceUfrag1,
293 kIcePwd1, ICEMODE_FULL,
294 CONNECTIONROLE_ACTPASS, fingerprint.get());
295 TransportDescription remote_desc(std::vector<std::string>(), kIceUfrag2,
296 kIcePwd2, ICEMODE_FULL,
297 CONNECTIONROLE_ACTIVE, fingerprint.get());
298 std::string err;
299 EXPECT_TRUE(transport_controller_->SetLocalTransportDescription(
300 "audio", local_desc, cricket::CA_OFFER, &err));
301 EXPECT_TRUE(transport_controller_->SetRemoteTransportDescription(
302 "audio", remote_desc, cricket::CA_ANSWER, &err));
303
304 // Finally we can get the role. Should be "server" since the remote
305 // endpoint's role was "active".
306 EXPECT_TRUE(transport_controller_->GetSslRole("audio", &role));
307 EXPECT_EQ(rtc::SSL_SERVER, role);
308
309 // Lastly, test that GetSslRole returns false for a nonexistent transport.
279 EXPECT_FALSE(transport_controller_->GetSslRole("video", &role)); 310 EXPECT_FALSE(transport_controller_->GetSslRole("video", &role));
280 EXPECT_TRUE(transport_controller_->GetSslRole("audio", &role));
Taylor Brandstetter 2017/03/23 03:37:10 This test was just succeeding by accident before,
281 EXPECT_EQ(rtc::SSL_CLIENT, role);
282 } 311 }
283 312
284 TEST_F(TransportControllerTest, TestSetAndGetLocalCertificate) { 313 TEST_F(TransportControllerTest, TestSetAndGetLocalCertificate) {
285 rtc::scoped_refptr<rtc::RTCCertificate> certificate1 = 314 rtc::scoped_refptr<rtc::RTCCertificate> certificate1 =
286 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>( 315 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>(
287 rtc::SSLIdentity::Generate("session1", rtc::KT_DEFAULT))); 316 rtc::SSLIdentity::Generate("session1", rtc::KT_DEFAULT)));
288 rtc::scoped_refptr<rtc::RTCCertificate> certificate2 = 317 rtc::scoped_refptr<rtc::RTCCertificate> certificate2 =
289 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>( 318 rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>(
290 rtc::SSLIdentity::Generate("session2", rtc::KT_DEFAULT))); 319 rtc::SSLIdentity::Generate("session2", rtc::KT_DEFAULT)));
291 rtc::scoped_refptr<rtc::RTCCertificate> returned_certificate; 320 rtc::scoped_refptr<rtc::RTCCertificate> returned_certificate;
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 ASSERT_TRUE(transport_controller_->SetLocalTransportDescription( 869 ASSERT_TRUE(transport_controller_->SetLocalTransportDescription(
841 "audio", ice_restart_local_desc, CA_OFFER, nullptr)); 870 "audio", ice_restart_local_desc, CA_OFFER, nullptr));
842 ASSERT_TRUE(transport_controller_->SetLocalTransportDescription( 871 ASSERT_TRUE(transport_controller_->SetLocalTransportDescription(
843 "video", local_desc, CA_OFFER, nullptr)); 872 "video", local_desc, CA_OFFER, nullptr));
844 // NeedsIceRestart should still be true for video. 873 // NeedsIceRestart should still be true for video.
845 EXPECT_FALSE(transport_controller_->NeedsIceRestart("audio")); 874 EXPECT_FALSE(transport_controller_->NeedsIceRestart("audio"));
846 EXPECT_TRUE(transport_controller_->NeedsIceRestart("video")); 875 EXPECT_TRUE(transport_controller_->NeedsIceRestart("video"));
847 } 876 }
848 877
849 } // namespace cricket { 878 } // namespace cricket {
OLDNEW
« webrtc/p2p/base/jseptransport.cc ('K') | « webrtc/p2p/base/transportcontroller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698