Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1280)

Side by Side Diff: chrome_proxy_resolver_unittest.cc

Issue 5205002: AU: Manual proxy support (Closed) Base URL: http://git.chromium.org/git/update_engine.git@master
Patch Set: missed one fix for review Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome_proxy_resolver.cc ('k') | download_action_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <deque>
5 #include <string> 6 #include <string>
6 #include <vector>
7 7
8 #include <gtest/gtest.h> 8 #include <gtest/gtest.h>
9 9
10 #include "update_engine/chrome_proxy_resolver.h" 10 #include "update_engine/chrome_proxy_resolver.h"
11 #include "update_engine/mock_dbus_interface.h" 11 #include "update_engine/mock_dbus_interface.h"
12 12
13 using std::deque;
13 using std::string; 14 using std::string;
14 using std::vector;
15 using ::testing::_; 15 using ::testing::_;
16 using ::testing::Return; 16 using ::testing::Return;
17 using ::testing::SetArgumentPointee; 17 using ::testing::SetArgumentPointee;
18 using ::testing::StrEq; 18 using ::testing::StrEq;
19 19
20 namespace chromeos_update_engine { 20 namespace chromeos_update_engine {
21 21
22 class ChromeProxyResolverTest : public ::testing::Test { }; 22 class ChromeProxyResolverTest : public ::testing::Test { };
23 23
24 TEST(ChromeProxyResolverTest, GetProxiesForUrlWithSettingsTest) { 24 TEST(ChromeProxyResolverTest, GetProxiesForUrlWithSettingsTest) {
25 const string kSingle = 25 const string kSingle =
26 "{\"mode\":3,\"single\":{\"server\":\"192.168.42.86:80\",\"src\":0}}"; 26 "{\"mode\":3,\"single\":{\"server\":\"192.168.42.86:80\",\"src\":0}}";
27 const string kSocks = 27 const string kSocks =
28 "{\"mode\":4,\"socks\":{\"server\":\"socks5://192.168.42.83:5555\"," 28 "{\"mode\":4,\"socks\":{\"server\":\"socks5://192.168.42.83:5555\","
29 "\"src\":0}}"; 29 "\"src\":0}}";
30 const string kAll = 30 const string kAll =
31 "{\"http\":{\"server\":\"http_proxy:11\",\"src\":0}," 31 "{\"http\":{\"server\":\"http_proxy:11\",\"src\":0},"
32 "\"https\":{\"server\":\"https://https_proxy:22\",\"src\":0}," 32 "\"https\":{\"server\":\"https://https_proxy:22\",\"src\":0},"
33 "\"mode\":4," 33 "\"mode\":4,"
34 "\"socks\":{\"server\":\"socks5://socks:55\",\"src\":0}}"; 34 "\"socks\":{\"server\":\"socks5://socks:55\",\"src\":0}}";
35 const string kHttpHttps = 35 const string kHttpHttps =
36 "{\"http\":{\"server\":\"http_proxy:11\",\"src\":0}," 36 "{\"http\":{\"server\":\"http_proxy:11\",\"src\":0},"
37 "\"https\":{\"server\":\"https://https_proxy:22\",\"src\":0}," 37 "\"https\":{\"server\":\"https://https_proxy:22\",\"src\":0},"
38 "\"mode\":4}"; 38 "\"mode\":4}";
39 39
40 ChromeProxyResolver resolver(NULL); 40 ChromeProxyResolver resolver(NULL);
41 vector<string> out; 41 deque<string> out;
42 string urls[] = {"http://foo.com/update", "https://bar.com/foo.gz"}; 42 string urls[] = {"http://foo.com/update", "https://bar.com/foo.gz"};
43 string multi_settings[] = {kAll, kHttpHttps}; 43 string multi_settings[] = {kAll, kHttpHttps};
44 for (size_t i = 0; i < arraysize(urls); i++) { 44 for (size_t i = 0; i < arraysize(urls); i++) {
45 const string& url = urls[i]; 45 const string& url = urls[i];
46 LOG(INFO) << "url: " << url; 46 LOG(INFO) << "url: " << url;
47 EXPECT_TRUE(resolver.GetProxiesForUrlWithSettings(url, kSingle, &out)); 47 EXPECT_TRUE(resolver.GetProxiesForUrlWithSettings(url, kSingle, &out));
48 EXPECT_EQ(2, out.size()); 48 EXPECT_EQ(2, out.size());
49 EXPECT_EQ("http://192.168.42.86:80", out[0]); 49 EXPECT_EQ("http://192.168.42.86:80", out[0]);
50 EXPECT_EQ(kNoProxy, out[1]); 50 EXPECT_EQ(kNoProxy, out[1]);
51 51
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 StrEq(kSessionManagerRetrievePropertyMethod), 112 StrEq(kSessionManagerRetrievePropertyMethod),
113 _, 113 _,
114 G_TYPE_STRING, StrEq(kSessionManagerProxySettingsKey), 114 G_TYPE_STRING, StrEq(kSessionManagerProxySettingsKey),
115 G_TYPE_INVALID, 115 G_TYPE_INVALID,
116 G_TYPE_STRING, _, 116 G_TYPE_STRING, _,
117 DBUS_TYPE_G_UCHAR_ARRAY, _)) 117 DBUS_TYPE_G_UCHAR_ARRAY, _))
118 .WillOnce(DoAll(SetArgumentPointee<7>(strdup(settings)), 118 .WillOnce(DoAll(SetArgumentPointee<7>(strdup(settings)),
119 SetArgumentPointee<9>(ret_array), 119 SetArgumentPointee<9>(ret_array),
120 Return(TRUE))); 120 Return(TRUE)));
121 121
122 vector<string> proxies; 122 deque<string> proxies;
123 EXPECT_TRUE(resolver.GetProxiesForUrl("http://user:pass@foo.com:22", 123 EXPECT_TRUE(resolver.GetProxiesForUrl("http://user:pass@foo.com:22",
124 &proxies)); 124 &proxies));
125 EXPECT_EQ(2, proxies.size()); 125 EXPECT_EQ(2, proxies.size());
126 EXPECT_EQ("socks5://192.168.52.83:5555", proxies[0]); 126 EXPECT_EQ("socks5://192.168.52.83:5555", proxies[0]);
127 EXPECT_EQ(kNoProxy, proxies[1]); 127 EXPECT_EQ(kNoProxy, proxies[1]);
128 } 128 }
129 129
130 TEST(ChromeProxyResolverTest, GetProxyTypeTest) { 130 TEST(ChromeProxyResolverTest, GetProxyTypeTest) {
131 curl_proxytype type; 131 curl_proxytype type;
132 EXPECT_TRUE(ChromeProxyResolver::GetProxyType("socks://f.ru", &type)); 132 EXPECT_TRUE(ChromeProxyResolver::GetProxyType("socks://f.ru", &type));
133 EXPECT_EQ(CURLPROXY_SOCKS5_HOSTNAME, type); 133 EXPECT_EQ(CURLPROXY_SOCKS5_HOSTNAME, type);
134 EXPECT_TRUE(ChromeProxyResolver::GetProxyType("socks5://f.ru:9", &type)); 134 EXPECT_TRUE(ChromeProxyResolver::GetProxyType("socks5://f.ru:9", &type));
135 EXPECT_EQ(CURLPROXY_SOCKS5_HOSTNAME, type); 135 EXPECT_EQ(CURLPROXY_SOCKS5_HOSTNAME, type);
136 EXPECT_TRUE(ChromeProxyResolver::GetProxyType("socks4://f.ru:9", &type)); 136 EXPECT_TRUE(ChromeProxyResolver::GetProxyType("socks4://f.ru:9", &type));
137 EXPECT_EQ(CURLPROXY_SOCKS4A, type); 137 EXPECT_EQ(CURLPROXY_SOCKS4A, type);
138 EXPECT_TRUE(ChromeProxyResolver::GetProxyType("http://f.no:88", &type)); 138 EXPECT_TRUE(ChromeProxyResolver::GetProxyType("http://f.no:88", &type));
139 EXPECT_EQ(CURLPROXY_HTTP, type); 139 EXPECT_EQ(CURLPROXY_HTTP, type);
140 EXPECT_TRUE(ChromeProxyResolver::GetProxyType("https://f.no:88", &type)); 140 EXPECT_TRUE(ChromeProxyResolver::GetProxyType("https://f.no:88", &type));
141 EXPECT_EQ(CURLPROXY_HTTP, type); 141 EXPECT_EQ(CURLPROXY_HTTP, type);
142 EXPECT_FALSE(ChromeProxyResolver::GetProxyType(kNoProxy, &type)); 142 EXPECT_FALSE(ChromeProxyResolver::GetProxyType(kNoProxy, &type));
143 EXPECT_FALSE(ChromeProxyResolver::GetProxyType("foo://", &type)); 143 EXPECT_FALSE(ChromeProxyResolver::GetProxyType("foo://", &type));
144 EXPECT_FALSE(ChromeProxyResolver::GetProxyType("missing.com:8", &type)); 144 EXPECT_FALSE(ChromeProxyResolver::GetProxyType("missing.com:8", &type));
145 } 145 }
146 146
147 } // namespace chromeos_update_engine 147 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « chrome_proxy_resolver.cc ('k') | download_action_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698