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

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc

Issue 1547273003: Set trusted SPDY proxy dynamically on per-profile basis (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
index ea4d8c849e832cd0e550ad4ec9bc44fb41210dd5..689436c7dc827830a7301cc297e6cd8861e3362e 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
@@ -28,6 +28,7 @@
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
#include "components/variations/variations_associated_data.h"
#include "net/base/external_estimate_provider.h"
+#include "net/base/host_port_pair.h"
#include "net/base/network_quality_estimator.h"
#include "net/http/http_status_code.h"
#include "net/log/test_net_log.h"
@@ -908,6 +909,71 @@ TEST_F(DataReductionProxyConfigTest, LoFiOn) {
}
}
+// Tests that the trusted SPDY proxy is set correctly.
+TEST_F(DataReductionProxyConfigTest, TrustedSpdyProxy) {
+ const struct {
+ bool is_data_reduction_proxy_enabled;
+ bool is_in_trusted_spdy_proxy_field_trial;
+ net::ProxyServer proxy;
+ } tests[] = {
+ {false, false, net::ProxyServer::FromURI("http://origin.net:80",
+ net::ProxyServer::SCHEME_HTTP)},
+ {false, false, net::ProxyServer::FromURI("https://origin.net:443",
+ net::ProxyServer::SCHEME_HTTP)},
+ {false, true, net::ProxyServer::FromURI("http://origin.net:80",
+ net::ProxyServer::SCHEME_HTTP)},
+ {false, true, net::ProxyServer::FromURI("https://origin.net:443",
+ net::ProxyServer::SCHEME_HTTP)},
+ {false, true, net::ProxyServer::FromURI("quic://origin.net:443",
+ net::ProxyServer::SCHEME_QUIC)},
+ {true, false, net::ProxyServer::FromURI("http://origin.net:80",
+ net::ProxyServer::SCHEME_HTTP)},
+ {true, false, net::ProxyServer::FromURI("https://origin.net:443",
+ net::ProxyServer::SCHEME_HTTP)},
+ {true, true, net::ProxyServer::FromURI("http://origin.net:80",
+ net::ProxyServer::SCHEME_HTTP)},
+ {true, true, net::ProxyServer::FromURI("https://origin.net:443",
+ net::ProxyServer::SCHEME_HTTP)},
+ {true, true, net::ProxyServer::FromURI("quic://origin.net:443",
+ net::ProxyServer::SCHEME_QUIC)},
+ };
+ for (size_t i = 0; i < arraysize(tests); ++i) {
+ bool is_proxy_secure = tests[i].proxy.is_https();
+
+ net::ProxyServer expected_trusted_spdy_proxy;
+ if (tests[i].is_data_reduction_proxy_enabled &&
+ tests[i].is_in_trusted_spdy_proxy_field_trial && is_proxy_secure) {
+ expected_trusted_spdy_proxy = tests[i].proxy;
+ }
+
+ std::vector<net::ProxyServer> proxies_for_http;
+ proxies_for_http.push_back(tests[i].proxy);
+
+ scoped_ptr<DataReductionProxyMutableConfigValues> config_values =
bengr 2016/01/11 22:29:35 #include "base/memory/scoped_ptr.h"
tbansal1 2016/01/12 20:50:51 Done.
+ DataReductionProxyMutableConfigValues::CreateFromParams(params());
+ config_values->UpdateValues(proxies_for_http);
+ scoped_ptr<DataReductionProxyConfig> config(new DataReductionProxyConfig(
+ net_log(), std::move(config_values), configurator(), event_creator()));
+
+ if (tests[i].is_data_reduction_proxy_enabled)
+ config->enabled_by_user_ = true;
+
+ base::FieldTrialList field_trial_list(nullptr);
+ if (tests[i].is_in_trusted_spdy_proxy_field_trial) {
+ base::FieldTrialList::CreateFieldTrial(
+ params::GetTrustedSpdyProxyFieldTrialName(), "Enabled");
+ } else {
+ base::FieldTrialList::CreateFieldTrial(
+ params::GetTrustedSpdyProxyFieldTrialName(), "Control");
+ }
+
+ net::ProxyServer trusted_spdy_proxy;
+ config->GetTrustedSpdyProxy(&trusted_spdy_proxy);
+
+ EXPECT_EQ(expected_trusted_spdy_proxy, trusted_spdy_proxy) << i;
bengr 2016/01/11 22:29:35 What is supposed to happen with QUIC?
tbansal1 2016/01/12 20:50:51 With QUIC, trusted proxy should not be set (both e
+ }
+}
+
// Overrides net::NetworkQualityEstimator for testing.
class TestNetworkQualityEstimator : public net::NetworkQualityEstimator {
public:

Powered by Google App Engine
This is Rietveld 408576698