OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 ASSERT(certificate_); | 81 ASSERT(certificate_); |
82 use_dtls_srtp_ = true; | 82 use_dtls_srtp_ = true; |
83 } | 83 } |
84 void SetupMaxProtocolVersion(rtc::SSLProtocolVersion version) { | 84 void SetupMaxProtocolVersion(rtc::SSLProtocolVersion version) { |
85 ssl_max_version_ = version; | 85 ssl_max_version_ = version; |
86 } | 86 } |
87 void SetupChannels(int count, cricket::IceRole role, int async_delay_ms = 0) { | 87 void SetupChannels(int count, cricket::IceRole role, int async_delay_ms = 0) { |
88 transport_.reset( | 88 transport_.reset( |
89 new cricket::JsepTransport("dtls content name", certificate_)); | 89 new cricket::JsepTransport("dtls content name", certificate_)); |
90 for (int i = 0; i < count; ++i) { | 90 for (int i = 0; i < count; ++i) { |
91 cricket::FakeTransportChannel* fake_ice_channel = | 91 cricket::FakeIceTransport* fake_ice_channel = |
92 new cricket::FakeTransportChannel(transport_->mid(), i); | 92 new cricket::FakeIceTransport(transport_->mid(), i); |
93 fake_ice_channel->SetAsync(true); | 93 fake_ice_channel->SetAsync(true); |
94 fake_ice_channel->SetAsyncDelay(async_delay_ms); | 94 fake_ice_channel->SetAsyncDelay(async_delay_ms); |
95 // Hook the raw packets so that we can verify they are encrypted. | 95 // Hook the raw packets so that we can verify they are encrypted. |
96 fake_ice_channel->SignalReadPacket.connect( | 96 fake_ice_channel->SignalReadPacket.connect( |
97 this, &DtlsTestClient::OnFakeTransportChannelReadPacket); | 97 this, &DtlsTestClient::OnFakeTransportChannelReadPacket); |
98 | 98 |
99 cricket::DtlsTransportChannelWrapper* channel = | 99 cricket::DtlsTransportChannelWrapper* channel = |
100 new cricket::DtlsTransportChannelWrapper(fake_ice_channel); | 100 new cricket::DtlsTransportChannelWrapper(fake_ice_channel); |
101 channel->SetLocalCertificate(certificate_); | 101 channel->SetLocalCertificate(certificate_); |
102 channel->SetIceRole(role); | 102 channel->SetIceRole(role); |
103 channel->SetIceTiebreaker((role == cricket::ICEROLE_CONTROLLING) ? 1 : 2); | 103 channel->SetIceTiebreaker((role == cricket::ICEROLE_CONTROLLING) ? 1 : 2); |
104 channel->SetSslMaxProtocolVersion(ssl_max_version_); | 104 channel->SetSslMaxProtocolVersion(ssl_max_version_); |
105 channel->SignalWritableState.connect(this, | 105 channel->SignalWritableState.connect(this, |
106 &DtlsTestClient::OnTransportChannelWritableState); | 106 &DtlsTestClient::OnTransportChannelWritableState); |
107 channel->SignalReadPacket.connect(this, | 107 channel->SignalReadPacket.connect(this, |
108 &DtlsTestClient::OnTransportChannelReadPacket); | 108 &DtlsTestClient::OnTransportChannelReadPacket); |
109 channel->SignalSentPacket.connect( | 109 channel->SignalSentPacket.connect( |
110 this, &DtlsTestClient::OnTransportChannelSentPacket); | 110 this, &DtlsTestClient::OnTransportChannelSentPacket); |
111 channels_.push_back( | 111 channels_.push_back( |
112 std::unique_ptr<cricket::DtlsTransportChannelWrapper>(channel)); | 112 std::unique_ptr<cricket::DtlsTransportChannelWrapper>(channel)); |
113 fake_channels_.push_back( | 113 fake_channels_.push_back( |
114 std::unique_ptr<cricket::FakeTransportChannel>(fake_ice_channel)); | 114 std::unique_ptr<cricket::FakeIceTransport>(fake_ice_channel)); |
115 transport_->AddChannel(channel, i); | 115 transport_->AddChannel(channel, i); |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 cricket::JsepTransport* transport() { return transport_.get(); } | 119 cricket::JsepTransport* transport() { return transport_.get(); } |
120 | 120 |
121 cricket::FakeTransportChannel* GetFakeChannel(int component) { | 121 cricket::FakeIceTransport* GetFakeChannel(int component) { |
122 for (const auto& ch : fake_channels_) { | 122 for (const auto& ch : fake_channels_) { |
123 if (ch->component() == component) { | 123 if (ch->component() == component) { |
124 return ch.get(); | 124 return ch.get(); |
125 } | 125 } |
126 } | 126 } |
127 return nullptr; | 127 return nullptr; |
128 } | 128 } |
129 | 129 |
130 cricket::DtlsTransportChannelWrapper* GetDtlsChannel(int component) { | 130 cricket::DtlsTransportChannelWrapper* GetDtlsChannel(int component) { |
131 for (const auto& ch : channels_) { | 131 for (const auto& ch : channels_) { |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 ASSERT_TRUE(VerifyEncryptedPacket(data, size)); | 427 ASSERT_TRUE(VerifyEncryptedPacket(data, size)); |
428 } else if (IsRtpLeadByte(data[0])) { | 428 } else if (IsRtpLeadByte(data[0])) { |
429 ASSERT_TRUE(VerifyPacket(data, size, NULL)); | 429 ASSERT_TRUE(VerifyPacket(data, size, NULL)); |
430 } | 430 } |
431 } | 431 } |
432 } | 432 } |
433 | 433 |
434 private: | 434 private: |
435 std::string name_; | 435 std::string name_; |
436 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; | 436 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; |
437 std::vector<std::unique_ptr<cricket::FakeTransportChannel>> fake_channels_; | 437 std::vector<std::unique_ptr<cricket::FakeIceTransport>> fake_channels_; |
438 std::vector<std::unique_ptr<cricket::DtlsTransportChannelWrapper>> channels_; | 438 std::vector<std::unique_ptr<cricket::DtlsTransportChannelWrapper>> channels_; |
439 std::unique_ptr<cricket::JsepTransport> transport_; | 439 std::unique_ptr<cricket::JsepTransport> transport_; |
440 size_t packet_size_ = 0u; | 440 size_t packet_size_ = 0u; |
441 std::set<int> received_; | 441 std::set<int> received_; |
442 bool use_dtls_srtp_ = false; | 442 bool use_dtls_srtp_ = false; |
443 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12; | 443 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12; |
444 int received_dtls_client_hellos_ = 0; | 444 int received_dtls_client_hellos_ = 0; |
445 int received_dtls_server_hellos_ = 0; | 445 int received_dtls_server_hellos_ = 0; |
446 rtc::SentPacket sent_packet_; | 446 rtc::SentPacket sent_packet_; |
447 }; | 447 }; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 bool use_dtls_srtp_; | 632 bool use_dtls_srtp_; |
633 rtc::SSLProtocolVersion ssl_expected_version_; | 633 rtc::SSLProtocolVersion ssl_expected_version_; |
634 }; | 634 }; |
635 | 635 |
636 class DtlsTransportChannelTest : public DtlsTransportChannelTestBase, | 636 class DtlsTransportChannelTest : public DtlsTransportChannelTestBase, |
637 public ::testing::Test {}; | 637 public ::testing::Test {}; |
638 | 638 |
639 // Test that transport negotiation of ICE, no DTLS works properly. | 639 // Test that transport negotiation of ICE, no DTLS works properly. |
640 TEST_F(DtlsTransportChannelTest, TestChannelSetupIce) { | 640 TEST_F(DtlsTransportChannelTest, TestChannelSetupIce) { |
641 Negotiate(); | 641 Negotiate(); |
642 cricket::FakeTransportChannel* channel1 = client1_.GetFakeChannel(0); | 642 cricket::FakeIceTransport* channel1 = client1_.GetFakeChannel(0); |
643 cricket::FakeTransportChannel* channel2 = client2_.GetFakeChannel(0); | 643 cricket::FakeIceTransport* channel2 = client2_.GetFakeChannel(0); |
644 ASSERT_TRUE(channel1 != NULL); | 644 ASSERT_TRUE(channel1 != NULL); |
645 ASSERT_TRUE(channel2 != NULL); | 645 ASSERT_TRUE(channel2 != NULL); |
646 EXPECT_EQ(cricket::ICEROLE_CONTROLLING, channel1->GetIceRole()); | 646 EXPECT_EQ(cricket::ICEROLE_CONTROLLING, channel1->GetIceRole()); |
647 EXPECT_EQ(1U, channel1->IceTiebreaker()); | 647 EXPECT_EQ(1U, channel1->IceTiebreaker()); |
648 EXPECT_EQ(kIceUfrag1, channel1->ice_ufrag()); | 648 EXPECT_EQ(kIceUfrag1, channel1->ice_ufrag()); |
649 EXPECT_EQ(kIcePwd1, channel1->ice_pwd()); | 649 EXPECT_EQ(kIcePwd1, channel1->ice_pwd()); |
650 EXPECT_EQ(cricket::ICEROLE_CONTROLLED, channel2->GetIceRole()); | 650 EXPECT_EQ(cricket::ICEROLE_CONTROLLED, channel2->GetIceRole()); |
651 EXPECT_EQ(2U, channel2->IceTiebreaker()); | 651 EXPECT_EQ(2U, channel2->IceTiebreaker()); |
652 } | 652 } |
653 | 653 |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 std::vector<DtlsTransportEvent>{ | 1183 std::vector<DtlsTransportEvent>{ |
1184 CALLER_RECEIVES_CLIENTHELLO, CALLER_RECEIVES_FINGERPRINT, | 1184 CALLER_RECEIVES_CLIENTHELLO, CALLER_RECEIVES_FINGERPRINT, |
1185 CALLER_WRITABLE, HANDSHAKE_FINISHES}, | 1185 CALLER_WRITABLE, HANDSHAKE_FINISHES}, |
1186 std::vector<DtlsTransportEvent>{ | 1186 std::vector<DtlsTransportEvent>{ |
1187 CALLER_RECEIVES_CLIENTHELLO, CALLER_WRITABLE, | 1187 CALLER_RECEIVES_CLIENTHELLO, CALLER_WRITABLE, |
1188 CALLER_RECEIVES_FINGERPRINT, HANDSHAKE_FINISHES}, | 1188 CALLER_RECEIVES_FINGERPRINT, HANDSHAKE_FINISHES}, |
1189 std::vector<DtlsTransportEvent>{CALLER_RECEIVES_CLIENTHELLO, | 1189 std::vector<DtlsTransportEvent>{CALLER_RECEIVES_CLIENTHELLO, |
1190 CALLER_WRITABLE, HANDSHAKE_FINISHES, | 1190 CALLER_WRITABLE, HANDSHAKE_FINISHES, |
1191 CALLER_RECEIVES_FINGERPRINT}), | 1191 CALLER_RECEIVES_FINGERPRINT}), |
1192 ::testing::Bool())); | 1192 ::testing::Bool())); |
OLD | NEW |