| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_auth_request_handler_unittest.cc
|
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_auth_request_handler_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_auth_request_handler_unittest.cc
|
| index 68eedfe6ec85027148e757d0a8feff1ed9f05c99..74397a004adc6b0c92b66471ce8729b5caf47bf7 100644
|
| --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_auth_request_handler_unittest.cc
|
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_auth_request_handler_unittest.cc
|
| @@ -5,6 +5,7 @@
|
|
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth_request_handler.h"
|
|
|
| +#include "base/command_line.h"
|
| #include "base/md5.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/run_loop.h"
|
| @@ -13,6 +14,7 @@
|
| #include "base/time/time.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.h"
|
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params_test_utils.h"
|
| +#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
|
| #include "net/base/auth.h"
|
| #include "net/base/host_port_pair.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| @@ -88,6 +90,10 @@ const std::string kExpectedHeader4 =
|
| std::string("ps=0-1633771873-1633771873-1633771873, ") +
|
| std::string("sid=c911fdb402f578787562cf7f00eda972, c=") +
|
| kClientStr;
|
| +const std::string kExpectedHeader5 =
|
| + std::string("ps=0-1633771873-1633771873-1633771873, ") +
|
| + std::string("sid=c911fdb402f578787562cf7f00eda972, c=") +
|
| + kClientStr + std::string(", q=low");
|
|
|
| class TestDataReductionProxyAuthRequestHandler
|
| : public DataReductionProxyAuthRequestHandler {
|
| @@ -322,4 +328,43 @@ TEST_F(DataReductionProxyAuthRequestHandlerTest, AuthHashForSalt) {
|
| 8675309, kDataReductionProxyKey));
|
| }
|
|
|
| +TEST_F(DataReductionProxyAuthRequestHandlerTest, AuthorizationLoFi) {
|
| + scoped_ptr<TestDataReductionProxyParams> params;
|
| + params.reset(
|
| + new TestDataReductionProxyParams(
|
| + DataReductionProxyParams::kAllowed |
|
| + DataReductionProxyParams::kFallbackAllowed |
|
| + DataReductionProxyParams::kPromoAllowed,
|
| + TestDataReductionProxyParams::HAS_EVERYTHING &
|
| + ~TestDataReductionProxyParams::HAS_DEV_ORIGIN &
|
| + ~TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN));
|
| + TestDataReductionProxyAuthRequestHandler auth_handler(kClient,
|
| + kBogusVersion,
|
| + params.get(),
|
| + loop_proxy_);
|
| +
|
| + base::CommandLine::ForCurrentProcess()->AppendSwitch(
|
| + data_reduction_proxy::switches::kEnableDataReductionProxyLoFi);
|
| +
|
| + // Now set a key.
|
| + auth_handler.InitAuthentication(kTestKey2);
|
| + base::RunLoop().RunUntilIdle();
|
| + EXPECT_EQ(kTestKey2, auth_handler.key_);
|
| + EXPECT_EQ(kExpectedCredentials2, auth_handler.credentials_);
|
| + EXPECT_EQ(kExpectedSession2, auth_handler.session_);
|
| +
|
| + net::HttpRequestHeaders headers;
|
| + // Write headers with a valid data reduction proxy;
|
| + auth_handler.MaybeAddRequestHeader(
|
| + NULL,
|
| + net::ProxyServer::FromURI(
|
| + net::HostPortPair::FromURL(GURL(params->DefaultOrigin())).ToString(),
|
| + net::ProxyServer::SCHEME_HTTP),
|
| + &headers);
|
| + EXPECT_TRUE(headers.HasHeader(kChromeProxyHeader));
|
| + std::string header_value;
|
| + headers.GetHeader(kChromeProxyHeader, &header_value);
|
| + EXPECT_EQ(kExpectedHeader5, header_value);
|
| +}
|
| +
|
| } // namespace data_reduction_proxy
|
|
|