Chromium Code Reviews| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 static const char kAudioTrackLabelBase[] = "audio_track"; | 108 static const char kAudioTrackLabelBase[] = "audio_track"; |
| 109 static const char kDataChannelLabel[] = "data_channel"; | 109 static const char kDataChannelLabel[] = "data_channel"; |
| 110 | 110 |
| 111 // Disable for TSan v2, see | 111 // Disable for TSan v2, see |
| 112 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. | 112 // https://code.google.com/p/webrtc/issues/detail?id=1205 for details. |
| 113 // This declaration is also #ifdef'd as it causes unused-variable errors. | 113 // This declaration is also #ifdef'd as it causes unused-variable errors. |
| 114 #if !defined(THREAD_SANITIZER) | 114 #if !defined(THREAD_SANITIZER) |
| 115 // SRTP cipher name negotiated by the tests. This must be updated if the | 115 // SRTP cipher name negotiated by the tests. This must be updated if the |
| 116 // default changes. | 116 // default changes. |
| 117 static const int kDefaultSrtpCryptoSuite = rtc::SRTP_AES128_CM_SHA1_32; | 117 static const int kDefaultSrtpCryptoSuite = rtc::SRTP_AES128_CM_SHA1_32; |
| 118 static const int kDefaultSrtpCryptoSuiteGcm = rtc::SRTP_AEAD_AES_256_GCM; | |
| 118 #endif | 119 #endif |
| 119 | 120 |
| 120 static void RemoveLinesFromSdp(const std::string& line_start, | 121 static void RemoveLinesFromSdp(const std::string& line_start, |
| 121 std::string* sdp) { | 122 std::string* sdp) { |
| 122 const char kSdpLineEnd[] = "\r\n"; | 123 const char kSdpLineEnd[] = "\r\n"; |
| 123 size_t ssrc_pos = 0; | 124 size_t ssrc_pos = 0; |
| 124 while ((ssrc_pos = sdp->find(line_start, ssrc_pos)) != | 125 while ((ssrc_pos = sdp->find(line_start, ssrc_pos)) != |
| 125 std::string::npos) { | 126 std::string::npos) { |
| 126 size_t end_ssrc = sdp->find(kSdpLineEnd, ssrc_pos); | 127 size_t end_ssrc = sdp->find(kSdpLineEnd, ssrc_pos); |
| 127 sdp->erase(ssrc_pos, end_ssrc - ssrc_pos + strlen(kSdpLineEnd)); | 128 sdp->erase(ssrc_pos, end_ssrc - ssrc_pos + strlen(kSdpLineEnd)); |
| (...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1523 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT))); | 1524 rtc::SSL_PROTOCOL_DTLS_10, rtc::KT_DEFAULT))); |
| 1524 | 1525 |
| 1525 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite), | 1526 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite), |
| 1526 initializing_client()->GetSrtpCipherStats(), | 1527 initializing_client()->GetSrtpCipherStats(), |
| 1527 kMaxWaitForStatsMs); | 1528 kMaxWaitForStatsMs); |
| 1528 EXPECT_EQ(1, | 1529 EXPECT_EQ(1, |
| 1529 init_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher, | 1530 init_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher, |
| 1530 kDefaultSrtpCryptoSuite)); | 1531 kDefaultSrtpCryptoSuite)); |
| 1531 } | 1532 } |
| 1532 | 1533 |
| 1534 // Test that a non-GCM cipher is used if both sides only support non-GCM. | |
| 1535 TEST_F(P2PTestConductor, GetGcmNone) { | |
| 1536 PeerConnectionFactory::Options init_options; | |
| 1537 init_options.enable_gcm_ciphers = false; | |
| 1538 PeerConnectionFactory::Options recv_options; | |
| 1539 recv_options.enable_gcm_ciphers = false; | |
| 1540 ASSERT_TRUE( | |
| 1541 CreateTestClients(nullptr, &init_options, nullptr, &recv_options)); | |
| 1542 rtc::scoped_refptr<webrtc::FakeMetricsObserver> | |
| 1543 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); | |
| 1544 initializing_client()->pc()->RegisterUMAObserver(init_observer); | |
| 1545 LocalP2PTest(); | |
| 1546 | |
| 1547 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite), | |
| 1548 initializing_client()->GetSrtpCipherStats(), | |
| 1549 kMaxWaitForStatsMs); | |
| 1550 EXPECT_EQ(1, | |
| 1551 init_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher, | |
| 1552 kDefaultSrtpCryptoSuite)); | |
|
pthatcher1
2015/12/18 20:31:31
Can you move this common logic into a separate met
joachim
2015/12/19 15:26:23
Done.
| |
| 1553 } | |
| 1554 | |
| 1555 // Test that a GCM cipher is used if both ends support it. | |
| 1556 TEST_F(P2PTestConductor, GetGcmBoth) { | |
| 1557 PeerConnectionFactory::Options init_options; | |
| 1558 init_options.enable_gcm_ciphers = true; | |
| 1559 PeerConnectionFactory::Options recv_options; | |
| 1560 recv_options.enable_gcm_ciphers = true; | |
| 1561 ASSERT_TRUE( | |
| 1562 CreateTestClients(nullptr, &init_options, nullptr, &recv_options)); | |
| 1563 rtc::scoped_refptr<webrtc::FakeMetricsObserver> | |
| 1564 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); | |
| 1565 initializing_client()->pc()->RegisterUMAObserver(init_observer); | |
| 1566 LocalP2PTest(); | |
| 1567 | |
| 1568 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuiteGcm), | |
| 1569 initializing_client()->GetSrtpCipherStats(), | |
| 1570 kMaxWaitForStatsMs); | |
| 1571 EXPECT_EQ(1, | |
| 1572 init_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher, | |
| 1573 kDefaultSrtpCryptoSuiteGcm)); | |
| 1574 } | |
| 1575 | |
| 1576 // Test that a non-GCM cipher is used if the initator supports GCM and the | |
| 1577 // received supports non-GCM. | |
| 1578 TEST_F(P2PTestConductor, GetGcmInit) { | |
| 1579 PeerConnectionFactory::Options init_options; | |
| 1580 init_options.enable_gcm_ciphers = true; | |
| 1581 PeerConnectionFactory::Options recv_options; | |
| 1582 recv_options.enable_gcm_ciphers = false; | |
| 1583 ASSERT_TRUE( | |
| 1584 CreateTestClients(nullptr, &init_options, nullptr, &recv_options)); | |
| 1585 rtc::scoped_refptr<webrtc::FakeMetricsObserver> | |
| 1586 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); | |
| 1587 initializing_client()->pc()->RegisterUMAObserver(init_observer); | |
| 1588 LocalP2PTest(); | |
| 1589 | |
| 1590 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite), | |
| 1591 initializing_client()->GetSrtpCipherStats(), | |
| 1592 kMaxWaitForStatsMs); | |
| 1593 EXPECT_EQ(1, | |
| 1594 init_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher, | |
| 1595 kDefaultSrtpCryptoSuite)); | |
| 1596 } | |
| 1597 | |
| 1598 // Test that a non-GCM cipher is used if the initator supports non-GCM and the | |
| 1599 // received supports GCM. | |
| 1600 TEST_F(P2PTestConductor, GetGcmRecv) { | |
| 1601 PeerConnectionFactory::Options init_options; | |
| 1602 init_options.enable_gcm_ciphers = false; | |
| 1603 PeerConnectionFactory::Options recv_options; | |
| 1604 recv_options.enable_gcm_ciphers = true; | |
| 1605 ASSERT_TRUE( | |
| 1606 CreateTestClients(nullptr, &init_options, nullptr, &recv_options)); | |
| 1607 rtc::scoped_refptr<webrtc::FakeMetricsObserver> | |
| 1608 init_observer = new rtc::RefCountedObject<webrtc::FakeMetricsObserver>(); | |
| 1609 initializing_client()->pc()->RegisterUMAObserver(init_observer); | |
| 1610 LocalP2PTest(); | |
| 1611 | |
| 1612 EXPECT_EQ_WAIT(rtc::SrtpCryptoSuiteToName(kDefaultSrtpCryptoSuite), | |
| 1613 initializing_client()->GetSrtpCipherStats(), | |
| 1614 kMaxWaitForStatsMs); | |
| 1615 EXPECT_EQ(1, | |
| 1616 init_observer->GetEnumCounter(webrtc::kEnumCounterAudioSrtpCipher, | |
| 1617 kDefaultSrtpCryptoSuite)); | |
| 1618 } | |
| 1619 | |
| 1533 // This test sets up a call between two parties with audio, video and an RTP | 1620 // This test sets up a call between two parties with audio, video and an RTP |
| 1534 // data channel. | 1621 // data channel. |
| 1535 TEST_F(P2PTestConductor, LocalP2PTestRtpDataChannel) { | 1622 TEST_F(P2PTestConductor, LocalP2PTestRtpDataChannel) { |
| 1536 FakeConstraints setup_constraints; | 1623 FakeConstraints setup_constraints; |
| 1537 setup_constraints.SetAllowRtpDataChannels(); | 1624 setup_constraints.SetAllowRtpDataChannels(); |
| 1538 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); | 1625 ASSERT_TRUE(CreateTestClients(&setup_constraints, &setup_constraints)); |
| 1539 initializing_client()->CreateDataChannel(); | 1626 initializing_client()->CreateDataChannel(); |
| 1540 LocalP2PTest(); | 1627 LocalP2PTest(); |
| 1541 ASSERT_TRUE(initializing_client()->data_channel() != nullptr); | 1628 ASSERT_TRUE(initializing_client()->data_channel() != nullptr); |
| 1542 ASSERT_TRUE(receiving_client()->data_channel() != nullptr); | 1629 ASSERT_TRUE(receiving_client()->data_channel() != nullptr); |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1958 server.urls.push_back("stun:hostname"); | 2045 server.urls.push_back("stun:hostname"); |
| 1959 server.urls.push_back("turn:hostname"); | 2046 server.urls.push_back("turn:hostname"); |
| 1960 servers.push_back(server); | 2047 servers.push_back(server); |
| 1961 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_configurations_, | 2048 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_configurations_, |
| 1962 &turn_configurations_)); | 2049 &turn_configurations_)); |
| 1963 EXPECT_EQ(1U, stun_configurations_.size()); | 2050 EXPECT_EQ(1U, stun_configurations_.size()); |
| 1964 EXPECT_EQ(1U, turn_configurations_.size()); | 2051 EXPECT_EQ(1U, turn_configurations_.size()); |
| 1965 } | 2052 } |
| 1966 | 2053 |
| 1967 #endif // if !defined(THREAD_SANITIZER) | 2054 #endif // if !defined(THREAD_SANITIZER) |
| OLD | NEW |