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

Side by Side Diff: talk/app/webrtc/webrtcsdp_unittest.cc

Issue 1196403004: Prevent JS from bypassing RTP data channel bandwidth limitation. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Removing accidentally copied line Created 5 years, 6 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
« talk/app/webrtc/webrtcsdp.cc ('K') | « talk/app/webrtc/webrtcsdp.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 * libjingle 2 * libjingle
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithDataChannelAndBandwidth) { 1691 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithDataChannelAndBandwidth) {
1692 AddRtpDataChannel(); 1692 AddRtpDataChannel();
1693 data_desc_->set_bandwidth(100*1000); 1693 data_desc_->set_bandwidth(100*1000);
1694 JsepSessionDescription jsep_desc(kDummyString); 1694 JsepSessionDescription jsep_desc(kDummyString);
1695 1695
1696 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); 1696 ASSERT_TRUE(jsep_desc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
1697 std::string message = webrtc::SdpSerialize(jsep_desc); 1697 std::string message = webrtc::SdpSerialize(jsep_desc);
1698 1698
1699 std::string expected_sdp = kSdpString; 1699 std::string expected_sdp = kSdpString;
1700 expected_sdp.append(kSdpRtpDataChannelString); 1700 expected_sdp.append(kSdpRtpDataChannelString);
1701 // We want to test that serializing data content ignores bandwidth 1701 // Serializing data content shouldn't ignore bandwidth settings.
1702 // settings (it should always be the default). Thus, we don't do
1703 // the following:
1704 // TODO(pthatcher): We need to temporarily allow the SDP to control
1705 // this for backwards-compatibility. Once we don't need that any
1706 // more, remove this.
1707 InjectAfter("m=application 9 RTP/SAVPF 101\r\nc=IN IP4 0.0.0.0\r\n", 1702 InjectAfter("m=application 9 RTP/SAVPF 101\r\nc=IN IP4 0.0.0.0\r\n",
1708 "b=AS:100\r\n", 1703 "b=AS:100\r\n",
1709 &expected_sdp); 1704 &expected_sdp);
1710 EXPECT_EQ(expected_sdp, message); 1705 EXPECT_EQ(expected_sdp, message);
1711 } 1706 }
1712 1707
1713 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmap) { 1708 TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithExtmap) {
1714 AddExtmap(); 1709 AddExtmap();
1715 JsepSessionDescription desc_with_extmap("dummy"); 1710 JsepSessionDescription desc_with_extmap("dummy");
1716 ASSERT_TRUE(desc_with_extmap.Initialize(desc_.Copy(), 1711 ASSERT_TRUE(desc_with_extmap.Initialize(desc_.Copy(),
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 unusual_portstr, strlen(unusual_portstr), 2249 unusual_portstr, strlen(unusual_portstr),
2255 &sdp_with_data); 2250 &sdp_with_data);
2256 2251
2257 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output)); 2252 EXPECT_TRUE(SdpDeserialize(sdp_with_data, &jdesc_output));
2258 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output)); 2253 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_output));
2259 } 2254 }
2260 2255
2261 TEST_F(WebRtcSdpTest, DeserializeSdpWithRtpDataChannelsAndBandwidth) { 2256 TEST_F(WebRtcSdpTest, DeserializeSdpWithRtpDataChannelsAndBandwidth) {
2262 AddRtpDataChannel(); 2257 AddRtpDataChannel();
2263 JsepSessionDescription jdesc(kDummyString); 2258 JsepSessionDescription jdesc(kDummyString);
2264 // We want to test that deserializing data content ignores bandwidth 2259 // We want to test that deserializing data content limits bandwidth
2265 // settings (it should always be the default). Thus, we don't do 2260 // settings (it should never be greater than the default).
2266 // the following: 2261 // This should prevent someone from using unlimited data bandwidth through
2267 // TODO(pthatcher): We need to temporarily allow the SDP to control 2262 // JS and "breaking the Internet".
2268 // this for backwards-compatibility. Once we don't need that any
2269 // more, remove this.
2270 DataContentDescription* dcd = static_cast<DataContentDescription*>( 2263 DataContentDescription* dcd = static_cast<DataContentDescription*>(
2271 GetFirstDataContent(&desc_)->description); 2264 GetFirstDataContent(&desc_)->description);
2272 dcd->set_bandwidth(100 * 1000); 2265 dcd->set_bandwidth(100 * 1000);
2273 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion)); 2266 ASSERT_TRUE(jdesc.Initialize(desc_.Copy(), kSessionId, kSessionVersion));
2274 2267
2275 std::string sdp_with_bandwidth = kSdpString; 2268 std::string sdp_with_bandwidth = kSdpString;
2276 sdp_with_bandwidth.append(kSdpRtpDataChannelString); 2269 sdp_with_bandwidth.append(kSdpRtpDataChannelString);
2277 InjectAfter("a=mid:data_content_name\r\n", 2270 InjectAfter("a=mid:data_content_name\r\n",
2278 "b=AS:100\r\n", 2271 "b=AS:100\r\n",
2279 &sdp_with_bandwidth); 2272 &sdp_with_bandwidth);
2280 JsepSessionDescription jdesc_with_bandwidth(kDummyString); 2273 JsepSessionDescription jdesc_with_bandwidth(kDummyString);
2281 2274
2282 EXPECT_TRUE( 2275 EXPECT_FALSE(SdpDeserialize(sdp_with_bandwidth, &jdesc_with_bandwidth));
2283 SdpDeserialize(sdp_with_bandwidth, &jdesc_with_bandwidth));
2284 EXPECT_TRUE(CompareSessionDescription(jdesc, jdesc_with_bandwidth));
2285 } 2276 }
2286 2277
2287 TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithSessionLevelExtmap) { 2278 TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithSessionLevelExtmap) {
2288 TestDeserializeExtmap(true, false); 2279 TestDeserializeExtmap(true, false);
2289 } 2280 }
2290 2281
2291 TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithMediaLevelExtmap) { 2282 TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithMediaLevelExtmap) {
2292 TestDeserializeExtmap(false, true); 2283 TestDeserializeExtmap(false, true);
2293 } 2284 }
2294 2285
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
2709 const cricket::MediaContentDescription* mdesc = 2700 const cricket::MediaContentDescription* mdesc =
2710 static_cast<const cricket::MediaContentDescription*>( 2701 static_cast<const cricket::MediaContentDescription*>(
2711 desc->contents()[i].description); 2702 desc->contents()[i].description);
2712 EXPECT_EQ(media_types[media_content_in_sdp[i]], mdesc->type()); 2703 EXPECT_EQ(media_types[media_content_in_sdp[i]], mdesc->type());
2713 } 2704 }
2714 2705
2715 std::string serialized_sdp = webrtc::SdpSerialize(jdesc); 2706 std::string serialized_sdp = webrtc::SdpSerialize(jdesc);
2716 EXPECT_EQ(sdp_string, serialized_sdp); 2707 EXPECT_EQ(sdp_string, serialized_sdp);
2717 } 2708 }
2718 } 2709 }
OLDNEW
« talk/app/webrtc/webrtcsdp.cc ('K') | « talk/app/webrtc/webrtcsdp.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698