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

Side by Side Diff: webrtc/api/peerconnectioninterface_unittest.cc

Issue 2641633002: Only set certificate on DTLS transport if fingerprint is found in SDP. (Closed)
Patch Set: Fix tests by making FakeTransportController::Connect put fingerprints in transport descriptions. Created 3 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 | « no previous file | webrtc/api/test/fakertccertificategenerator.h » ('j') | 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 10
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 "a=ssrc:2 msid:stream1 videotrack0\r\n"; 286 "a=ssrc:2 msid:stream1 videotrack0\r\n";
287 287
288 static const char kSdpStringMs1Audio1[] = 288 static const char kSdpStringMs1Audio1[] =
289 "a=ssrc:3 cname:stream1\r\n" 289 "a=ssrc:3 cname:stream1\r\n"
290 "a=ssrc:3 msid:stream1 audiotrack1\r\n"; 290 "a=ssrc:3 msid:stream1 audiotrack1\r\n";
291 291
292 static const char kSdpStringMs1Video1[] = 292 static const char kSdpStringMs1Video1[] =
293 "a=ssrc:4 cname:stream1\r\n" 293 "a=ssrc:4 cname:stream1\r\n"
294 "a=ssrc:4 msid:stream1 videotrack1\r\n"; 294 "a=ssrc:4 msid:stream1 videotrack1\r\n";
295 295
296 static const char kDtlsSdesFallbackSdp[] =
297 "v=0\r\n"
298 "o=xxxxxx 7 2 IN IP4 0.0.0.0\r\n"
299 "s=-\r\n"
300 "c=IN IP4 0.0.0.0\r\n"
301 "t=0 0\r\n"
302 "a=group:BUNDLE audio\r\n"
303 "a=msid-semantic: WMS\r\n"
304 "m=audio 1 RTP/SAVPF 0\r\n"
305 "a=sendrecv\r\n"
306 "a=rtcp-mux\r\n"
307 "a=mid:audio\r\n"
308 "a=ssrc:1 cname:stream1\r\n"
309 "a=ssrc:1 mslabel:stream1\r\n"
310 "a=ssrc:1 label:audiotrack0\r\n"
311 "a=ice-ufrag:e5785931\r\n"
312 "a=ice-pwd:36fb7878390db89481c1d46daa4278d8\r\n"
313 "a=rtpmap:0 pcmu/8000\r\n"
314 "a=fingerprint:sha-1 "
315 "4A:AD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B:19:E5:7C:AB\r\n"
316 "a=setup:actpass\r\n"
317 "a=crypto:1 AES_CM_128_HMAC_SHA1_32 "
318 "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32 "
319 "dummy_session_params\r\n";
320
296 #define MAYBE_SKIP_TEST(feature) \ 321 #define MAYBE_SKIP_TEST(feature) \
297 if (!(feature())) { \ 322 if (!(feature())) { \
298 LOG(LS_INFO) << "Feature disabled... skipping"; \ 323 LOG(LS_INFO) << "Feature disabled... skipping"; \
299 return; \ 324 return; \
300 } 325 }
301 326
302 using ::testing::Exactly; 327 using ::testing::Exactly;
303 using cricket::StreamParams; 328 using cricket::StreamParams;
304 using webrtc::AudioSourceInterface; 329 using webrtc::AudioSourceInterface;
305 using webrtc::AudioTrack; 330 using webrtc::AudioTrack;
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 std::unique_ptr<cricket::FakePortAllocator> port_allocator( 759 std::unique_ptr<cricket::FakePortAllocator> port_allocator(
735 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr)); 760 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr));
736 port_allocator_ = port_allocator.get(); 761 port_allocator_ = port_allocator.get();
737 762
738 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator; 763 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator;
739 bool dtls; 764 bool dtls;
740 if (FindConstraint(constraints, 765 if (FindConstraint(constraints,
741 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, 766 webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
742 &dtls, 767 &dtls,
743 nullptr) && dtls) { 768 nullptr) && dtls) {
744 cert_generator.reset(new FakeRTCCertificateGenerator()); 769 fake_certificate_generator_ = new FakeRTCCertificateGenerator();
770 cert_generator.reset(fake_certificate_generator_);
745 } 771 }
746 pc_ = pc_factory_->CreatePeerConnection( 772 pc_ = pc_factory_->CreatePeerConnection(
747 config, constraints, std::move(port_allocator), 773 config, constraints, std::move(port_allocator),
748 std::move(cert_generator), &observer_); 774 std::move(cert_generator), &observer_);
749 ASSERT_TRUE(pc_.get() != NULL); 775 ASSERT_TRUE(pc_.get() != NULL);
750 observer_.SetPeerConnectionInterface(pc_.get()); 776 observer_.SetPeerConnectionInterface(pc_.get());
751 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_); 777 EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_);
752 } 778 }
753 779
754 void CreatePeerConnectionExpectFail(const std::string& uri) { 780 void CreatePeerConnectionExpectFail(const std::string& uri) {
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 const SessionDescriptionInterface* desc) { 1154 const SessionDescriptionInterface* desc) {
1129 const cricket::ContentInfo* audio_content = 1155 const cricket::ContentInfo* audio_content =
1130 cricket::GetFirstAudioContent(desc->description()); 1156 cricket::GetFirstAudioContent(desc->description());
1131 const cricket::AudioContentDescription* audio_desc = 1157 const cricket::AudioContentDescription* audio_desc =
1132 static_cast<const cricket::AudioContentDescription*>( 1158 static_cast<const cricket::AudioContentDescription*>(
1133 audio_content->description); 1159 audio_content->description);
1134 return audio_desc->streams()[0].cname; 1160 return audio_desc->streams()[0].cname;
1135 } 1161 }
1136 1162
1137 cricket::FakePortAllocator* port_allocator_ = nullptr; 1163 cricket::FakePortAllocator* port_allocator_ = nullptr;
1164 FakeRTCCertificateGenerator* fake_certificate_generator_ = nullptr;
1138 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_; 1165 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_;
1139 rtc::scoped_refptr<PeerConnectionFactoryForTest> pc_factory_for_test_; 1166 rtc::scoped_refptr<PeerConnectionFactoryForTest> pc_factory_for_test_;
1140 rtc::scoped_refptr<PeerConnectionInterface> pc_; 1167 rtc::scoped_refptr<PeerConnectionInterface> pc_;
1141 MockPeerConnectionObserver observer_; 1168 MockPeerConnectionObserver observer_;
1142 rtc::scoped_refptr<StreamCollection> reference_collection_; 1169 rtc::scoped_refptr<StreamCollection> reference_collection_;
1143 }; 1170 };
1144 1171
1145 // Test that no callbacks on the PeerConnectionObserver are called after the 1172 // Test that no callbacks on the PeerConnectionObserver are called after the
1146 // PeerConnection is closed. 1173 // PeerConnection is closed.
1147 TEST_F(PeerConnectionInterfaceTest, CloseAndTestCallbackFunctions) { 1174 TEST_F(PeerConnectionInterfaceTest, CloseAndTestCallbackFunctions) {
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 ASSERT_TRUE(content != NULL); 2093 ASSERT_TRUE(content != NULL);
2067 EXPECT_FALSE(content->rejected); 2094 EXPECT_FALSE(content->rejected);
2068 #ifdef HAVE_SCTP 2095 #ifdef HAVE_SCTP
2069 content = 2096 content =
2070 cricket::GetFirstDataContent(pc_->local_description()->description()); 2097 cricket::GetFirstDataContent(pc_->local_description()->description());
2071 ASSERT_TRUE(content != NULL); 2098 ASSERT_TRUE(content != NULL);
2072 EXPECT_TRUE(content->rejected); 2099 EXPECT_TRUE(content->rejected);
2073 #endif 2100 #endif
2074 } 2101 }
2075 2102
2103 // Test that an offer can be received which offers DTLS with SDES fallback.
2104 // Regression test for issue:
2105 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6972
2106 TEST_F(PeerConnectionInterfaceTest, ReceiveDtlsSdesFallbackOffer) {
2107 FakeConstraints constraints;
2108 constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
2109 true);
2110 CreatePeerConnection(&constraints);
2111 // Wait for fake certificate to be generated. Previously, this is what caused
2112 // the "a=crypto" lines to be rejected.
2113 AddAudioVideoStream(kStreamLabel1, "audio_label", "video_label");
2114 ASSERT_NE(nullptr, fake_certificate_generator_);
2115 EXPECT_EQ_WAIT(1, fake_certificate_generator_->generated_certificates(),
2116 kTimeout);
2117 SessionDescriptionInterface* desc = webrtc::CreateSessionDescription(
2118 SessionDescriptionInterface::kOffer, kDtlsSdesFallbackSdp, nullptr);
2119 EXPECT_TRUE(DoSetSessionDescription(desc, false));
2120 CreateAnswerAsLocalDescription();
2121 }
2122
2076 // Test that we can create an audio only offer and receive an answer with a 2123 // Test that we can create an audio only offer and receive an answer with a
2077 // limited set of audio codecs and receive an updated offer with more audio 2124 // limited set of audio codecs and receive an updated offer with more audio
2078 // codecs, where the added codecs are not supported. 2125 // codecs, where the added codecs are not supported.
2079 TEST_F(PeerConnectionInterfaceTest, ReceiveUpdatedAudioOfferWithBadCodecs) { 2126 TEST_F(PeerConnectionInterfaceTest, ReceiveUpdatedAudioOfferWithBadCodecs) {
2080 CreatePeerConnectionWithoutDtls(); 2127 CreatePeerConnectionWithoutDtls();
2081 AddVoiceStream("audio_label"); 2128 AddVoiceStream("audio_label");
2082 CreateOfferAsLocalDescription(); 2129 CreateOfferAsLocalDescription();
2083 2130
2084 SessionDescriptionInterface* answer = 2131 SessionDescriptionInterface* answer =
2085 webrtc::CreateSessionDescription(SessionDescriptionInterface::kAnswer, 2132 webrtc::CreateSessionDescription(SessionDescriptionInterface::kAnswer,
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
3356 EXPECT_NE(a, f); 3403 EXPECT_NE(a, f);
3357 3404
3358 PeerConnectionInterface::RTCConfiguration g; 3405 PeerConnectionInterface::RTCConfiguration g;
3359 g.disable_ipv6 = true; 3406 g.disable_ipv6 = true;
3360 EXPECT_NE(a, g); 3407 EXPECT_NE(a, g);
3361 3408
3362 PeerConnectionInterface::RTCConfiguration h( 3409 PeerConnectionInterface::RTCConfiguration h(
3363 PeerConnectionInterface::RTCConfigurationType::kAggressive); 3410 PeerConnectionInterface::RTCConfigurationType::kAggressive);
3364 EXPECT_NE(a, h); 3411 EXPECT_NE(a, h);
3365 } 3412 }
OLDNEW
« no previous file with comments | « no previous file | webrtc/api/test/fakertccertificategenerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698