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

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

Issue 2224563004: Add signaling to support ICE renomination. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Merge Created 4 years, 3 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/transportdescriptionfactory.cc ('k') | webrtc/p2p/quic/quictransportchannel.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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 EXPECT_EQ(desc->identity_fingerprint->algorithm, dtls_alg); 52 EXPECT_EQ(desc->identity_fingerprint->algorithm, dtls_alg);
53 EXPECT_GT(desc->identity_fingerprint->digest.size(), 0U); 53 EXPECT_GT(desc->identity_fingerprint->digest.size(), 0U);
54 } 54 }
55 } 55 }
56 56
57 // This test ice restart by doing two offer answer exchanges. On the second 57 // This test ice restart by doing two offer answer exchanges. On the second
58 // exchange ice is restarted. The test verifies that the ufrag and password 58 // exchange ice is restarted. The test verifies that the ufrag and password
59 // in the offer and answer is changed. 59 // in the offer and answer is changed.
60 // If |dtls| is true, the test verifies that the finger print is not changed. 60 // If |dtls| is true, the test verifies that the finger print is not changed.
61 void TestIceRestart(bool dtls) { 61 void TestIceRestart(bool dtls) {
62 if (dtls) { 62 SetDtls(dtls);
63 f1_.set_secure(cricket::SEC_ENABLED);
64 f2_.set_secure(cricket::SEC_ENABLED);
65 f1_.set_certificate(cert1_);
66 f2_.set_certificate(cert2_);
67 } else {
68 f1_.set_secure(cricket::SEC_DISABLED);
69 f2_.set_secure(cricket::SEC_DISABLED);
70 }
71
72 cricket::TransportOptions options; 63 cricket::TransportOptions options;
73 // The initial offer / answer exchange. 64 // The initial offer / answer exchange.
74 std::unique_ptr<TransportDescription> offer(f1_.CreateOffer(options, NULL)); 65 std::unique_ptr<TransportDescription> offer(f1_.CreateOffer(options, NULL));
75 std::unique_ptr<TransportDescription> answer( 66 std::unique_ptr<TransportDescription> answer(
76 f2_.CreateAnswer(offer.get(), options, NULL)); 67 f2_.CreateAnswer(offer.get(), options, NULL));
77 68
78 // Create an updated offer where we restart ice. 69 // Create an updated offer where we restart ice.
79 options.ice_restart = true; 70 options.ice_restart = true;
80 std::unique_ptr<TransportDescription> restart_offer( 71 std::unique_ptr<TransportDescription> restart_offer(
81 f1_.CreateOffer(options, offer.get())); 72 f1_.CreateOffer(options, offer.get()));
(...skipping 20 matching lines...) Expand all
102 restart_desc->ice_pwd.size()); 93 restart_desc->ice_pwd.size());
103 // If DTLS is enabled, make sure the finger print is unchanged. 94 // If DTLS is enabled, make sure the finger print is unchanged.
104 if (dtls) { 95 if (dtls) {
105 EXPECT_FALSE( 96 EXPECT_FALSE(
106 org_desc->identity_fingerprint->GetRfc4572Fingerprint().empty()); 97 org_desc->identity_fingerprint->GetRfc4572Fingerprint().empty());
107 EXPECT_EQ(org_desc->identity_fingerprint->GetRfc4572Fingerprint(), 98 EXPECT_EQ(org_desc->identity_fingerprint->GetRfc4572Fingerprint(),
108 restart_desc->identity_fingerprint->GetRfc4572Fingerprint()); 99 restart_desc->identity_fingerprint->GetRfc4572Fingerprint());
109 } 100 }
110 } 101 }
111 102
103 void TestIceRenomination(bool dtls) {
104 SetDtls(dtls);
105
106 cricket::TransportOptions options;
107 // The initial offer / answer exchange.
108 std::unique_ptr<TransportDescription> offer(
109 f1_.CreateOffer(options, nullptr));
110 std::unique_ptr<TransportDescription> answer(
111 f2_.CreateAnswer(offer.get(), options, nullptr));
112 VerifyRenomination(offer.get(), false);
113 VerifyRenomination(answer.get(), false);
114
115 options.enable_ice_renomination = true;
116 std::unique_ptr<TransportDescription> renomination_offer(
117 f1_.CreateOffer(options, offer.get()));
118 VerifyRenomination(renomination_offer.get(), true);
119
120 std::unique_ptr<TransportDescription> renomination_answer(
121 f2_.CreateAnswer(renomination_offer.get(), options, answer.get()));
122 VerifyRenomination(renomination_answer.get(), true);
123 }
124
112 protected: 125 protected:
126 void VerifyRenomination(TransportDescription* desc,
127 bool renomination_expected) {
128 ASSERT_TRUE(desc != nullptr);
129 std::vector<std::string>& options = desc->transport_options;
130 auto iter = std::find(options.begin(), options.end(),
131 cricket::ICE_RENOMINATION_STR);
132 EXPECT_EQ(renomination_expected, iter != options.end());
133 }
134
135 void SetDtls(bool dtls) {
136 if (dtls) {
137 f1_.set_secure(cricket::SEC_ENABLED);
138 f2_.set_secure(cricket::SEC_ENABLED);
139 f1_.set_certificate(cert1_);
140 f2_.set_certificate(cert2_);
141 } else {
142 f1_.set_secure(cricket::SEC_DISABLED);
143 f2_.set_secure(cricket::SEC_DISABLED);
144 }
145 }
146
113 TransportDescriptionFactory f1_; 147 TransportDescriptionFactory f1_;
114 TransportDescriptionFactory f2_; 148 TransportDescriptionFactory f2_;
115 149
116 rtc::scoped_refptr<rtc::RTCCertificate> cert1_; 150 rtc::scoped_refptr<rtc::RTCCertificate> cert1_;
117 rtc::scoped_refptr<rtc::RTCCertificate> cert2_; 151 rtc::scoped_refptr<rtc::RTCCertificate> cert2_;
118 }; 152 };
119 153
120 TEST_F(TransportDescriptionFactoryTest, TestOfferDefault) { 154 TEST_F(TransportDescriptionFactoryTest, TestOfferDefault) {
121 std::unique_ptr<TransportDescription> desc( 155 std::unique_ptr<TransportDescription> desc(
122 f1_.CreateOffer(TransportOptions(), NULL)); 156 f1_.CreateOffer(TransportOptions(), NULL));
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // if |TransportDescriptionOptions::ice_restart| is true. 283 // if |TransportDescriptionOptions::ice_restart| is true.
250 TEST_F(TransportDescriptionFactoryTest, TestIceRestart) { 284 TEST_F(TransportDescriptionFactoryTest, TestIceRestart) {
251 TestIceRestart(false); 285 TestIceRestart(false);
252 } 286 }
253 287
254 // Test that ice ufrag and password is changed in an updated offer and answer 288 // Test that ice ufrag and password is changed in an updated offer and answer
255 // if |TransportDescriptionOptions::ice_restart| is true and DTLS is enabled. 289 // if |TransportDescriptionOptions::ice_restart| is true and DTLS is enabled.
256 TEST_F(TransportDescriptionFactoryTest, TestIceRestartWithDtls) { 290 TEST_F(TransportDescriptionFactoryTest, TestIceRestartWithDtls) {
257 TestIceRestart(true); 291 TestIceRestart(true);
258 } 292 }
293
294 // Test that ice renomination is set in an updated offer and answer
295 // if |TransportDescriptionOptions::enable_ice_renomination| is true.
296 TEST_F(TransportDescriptionFactoryTest, TestIceRenomination) {
297 TestIceRenomination(false);
298 }
299
300 // Test that ice renomination is set in an updated offer and answer
301 // if |TransportDescriptionOptions::enable_ice_renomination| is true and DTLS
302 // is enabled.
303 TEST_F(TransportDescriptionFactoryTest, TestIceRenominationWithDtls) {
304 TestIceRenomination(true);
305 }
OLDNEW
« no previous file with comments | « webrtc/p2p/base/transportdescriptionfactory.cc ('k') | webrtc/p2p/quic/quictransportchannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698