OLD | NEW |
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 22 matching lines...) Expand all Loading... |
33 #include "webrtc/base/fakenetwork.h" | 33 #include "webrtc/base/fakenetwork.h" |
34 #include "webrtc/base/gunit.h" | 34 #include "webrtc/base/gunit.h" |
35 #include "webrtc/base/helpers.h" | 35 #include "webrtc/base/helpers.h" |
36 #include "webrtc/base/physicalsocketserver.h" | 36 #include "webrtc/base/physicalsocketserver.h" |
37 #include "webrtc/base/ssladapter.h" | 37 #include "webrtc/base/ssladapter.h" |
38 #include "webrtc/base/sslstreamadapter.h" | 38 #include "webrtc/base/sslstreamadapter.h" |
39 #include "webrtc/base/thread.h" | 39 #include "webrtc/base/thread.h" |
40 #include "webrtc/base/virtualsocketserver.h" | 40 #include "webrtc/base/virtualsocketserver.h" |
41 #include "webrtc/media/engine/fakewebrtcvideoengine.h" | 41 #include "webrtc/media/engine/fakewebrtcvideoengine.h" |
42 #include "webrtc/p2p/base/p2pconstants.h" | 42 #include "webrtc/p2p/base/p2pconstants.h" |
43 #include "webrtc/p2p/base/portinterface.h" | |
44 #include "webrtc/p2p/base/sessiondescription.h" | 43 #include "webrtc/p2p/base/sessiondescription.h" |
45 #include "webrtc/p2p/base/testturnserver.h" | 44 #include "webrtc/p2p/base/testturnserver.h" |
46 #include "webrtc/p2p/client/basicportallocator.h" | 45 #include "webrtc/p2p/client/basicportallocator.h" |
47 #include "webrtc/pc/mediasession.h" | 46 #include "webrtc/pc/mediasession.h" |
48 | 47 |
49 #define MAYBE_SKIP_TEST(feature) \ | 48 #define MAYBE_SKIP_TEST(feature) \ |
50 if (!(feature())) { \ | 49 if (!(feature())) { \ |
51 LOG(LS_INFO) << "Feature disabled... skipping"; \ | 50 LOG(LS_INFO) << "Feature disabled... skipping"; \ |
52 return; \ | 51 return; \ |
53 } | 52 } |
(...skipping 2559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2613 class IceServerParsingTest : public testing::Test { | 2612 class IceServerParsingTest : public testing::Test { |
2614 public: | 2613 public: |
2615 // Convenience for parsing a single URL. | 2614 // Convenience for parsing a single URL. |
2616 bool ParseUrl(const std::string& url) { | 2615 bool ParseUrl(const std::string& url) { |
2617 return ParseUrl(url, std::string(), std::string()); | 2616 return ParseUrl(url, std::string(), std::string()); |
2618 } | 2617 } |
2619 | 2618 |
2620 bool ParseUrl(const std::string& url, | 2619 bool ParseUrl(const std::string& url, |
2621 const std::string& username, | 2620 const std::string& username, |
2622 const std::string& password) { | 2621 const std::string& password) { |
2623 return ParseUrl( | |
2624 url, username, password, | |
2625 PeerConnectionInterface::TlsCertPolicy::kTlsCertPolicySecure); | |
2626 } | |
2627 | |
2628 bool ParseUrl(const std::string& url, | |
2629 const std::string& username, | |
2630 const std::string& password, | |
2631 PeerConnectionInterface::TlsCertPolicy tls_certificate_policy) { | |
2632 PeerConnectionInterface::IceServers servers; | 2622 PeerConnectionInterface::IceServers servers; |
2633 PeerConnectionInterface::IceServer server; | 2623 PeerConnectionInterface::IceServer server; |
2634 server.urls.push_back(url); | 2624 server.urls.push_back(url); |
2635 server.username = username; | 2625 server.username = username; |
2636 server.password = password; | 2626 server.password = password; |
2637 server.tls_cert_policy = tls_certificate_policy; | |
2638 servers.push_back(server); | 2627 servers.push_back(server); |
2639 return webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_); | 2628 return webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_); |
2640 } | 2629 } |
2641 | 2630 |
2642 protected: | 2631 protected: |
2643 cricket::ServerAddresses stun_servers_; | 2632 cricket::ServerAddresses stun_servers_; |
2644 std::vector<cricket::RelayServerConfig> turn_servers_; | 2633 std::vector<cricket::RelayServerConfig> turn_servers_; |
2645 }; | 2634 }; |
2646 | 2635 |
2647 // Make sure all STUN/TURN prefixes are parsed correctly. | 2636 // Make sure all STUN/TURN prefixes are parsed correctly. |
(...skipping 11 matching lines...) Expand all Loading... |
2659 EXPECT_TRUE(ParseUrl("turn:hostname")); | 2648 EXPECT_TRUE(ParseUrl("turn:hostname")); |
2660 EXPECT_EQ(0U, stun_servers_.size()); | 2649 EXPECT_EQ(0U, stun_servers_.size()); |
2661 EXPECT_EQ(1U, turn_servers_.size()); | 2650 EXPECT_EQ(1U, turn_servers_.size()); |
2662 EXPECT_EQ(cricket::PROTO_UDP, turn_servers_[0].ports[0].proto); | 2651 EXPECT_EQ(cricket::PROTO_UDP, turn_servers_[0].ports[0].proto); |
2663 turn_servers_.clear(); | 2652 turn_servers_.clear(); |
2664 | 2653 |
2665 EXPECT_TRUE(ParseUrl("turns:hostname")); | 2654 EXPECT_TRUE(ParseUrl("turns:hostname")); |
2666 EXPECT_EQ(0U, stun_servers_.size()); | 2655 EXPECT_EQ(0U, stun_servers_.size()); |
2667 EXPECT_EQ(1U, turn_servers_.size()); | 2656 EXPECT_EQ(1U, turn_servers_.size()); |
2668 EXPECT_EQ(cricket::PROTO_TLS, turn_servers_[0].ports[0].proto); | 2657 EXPECT_EQ(cricket::PROTO_TLS, turn_servers_[0].ports[0].proto); |
2669 EXPECT_TRUE(turn_servers_[0].tls_cert_policy == | |
2670 cricket::TlsCertPolicy::TLS_CERT_POLICY_SECURE); | |
2671 turn_servers_.clear(); | 2658 turn_servers_.clear(); |
2672 | 2659 |
2673 EXPECT_TRUE(ParseUrl( | |
2674 "turns:hostname", "", "", | |
2675 PeerConnectionInterface::TlsCertPolicy::kTlsCertPolicyInsecureNoCheck)); | |
2676 EXPECT_EQ(0U, stun_servers_.size()); | |
2677 EXPECT_EQ(1U, turn_servers_.size()); | |
2678 EXPECT_TRUE(turn_servers_[0].tls_cert_policy == | |
2679 cricket::TlsCertPolicy::TLS_CERT_POLICY_INSECURE_NO_CHECK); | |
2680 EXPECT_EQ(cricket::PROTO_TLS, turn_servers_[0].ports[0].proto); | |
2681 turn_servers_.clear(); | |
2682 | |
2683 // invalid prefixes | 2660 // invalid prefixes |
2684 EXPECT_FALSE(ParseUrl("stunn:hostname")); | 2661 EXPECT_FALSE(ParseUrl("stunn:hostname")); |
2685 EXPECT_FALSE(ParseUrl(":hostname")); | 2662 EXPECT_FALSE(ParseUrl(":hostname")); |
2686 EXPECT_FALSE(ParseUrl(":")); | 2663 EXPECT_FALSE(ParseUrl(":")); |
2687 EXPECT_FALSE(ParseUrl("")); | 2664 EXPECT_FALSE(ParseUrl("")); |
2688 } | 2665 } |
2689 | 2666 |
2690 TEST_F(IceServerParsingTest, VerifyDefaults) { | 2667 TEST_F(IceServerParsingTest, VerifyDefaults) { |
2691 // TURNS defaults | 2668 // TURNS defaults |
2692 EXPECT_TRUE(ParseUrl("turns:hostname")); | 2669 EXPECT_TRUE(ParseUrl("turns:hostname")); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2820 server.urls.push_back("turn:hostname2"); | 2797 server.urls.push_back("turn:hostname2"); |
2821 servers.push_back(server); | 2798 servers.push_back(server); |
2822 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); | 2799 EXPECT_TRUE(webrtc::ParseIceServers(servers, &stun_servers_, &turn_servers_)); |
2823 EXPECT_EQ(2U, turn_servers_.size()); | 2800 EXPECT_EQ(2U, turn_servers_.size()); |
2824 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); | 2801 EXPECT_NE(turn_servers_[0].priority, turn_servers_[1].priority); |
2825 } | 2802 } |
2826 | 2803 |
2827 #endif // if !defined(THREAD_SANITIZER) | 2804 #endif // if !defined(THREAD_SANITIZER) |
2828 | 2805 |
2829 } // namespace | 2806 } // namespace |
OLD | NEW |