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