Index: webrtc/p2p/quic/quictransportchannel_unittest.cc |
diff --git a/webrtc/p2p/quic/quictransportchannel_unittest.cc b/webrtc/p2p/quic/quictransportchannel_unittest.cc |
index 7b5b51848aae75da9cfa4964ea2bee289e33e925..a16bfd5b6592807f354035f8eaff64b9586a46b7 100644 |
--- a/webrtc/p2p/quic/quictransportchannel_unittest.cc |
+++ b/webrtc/p2p/quic/quictransportchannel_unittest.cc |
@@ -17,6 +17,7 @@ |
#include "webrtc/base/common.h" |
#include "webrtc/base/gunit.h" |
#include "webrtc/base/scoped_ptr.h" |
+#include "webrtc/base/sslfingerprint.h" |
#include "webrtc/base/sslidentity.h" |
#include "webrtc/p2p/base/faketransportcontroller.h" |
@@ -42,8 +43,10 @@ static const size_t kPacketSize = 100; |
static const int kNoWriteError = 0; |
// ICE parameters. |
-static const char kIceUfrag[] = "TESTICEUFRAG0001"; |
-static const char kIcePwd[] = "TESTICEPWD00000000000001"; |
+static const char kIceUfrag1[] = "TESTICEUFRAG0001"; |
+static const char kIcePwd1[] = "TESTICEPWD00000000000001"; |
+static const char kIceUfrag2[] = "TESTICEUFRAG0002"; |
+static const char kIcePwd2[] = "TESTICEPWD00000000000002"; |
// QUIC packet parameters. |
static const net::IPAddress kIpAddress(0, 0, 0, 0); |
@@ -125,10 +128,10 @@ class QuicTestPeer : public sigslot::has_slots<> { |
(local_ice_role == cricket::ICEROLE_CONTROLLING) ? 1 : 2); |
TransportDescription local_desc( |
- std::vector<std::string>(), kIceUfrag, kIcePwd, cricket::ICEMODE_FULL, |
+ std::vector<std::string>(), kIceUfrag1, kIcePwd1, cricket::ICEMODE_FULL, |
local_connection_role, local_fingerprint_.get()); |
TransportDescription remote_desc( |
- std::vector<std::string>(), kIceUfrag, kIcePwd, cricket::ICEMODE_FULL, |
+ std::vector<std::string>(), kIceUfrag1, kIcePwd1, cricket::ICEMODE_FULL, |
remote_connection_role, remote_fingerprint); |
quic_channel_.SetIceCredentials(local_desc.ice_ufrag, local_desc.ice_pwd); |
@@ -298,8 +301,8 @@ TEST_F(QuicTransportChannelTest, ChannelSetupIce) { |
FailableTransportChannel* channel2 = peer2_.ice_channel(); |
EXPECT_EQ(cricket::ICEROLE_CONTROLLED, channel1->GetIceRole()); |
EXPECT_EQ(2u, channel1->IceTiebreaker()); |
- EXPECT_EQ(kIceUfrag, channel1->ice_ufrag()); |
- EXPECT_EQ(kIcePwd, channel1->ice_pwd()); |
+ EXPECT_EQ(kIceUfrag1, channel1->ice_ufrag()); |
+ EXPECT_EQ(kIcePwd1, channel1->ice_pwd()); |
EXPECT_EQ(cricket::ICEROLE_CONTROLLING, channel2->GetIceRole()); |
EXPECT_EQ(1u, channel2->IceTiebreaker()); |
} |
@@ -486,3 +489,42 @@ TEST_F(QuicTransportChannelTest, IceReceivingBeforeConnected) { |
ASSERT_TRUE_WAIT(quic_connected(), kTimeoutMs); |
EXPECT_TRUE(peer1_.quic_channel()->receiving()); |
} |
+ |
+// Test that the Transport base class applies local and remote descriptions to |
+// the QUIC channel. |
+TEST_F(QuicTransportChannelTest, SetLocalAndRemoteTransportDescription) { |
+ QuicTransportChannel* quic_channel = peer1_.quic_channel(); |
+ // Set the local description. |
+ rtc::SSLFingerprint* local_fingerprint = peer1_.local_fingerprint().get(); |
+ TransportDescription local_desc( |
+ std::vector<std::string>(), kIceUfrag1, kIcePwd1, cricket::ICEMODE_FULL, |
+ cricket::CONNECTIONROLE_ACTPASS, local_fingerprint); |
+ ASSERT_TRUE(quic_channel->SetLocalTransportDescription( |
+ local_desc, cricket::CA_OFFER, nullptr)); |
+ const TransportDescription* transport_local_desc = |
+ quic_channel->local_description_for_test(); |
+ EXPECT_EQ(kIceUfrag1, transport_local_desc->ice_ufrag); |
+ EXPECT_EQ(kIcePwd1, transport_local_desc->ice_pwd); |
+ EXPECT_EQ(*local_fingerprint, *transport_local_desc->identity_fingerprint); |
+ // NegotiateTransportDescription was not called yet. The SSL role should |
+ // not be set and neither should the remote fingerprint. |
+ rtc::scoped_ptr<rtc::SSLRole> role(new rtc::SSLRole()); |
+ EXPECT_FALSE(quic_channel->GetSslRole(role.get())); |
+ // Set the remote description. |
+ rtc::SSLFingerprint* remote_fingerprint = peer2_.local_fingerprint().get(); |
+ TransportDescription remote_desc( |
+ std::vector<std::string>(), kIceUfrag2, kIcePwd2, cricket::ICEMODE_FULL, |
+ cricket::CONNECTIONROLE_PASSIVE, remote_fingerprint); |
+ ASSERT_TRUE(quic_channel->SetRemoteTransportDescription( |
+ remote_desc, cricket::CA_ANSWER, nullptr)); |
+ const TransportDescription* transport_remote_desc = |
+ quic_channel->remote_description_for_test(); |
+ EXPECT_EQ(kIceUfrag2, transport_remote_desc->ice_ufrag); |
+ EXPECT_EQ(kIcePwd2, transport_remote_desc->ice_pwd); |
+ EXPECT_EQ(*remote_fingerprint, *transport_remote_desc->identity_fingerprint); |
+ // NegotiateTransportDescription was called because the |
+ // transport description was an ANSWER. The SSL role should be set. |
+ ASSERT_TRUE(quic_channel->GetSslRole(role.get())); |
+ // SSL role should be client because the remote description is an ANSWER. |
+ EXPECT_EQ(*role, rtc::SSL_CLIENT); |
+} |