OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 static const char kVideoTrackLabelBase[] = "video_track"; | 106 static const char kVideoTrackLabelBase[] = "video_track"; |
107 static const char kAudioTrackLabelBase[] = "audio_track"; | 107 static const char kAudioTrackLabelBase[] = "audio_track"; |
108 static const char kDataChannelLabel[] = "data_channel"; | 108 static const char kDataChannelLabel[] = "data_channel"; |
109 | 109 |
110 // Disable for TSan v2, see | 110 // Disable for TSan v2, see |
111 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. | 111 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. |
112 // This declaration is also #ifdef'd as it causes unused-variable errors. | 112 // This declaration is also #ifdef'd as it causes unused-variable errors. |
113 #if !defined(THREAD_SANITIZER) | 113 #if !defined(THREAD_SANITIZER) |
114 // SRTP cipher name negotiated by the tests. This must be updated if the | 114 // SRTP cipher name negotiated by the tests. This must be updated if the |
115 // default changes. | 115 // default changes. |
116 static const char kDefaultSrtpCipher[] = "AES_CM_128_HMAC_SHA1_32"; | 116 static const int kDefaultSrtpCryptoSuite = rtc::SRTP_AES128_CM_SHA1_32; |
117 #endif | 117 #endif |
118 | 118 |
119 static void RemoveLinesFromSdp(const std::string& line_start, | 119 static void RemoveLinesFromSdp(const std::string& line_start, |
120 std::string* sdp) { | 120 std::string* sdp) { |
121 const char kSdpLineEnd[] = "\r\n"; | 121 const char kSdpLineEnd[] = "\r\n"; |
122 size_t ssrc_pos = 0; | 122 size_t ssrc_pos = 0; |
123 while ((ssrc_pos = sdp->find(line_start, ssrc_pos)) != | 123 while ((ssrc_pos = sdp->find(line_start, ssrc_pos)) != |
124 std::string::npos) { | 124 std::string::npos) { |
125 size_t end_ssrc = sdp->find(kSdpLineEnd, ssrc_pos); | 125 size_t end_ssrc = sdp->find(kSdpLineEnd, ssrc_pos); |
126 sdp->erase(ssrc_pos, end_ssrc - ssrc_pos + strlen(kSdpLineEnd)); | 126 sdp->erase(ssrc_pos, end_ssrc - ssrc_pos + strlen(kSdpLineEnd)); |
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; | 1320 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; |
1321 PeerConnectionFactory::Options recv_options; | 1321 PeerConnectionFactory::Options recv_options; |
1322 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; | 1322 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; |
1323 ASSERT_TRUE( | 1323 ASSERT_TRUE( |
1324 CreateTestClients(nullptr, &init_options, nullptr, &recv_options)); | 1324 CreateTestClients(nullptr, &init_options, nullptr, &recv_options)); |
1325 rtc::scoped_refptr<webrtc::FakeMetricsObserver> | 1325 rtc::scoped_refptr<webrtc::FakeMetricsObserver> |
1326 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); | 1326 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); |
1327 initializing_client()->pc()->RegisterUMAObserver(init_observer); | 1327 initializing_client()->pc()->RegisterUMAObserver(init_observer); |
1328 LocalP2PTest(); | 1328 LocalP2PTest(); |
1329 | 1329 |
1330 EXPECT_EQ_WAIT(rtc::SSLStreamAdapter::GetSslCipherSuiteName( | 1330 EXPECT_EQ_WAIT(rtc::SSLStreamAdapter::SslCipherSuiteToName( |
1331 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( | 1331 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
1332 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT)), | 1332 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT)), |
1333 initializing_client()->GetDtlsCipherStats(), | 1333 initializing_client()->GetDtlsCipherStats(), |
1334 kMaxWaitForStatsMs); | 1334 kMaxWaitForStatsMs); |
1335 EXPECT_EQ(1, init_observer->GetEnumCounter( | 1335 EXPECT_EQ(1, init_observer->GetEnumCounter( |
1336 webrtc::kEnumCounterAudioSslCipher, | 1336 webrtc::kEnumCounterAudioSslCipher, |
1337 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( | 1337 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
1338 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT))); | 1338 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT))); |
1339 | 1339 |
1340 EXPECT_EQ_WAIT(kDefaultSrtpCipher, | 1340 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite), |
1341 initializing_client()->GetSrtpCipherStats(), | 1341 initializing_client()->GetSrtpCipherStats(), |
1342 kMaxWaitForStatsMs); | 1342 kMaxWaitForStatsMs); |
1343 EXPECT_EQ(1, init_observer->GetEnumCounter( | 1343 EXPECT_EQ(1, |
1344 webrtc::kEnumCounterAudioSrtpCipher, | 1344 init_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher, |
1345 rtc::GetSrtpCryptoSuiteFromName(kDefaultSrtpCipher))); | 1345 kDefaultSrtpCryptoSuite)); |
1346 } | 1346 } |
1347 | 1347 |
1348 // Test that DTLS 1.2 is used if both ends support it. | 1348 // Test that DTLS 1.2 is used if both ends support it. |
1349 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Both) { | 1349 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Both) { |
1350 PeerConnectionFactory::Options init_options; | 1350 PeerConnectionFactory::Options init_options; |
1351 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; | 1351 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; |
1352 PeerConnectionFactory::Options recv_options; | 1352 PeerConnectionFactory::Options recv_options; |
1353 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; | 1353 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; |
1354 ASSERT_TRUE( | 1354 ASSERT_TRUE( |
1355 CreateTestClients(nullptr, &init_options, nullptr, &recv_options)); | 1355 CreateTestClients(nullptr, &init_options, nullptr, &recv_options)); |
1356 rtc::scoped_refptr<webrtc::FakeMetricsObserver> | 1356 rtc::scoped_refptr<webrtc::FakeMetricsObserver> |
1357 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); | 1357 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); |
1358 initializing_client()->pc()->RegisterUMAObserver(init_observer); | 1358 initializing_client()->pc()->RegisterUMAObserver(init_observer); |
1359 LocalP2PTest(); | 1359 LocalP2PTest(); |
1360 | 1360 |
1361 EXPECT_EQ_WAIT(rtc::SSLStreamAdapter::GetSslCipherSuiteName( | 1361 EXPECT_EQ_WAIT(rtc::SSLStreamAdapter::SslCipherSuiteToName( |
1362 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( | 1362 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
1363 rtc::SSL_PROTOCOL_DTLS_12, rtc::KT_DEFAULT)), | 1363 rtc::SSL_PROTOCOL_DTLS_12, rtc::KT_DEFAULT)), |
1364 initializing_client()->GetDtlsCipherStats(), | 1364 initializing_client()->GetDtlsCipherStats(), |
1365 kMaxWaitForStatsMs); | 1365 kMaxWaitForStatsMs); |
1366 EXPECT_EQ(1, init_observer->GetEnumCounter( | 1366 EXPECT_EQ(1, init_observer->GetEnumCounter( |
1367 webrtc::kEnumCounterAudioSslCipher, | 1367 webrtc::kEnumCounterAudioSslCipher, |
1368 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( | 1368 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
1369 rtc::SSL_PROTOCOL_DTLS_12, rtc::KT_DEFAULT))); | 1369 rtc::SSL_PROTOCOL_DTLS_12, rtc::KT_DEFAULT))); |
1370 | 1370 |
1371 EXPECT_EQ_WAIT(kDefaultSrtpCipher, | 1371 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite), |
1372 initializing_client()->GetSrtpCipherStats(), | 1372 initializing_client()->GetSrtpCipherStats(), |
1373 kMaxWaitForStatsMs); | 1373 kMaxWaitForStatsMs); |
1374 EXPECT_EQ(1, init_observer->GetEnumCounter( | 1374 EXPECT_EQ(1, |
1375 webrtc::kEnumCounterAudioSrtpCipher, | 1375 init_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher, |
1376 rtc::GetSrtpCryptoSuiteFromName(kDefaultSrtpCipher))); | 1376 kDefaultSrtpCryptoSuite)); |
1377 } | 1377 } |
1378 | 1378 |
1379 // Test that DTLS 1.0 is used if the initator supports DTLS 1.2 and the | 1379 // Test that DTLS 1.0 is used if the initator supports DTLS 1.2 and the |
1380 // received supports 1.0. | 1380 // received supports 1.0. |
1381 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Init) { | 1381 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Init) { |
1382 PeerConnectionFactory::Options init_options; | 1382 PeerConnectionFactory::Options init_options; |
1383 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; | 1383 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; |
1384 PeerConnectionFactory::Options recv_options; | 1384 PeerConnectionFactory::Options recv_options; |
1385 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; | 1385 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; |
1386 ASSERT_TRUE( | 1386 ASSERT_TRUE( |
1387 CreateTestClients(nullptr, &init_options, nullptr, &recv_options)); | 1387 CreateTestClients(nullptr, &init_options, nullptr, &recv_options)); |
1388 rtc::scoped_refptr<webrtc::FakeMetricsObserver> | 1388 rtc::scoped_refptr<webrtc::FakeMetricsObserver> |
1389 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); | 1389 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); |
1390 initializing_client()->pc()->RegisterUMAObserver(init_observer); | 1390 initializing_client()->pc()->RegisterUMAObserver(init_observer); |
1391 LocalP2PTest(); | 1391 LocalP2PTest(); |
1392 | 1392 |
1393 EXPECT_EQ_WAIT(rtc::SSLStreamAdapter::GetSslCipherSuiteName( | 1393 EXPECT_EQ_WAIT(rtc::SSLStreamAdapter::SslCipherSuiteToName( |
1394 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( | 1394 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
1395 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT)), | 1395 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT)), |
1396 initializing_client()->GetDtlsCipherStats(), | 1396 initializing_client()->GetDtlsCipherStats(), |
1397 kMaxWaitForStatsMs); | 1397 kMaxWaitForStatsMs); |
1398 EXPECT_EQ(1, init_observer->GetEnumCounter( | 1398 EXPECT_EQ(1, init_observer->GetEnumCounter( |
1399 webrtc::kEnumCounterAudioSslCipher, | 1399 webrtc::kEnumCounterAudioSslCipher, |
1400 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( | 1400 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
1401 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT))); | 1401 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT))); |
1402 | 1402 |
1403 EXPECT_EQ_WAIT(kDefaultSrtpCipher, | 1403 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite), |
1404 initializing_client()->GetSrtpCipherStats(), | 1404 initializing_client()->GetSrtpCipherStats(), |
1405 kMaxWaitForStatsMs); | 1405 kMaxWaitForStatsMs); |
1406 EXPECT_EQ(1, init_observer->GetEnumCounter( | 1406 EXPECT_EQ(1, |
1407 webrtc::kEnumCounterAudioSrtpCipher, | 1407 init_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher, |
1408 rtc::GetSrtpCryptoSuiteFromName(kDefaultSrtpCipher))); | 1408 kDefaultSrtpCryptoSuite)); |
1409 } | 1409 } |
1410 | 1410 |
1411 // Test that DTLS 1.0 is used if the initator supports DTLS 1.0 and the | 1411 // Test that DTLS 1.0 is used if the initator supports DTLS 1.0 and the |
1412 // received supports 1.2. | 1412 // received supports 1.2. |
1413 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Recv) { | 1413 TEST_F(JsepPeerConnectionP2PTestClient, GetDtls12Recv) { |
1414 PeerConnectionFactory::Options init_options; | 1414 PeerConnectionFactory::Options init_options; |
1415 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; | 1415 init_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_10; |
1416 PeerConnectionFactory::Options recv_options; | 1416 PeerConnectionFactory::Options recv_options; |
1417 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; | 1417 recv_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12; |
1418 ASSERT_TRUE( | 1418 ASSERT_TRUE( |
1419 CreateTestClients(nullptr, &init_options, nullptr, &recv_options)); | 1419 CreateTestClients(nullptr, &init_options, nullptr, &recv_options)); |
1420 rtc::scoped_refptr<webrtc::FakeMetricsObserver> | 1420 rtc::scoped_refptr<webrtc::FakeMetricsObserver> |
1421 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); | 1421 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); |
1422 initializing_client()->pc()->RegisterUMAObserver(init_observer); | 1422 initializing_client()->pc()->RegisterUMAObserver(init_observer); |
1423 LocalP2PTest(); | 1423 LocalP2PTest(); |
1424 | 1424 |
1425 EXPECT_EQ_WAIT(rtc::SSLStreamAdapter::GetSslCipherSuiteName( | 1425 EXPECT_EQ_WAIT(rtc::SSLStreamAdapter::SslCipherSuiteToName( |
1426 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( | 1426 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
1427 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT)), | 1427 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT)), |
1428 initializing_client()->GetDtlsCipherStats(), | 1428 initializing_client()->GetDtlsCipherStats(), |
1429 kMaxWaitForStatsMs); | 1429 kMaxWaitForStatsMs); |
1430 EXPECT_EQ(1, init_observer->GetEnumCounter( | 1430 EXPECT_EQ(1, init_observer->GetEnumCounter( |
1431 webrtc::kEnumCounterAudioSslCipher, | 1431 webrtc::kEnumCounterAudioSslCipher, |
1432 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( | 1432 rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( |
1433 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT))); | 1433 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT))); |
1434 | 1434 |
1435 EXPECT_EQ_WAIT(kDefaultSrtpCipher, | 1435 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite), |
1436 initializing_client()->GetSrtpCipherStats(), | 1436 initializing_client()->GetSrtpCipherStats(), |
1437 kMaxWaitForStatsMs); | 1437 kMaxWaitForStatsMs); |
1438 EXPECT_EQ(1, init_observer->GetEnumCounter( | 1438 EXPECT_EQ(1, |
1439 webrtc::kEnumCounterAudioSrtpCipher, | 1439 init_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher, |
1440 rtc::GetSrtpCryptoSuiteFromName(kDefaultSrtpCipher))); | 1440 kDefaultSrtpCryptoSuite)); |
1441 } | 1441 } |
1442 | 1442 |
1443 // This test sets up a call between two parties with audio, video and data. | 1443 // This test sets up a call between two parties with audio, video and data. |
1444 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestDataChannel) { | 1444 TEST_F(JsepPeerConnectionP2PTestClient, LocalP2PTestDataChannel) { |
1445 FakeConstraints setup_constraints; | 1445 FakeConstraints setup_constraints; |
1446 setup_constraints.SetAllowRtpDataChannels(); | 1446 setup_constraints.SetAllowRtpDataChannels(); |
1447 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); | 1447 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); |
1448 initializing_client()->CreateDataChannel(); | 1448 initializing_client()->CreateDataChannel(); |
1449 LocalP2PTest(); | 1449 LocalP2PTest(); |
1450 ASSERT_TRUE(initializing_client()->data_channel() != nullptr); | 1450 ASSERT_TRUE(initializing_client()->data_channel() != nullptr); |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 server.urls.push_back("stun:hostname"); | 1811 server.urls.push_back("stun:hostname"); |
1812 server.urls.push_back("turn:hostname"); | 1812 server.urls.push_back("turn:hostname"); |
1813 servers.push_back(server); | 1813 servers.push_back(server); |
1814 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_configurations_, | 1814 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_configurations_, |
1815 &turn_configurations_)); | 1815 &turn_configurations_)); |
1816 EXPECT_EQ(1U, stun_configurations_.size()); | 1816 EXPECT_EQ(1U, stun_configurations_.size()); |
1817 EXPECT_EQ(1U, turn_configurations_.size()); | 1817 EXPECT_EQ(1U, turn_configurations_.size()); |
1818 } | 1818 } |
1819 | 1819 |
1820 #endif // if !defined(THREAD_SANITIZER) | 1820 #endif // if !defined(THREAD_SANITIZER) |
OLD | NEW |