Chromium Code Reviews| 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..1cdd0b9202bee0824f9cbc87860442f558c92fdf 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 |
| @@ -12,6 +12,7 @@ |
| #include "base/command_line.h" |
| #include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
| #include "base/metrics/field_trial.h" |
| #include "base/strings/safe_sprintf.h" |
| #include "base/strings/string_number_conversions.h" |
| @@ -28,6 +29,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 +910,70 @@ TEST_F(DataReductionProxyConfigTest, LoFiOn) { |
| } |
| } |
| +// Tests that the trusted SPDY proxy is verified 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 expect_proxy_as_trusted = false; |
| + |
| + if (tests[i].is_data_reduction_proxy_enabled && |
| + tests[i].is_in_trusted_spdy_proxy_field_trial && |
| + tests[i].proxy.is_https()) { |
| + expect_proxy_as_trusted = true; |
|
bengr
2016/01/26 19:39:55
expect_proxy _is_ trusted?
tbansal1
2016/01/27 00:13:33
Done.
|
| + } |
| + |
| + std::vector<net::ProxyServer> proxies_for_http; |
| + proxies_for_http.push_back(tests[i].proxy); |
|
bengr
2016/01/26 19:39:55
Shouldn't you try configurations with 0 proxies an
tbansal1
2016/01/27 00:13:33
Good point. Done.
|
| + |
| + scoped_ptr<DataReductionProxyMutableConfigValues> config_values = |
| + 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; |
|
bengr
2016/01/26 19:39:55
config->enabled_by_user_ = tests[i].is_data_reduct
tbansal1
2016/01/27 00:13:33
Done.
|
| + |
| + base::FieldTrialList field_trial_list(nullptr); |
| + if (tests[i].is_in_trusted_spdy_proxy_field_trial) { |
|
bengr
2016/01/26 19:39:55
Use a ternary operator instead of the if/else.
tbansal1
2016/01/27 00:13:34
Done.
|
| + base::FieldTrialList::CreateFieldTrial( |
| + params::GetTrustedSpdyProxyFieldTrialName(), "Enabled"); |
| + } else { |
| + base::FieldTrialList::CreateFieldTrial( |
| + params::GetTrustedSpdyProxyFieldTrialName(), "Control"); |
| + } |
| + |
| + EXPECT_EQ(expect_proxy_as_trusted, |
| + config->IsTrustedSpdyProxy(tests[i].proxy)) |
| + << i; |
| + } |
| +} |
| + |
| // Overrides net::NetworkQualityEstimator for testing. |
| class TestNetworkQualityEstimator : public net::NetworkQualityEstimator { |
| public: |