Commit e3ea2ae8 authored by rajendrant's avatar rajendrant Committed by Commit Bot

Remove the deprecated session, credential in chrome-proxy

The fields ps, sid in chrome-proxy header are deprecated. So removing them.
https://g3doc.corp.google.com/wireless/speed/flywheel/g3doc/protocol/syntax_proxy.md#requests

Bug: 893728
Change-Id: I752938b6defd6e55405bd40151341ab50486c014
Reviewed-on: https://chromium-review.googlesource.com/c/1316677
Commit-Queue: rajendrant <rajendrant@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605582}
parent 7c68f63a
...@@ -904,10 +904,6 @@ TEST_F(DataReductionProxyNetworkDelegateTest, AuthenticationTest) { ...@@ -904,10 +904,6 @@ TEST_F(DataReductionProxyNetworkDelegateTest, AuthenticationTest) {
proxy_retry_info, &headers); proxy_retry_info, &headers);
EXPECT_TRUE(headers.HasHeader(chrome_proxy_header())); EXPECT_TRUE(headers.HasHeader(chrome_proxy_header()));
std::string header_value;
headers.GetHeader(chrome_proxy_header(), &header_value);
EXPECT_TRUE(header_value.find("ps=") != std::string::npos);
EXPECT_TRUE(header_value.find("sid=") != std::string::npos);
} }
TEST_F(DataReductionProxyNetworkDelegateTest, LoFiTransitions) { TEST_F(DataReductionProxyNetworkDelegateTest, LoFiTransitions) {
......
...@@ -12,13 +12,9 @@ ...@@ -12,13 +12,9 @@
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/strings/safe_sprintf.h" #include "base/strings/safe_sprintf.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/strings/string_tokenizer.h" #include "base/strings/string_tokenizer.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_features.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_features.h"
...@@ -26,7 +22,6 @@ ...@@ -26,7 +22,6 @@
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
#include "components/variations/variations_associated_data.h" #include "components/variations/variations_associated_data.h"
#include "crypto/random.h"
#include "net/base/host_port_pair.h" #include "net/base/host_port_pair.h"
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
#include "net/base/proxy_server.h" #include "net/base/proxy_server.h"
...@@ -45,8 +40,6 @@ std::string FormatOption(const std::string& name, const std::string& value) { ...@@ -45,8 +40,6 @@ std::string FormatOption(const std::string& name, const std::string& value) {
} // namespace } // namespace
const char kSessionHeaderOption[] = "ps";
const char kCredentialsHeaderOption[] = "sid";
const char kSecureSessionHeaderOption[] = "s"; const char kSecureSessionHeaderOption[] = "s";
const char kBuildNumberHeaderOption[] = "b"; const char kBuildNumberHeaderOption[] = "b";
const char kPatchNumberHeaderOption[] = "p"; const char kPatchNumberHeaderOption[] = "p";
...@@ -80,7 +73,6 @@ DataReductionProxyRequestOptions::DataReductionProxyRequestOptions( ...@@ -80,7 +73,6 @@ DataReductionProxyRequestOptions::DataReductionProxyRequestOptions(
const std::string& version, const std::string& version,
DataReductionProxyConfig* config) DataReductionProxyConfig* config)
: client_(util::GetStringForClient(client)), : client_(util::GetStringForClient(client)),
use_assigned_credentials_(false),
data_reduction_proxy_config_(config), data_reduction_proxy_config_(config),
current_page_id_(base::RandUint64()) { current_page_id_(base::RandUint64()) {
DCHECK(data_reduction_proxy_config_); DCHECK(data_reduction_proxy_config_);
...@@ -137,38 +129,11 @@ void DataReductionProxyRequestOptions::AddServerExperimentFromFieldTrial() { ...@@ -137,38 +129,11 @@ void DataReductionProxyRequestOptions::AddServerExperimentFromFieldTrial() {
experiments_.push_back(server_experiment); experiments_.push_back(server_experiment);
} }
// static
base::string16 DataReductionProxyRequestOptions::AuthHashForSalt(
int64_t salt,
const std::string& key) {
std::string salted_key =
base::StringPrintf("%lld%s%lld",
static_cast<long long>(salt),
key.c_str(),
static_cast<long long>(salt));
return base::UTF8ToUTF16(base::MD5String(salted_key));
}
base::Time DataReductionProxyRequestOptions::Now() const {
DCHECK(thread_checker_.CalledOnValidThread());
return base::Time::Now();
}
void DataReductionProxyRequestOptions::RandBytes(void* output,
size_t length) const {
DCHECK(thread_checker_.CalledOnValidThread());
crypto::RandBytes(output, length);
}
void DataReductionProxyRequestOptions::AddRequestHeader( void DataReductionProxyRequestOptions::AddRequestHeader(
net::HttpRequestHeaders* request_headers, net::HttpRequestHeaders* request_headers,
base::Optional<uint64_t> page_id) { base::Optional<uint64_t> page_id) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!page_id || page_id.value() > 0u); DCHECK(!page_id || page_id.value() > 0u);
base::Time now = Now();
// Authorization credentials must be regenerated if they are expired.
if (!use_assigned_credentials_ && (now > credentials_expiration_time_))
UpdateCredentials();
const char kChromeProxyHeader[] = "Chrome-Proxy"; const char kChromeProxyHeader[] = "Chrome-Proxy";
std::string header_value; std::string header_value;
if (request_headers->HasHeader(kChromeProxyHeader)) { if (request_headers->HasHeader(kChromeProxyHeader)) {
...@@ -193,31 +158,7 @@ void DataReductionProxyRequestOptions::AddRequestHeader( ...@@ -193,31 +158,7 @@ void DataReductionProxyRequestOptions::AddRequestHeader(
request_headers->SetHeader(kChromeProxyHeader, header_value); request_headers->SetHeader(kChromeProxyHeader, header_value);
} }
void DataReductionProxyRequestOptions::ComputeCredentials(
const base::Time& now,
std::string* session,
std::string* credentials) const {
DCHECK(session);
DCHECK(credentials);
int64_t timestamp = (now - base::Time::UnixEpoch()).InMilliseconds() / 1000;
int32_t rand[3];
RandBytes(rand, 3 * sizeof(rand[0]));
*session = base::StringPrintf("%lld-%u-%u-%u",
static_cast<long long>(timestamp),
rand[0],
rand[1],
rand[2]);
*credentials = base::UTF16ToUTF8(AuthHashForSalt(timestamp, key_));
DVLOG(1) << "session: [" << *session << "] "
<< "password: [" << *credentials << "]";
}
void DataReductionProxyRequestOptions::UpdateCredentials() { void DataReductionProxyRequestOptions::UpdateCredentials() {
base::Time now = Now();
ComputeCredentials(now, &session_, &credentials_);
credentials_expiration_time_ = now + base::TimeDelta::FromHours(24);
RegenerateRequestHeaderValue(); RegenerateRequestHeaderValue();
} }
...@@ -232,14 +173,9 @@ void DataReductionProxyRequestOptions::SetKeyOnIO(const std::string& key) { ...@@ -232,14 +173,9 @@ void DataReductionProxyRequestOptions::SetKeyOnIO(const std::string& key) {
void DataReductionProxyRequestOptions::SetSecureSession( void DataReductionProxyRequestOptions::SetSecureSession(
const std::string& secure_session) { const std::string& secure_session) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
session_.clear();
credentials_.clear();
secure_session_ = secure_session; secure_session_ = secure_session;
// Reset Page ID, so users can't be tracked across sessions. // Reset Page ID, so users can't be tracked across sessions.
ResetPageId(); ResetPageId();
// Force skipping of credential regeneration. It should be handled by the
// caller.
use_assigned_credentials_ = true;
RegenerateRequestHeaderValue(); RegenerateRequestHeaderValue();
} }
...@@ -276,10 +212,6 @@ const std::string& DataReductionProxyRequestOptions::GetSecureSession() const { ...@@ -276,10 +212,6 @@ const std::string& DataReductionProxyRequestOptions::GetSecureSession() const {
void DataReductionProxyRequestOptions::RegenerateRequestHeaderValue() { void DataReductionProxyRequestOptions::RegenerateRequestHeaderValue() {
std::vector<std::string> headers; std::vector<std::string> headers;
if (!session_.empty())
headers.push_back(FormatOption(kSessionHeaderOption, session_));
if (!credentials_.empty())
headers.push_back(FormatOption(kCredentialsHeaderOption, credentials_));
if (!secure_session_.empty()) { if (!secure_session_.empty()) {
headers.push_back( headers.push_back(
FormatOption(kSecureSessionHeaderOption, secure_session_)); FormatOption(kSecureSessionHeaderOption, secure_session_));
......
...@@ -15,9 +15,7 @@ ...@@ -15,9 +15,7 @@
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/strings/string16.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_util.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_util.h"
#include "net/http/http_request_headers.h" #include "net/http/http_request_headers.h"
...@@ -98,14 +96,6 @@ class DataReductionProxyRequestOptions { ...@@ -98,14 +96,6 @@ class DataReductionProxyRequestOptions {
uint64_t GeneratePageId(); uint64_t GeneratePageId();
protected: protected:
// Returns a UTF16 string that's the hash of the configured authentication
// |key| and |salt|. Returns an empty UTF16 string if no key is configured or
// the data reduction proxy feature isn't available.
static base::string16 AuthHashForSalt(int64_t salt, const std::string& key);
// Visible for testing.
virtual base::Time Now() const;
virtual void RandBytes(void* output, size_t length) const;
// Visible for testing. // Visible for testing.
virtual std::string GetDefaultKey() const; virtual std::string GetDefaultKey() const;
...@@ -134,12 +124,6 @@ class DataReductionProxyRequestOptions { ...@@ -134,12 +124,6 @@ class DataReductionProxyRequestOptions {
// Adds the server-side experiment from the field trial. // Adds the server-side experiment from the field trial.
void AddServerExperimentFromFieldTrial(); void AddServerExperimentFromFieldTrial();
// Generates a session ID and credentials suitable for authenticating with
// the data reduction proxy.
void ComputeCredentials(const base::Time& now,
std::string* session,
std::string* credentials) const;
// Generates and updates the session ID and credentials. // Generates and updates the session ID and credentials.
void UpdateCredentials(); void UpdateCredentials();
...@@ -155,21 +139,11 @@ class DataReductionProxyRequestOptions { ...@@ -155,21 +139,11 @@ class DataReductionProxyRequestOptions {
// Name of the client and version of the data reduction proxy protocol to use. // Name of the client and version of the data reduction proxy protocol to use.
std::string client_; std::string client_;
std::string session_;
std::string credentials_;
std::string secure_session_; std::string secure_session_;
std::string build_; std::string build_;
std::string patch_; std::string patch_;
std::vector<std::string> experiments_; std::vector<std::string> experiments_;
// The time at which the session expires. Used to ensure that a session is
// never used for more than twenty-four hours.
base::Time credentials_expiration_time_;
// Whether the authentication headers are sourced by |this| or injected via
// |SetCredentials|.
bool use_assigned_credentials_;
// Must outlive |this|. // Must outlive |this|.
DataReductionProxyConfig* data_reduction_proxy_config_; DataReductionProxyConfig* data_reduction_proxy_config_;
......
...@@ -11,13 +11,9 @@ ...@@ -11,13 +11,9 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/md5.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/metrics/field_trial.h" #include "base/metrics/field_trial.h"
#include "base/strings/string16.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h"
...@@ -40,17 +36,11 @@ const char kChromeProxyHeader[] = "chrome-proxy"; ...@@ -40,17 +36,11 @@ const char kChromeProxyHeader[] = "chrome-proxy";
const char kVersion[] = "0.1.2.3"; const char kVersion[] = "0.1.2.3";
const char kExpectedBuild[] = "2"; const char kExpectedBuild[] = "2";
const char kExpectedPatch[] = "3"; const char kExpectedPatch[] = "3";
const char kExpectedCredentials[] = "96bd72ec4a050ba60981743d41787768";
const char kExpectedSession[] = "0-1633771873-1633771873-1633771873";
const char kPageId[] = "1"; const char kPageId[] = "1";
const uint64_t kPageIdValue = 1; const uint64_t kPageIdValue = 1;
const char kTestKey2[] = "test-key2"; const char kTestKey2[] = "test-key2";
const char kExpectedCredentials2[] = "c911fdb402f578787562cf7f00eda972";
const char kExpectedSession2[] = "0-1633771873-1633771873-1633771873";
const char kDataReductionProxyKey[] = "12345";
const char kPageId2[] = "f"; const char kPageId2[] = "f";
const uint64_t kPageIdValue2 = 15;
const char kSecureSession[] = "TestSecureSessionKey"; const char kSecureSession[] = "TestSecureSessionKey";
} // namespace } // namespace
...@@ -94,9 +84,7 @@ const Client kClient = Client::UNKNOWN; ...@@ -94,9 +84,7 @@ const Client kClient = Client::UNKNOWN;
const char kClientStr[] = ""; const char kClientStr[] = "";
#endif #endif
void SetHeaderExpectations(const std::string& session, void SetHeaderExpectations(const std::string& secure_session,
const std::string& credentials,
const std::string& secure_session,
const std::string& client, const std::string& client,
const std::string& build, const std::string& build,
const std::string& patch, const std::string& patch,
...@@ -104,14 +92,6 @@ void SetHeaderExpectations(const std::string& session, ...@@ -104,14 +92,6 @@ void SetHeaderExpectations(const std::string& session,
const std::vector<std::string> experiments, const std::vector<std::string> experiments,
std::string* expected_header) { std::string* expected_header) {
std::vector<std::string> expected_options; std::vector<std::string> expected_options;
if (!session.empty()) {
expected_options.push_back(
std::string(kSessionHeaderOption) + "=" + session);
}
if (!credentials.empty()) {
expected_options.push_back(
std::string(kCredentialsHeaderOption) + "=" + credentials);
}
if (!secure_session.empty()) { if (!secure_session.empty()) {
expected_options.push_back(std::string(kSecureSessionHeaderOption) + "=" + expected_options.push_back(std::string(kSecureSessionHeaderOption) + "=" +
secure_session); secure_session);
...@@ -197,26 +177,16 @@ class DataReductionProxyRequestOptionsTest : public testing::Test { ...@@ -197,26 +177,16 @@ class DataReductionProxyRequestOptionsTest : public testing::Test {
net::HttpRequestHeaders callback_headers_; net::HttpRequestHeaders callback_headers_;
}; };
TEST_F(DataReductionProxyRequestOptionsTest, AuthHashForSalt) {
std::string salt = "8675309"; // Jenny's number to test the hash generator.
std::string salted_key = salt + kDataReductionProxyKey + salt;
base::string16 expected_hash = base::UTF8ToUTF16(base::MD5String(salted_key));
EXPECT_EQ(expected_hash,
DataReductionProxyRequestOptions::AuthHashForSalt(
8675309, kDataReductionProxyKey));
}
TEST_F(DataReductionProxyRequestOptionsTest, AuthorizationOnIOThread) { TEST_F(DataReductionProxyRequestOptionsTest, AuthorizationOnIOThread) {
std::string expected_header; std::string expected_header;
SetHeaderExpectations(kExpectedSession2, kExpectedCredentials2, std::string(), SetHeaderExpectations(std::string(), kClientStr, kExpectedBuild,
kClientStr, kExpectedBuild, kExpectedPatch, kPageId, kExpectedPatch, kPageId, std::vector<std::string>(),
std::vector<std::string>(), &expected_header); &expected_header);
std::string expected_header2; std::string expected_header2;
SetHeaderExpectations("86401-1633771873-1633771873-1633771873", SetHeaderExpectations(std::string(), kClientStr, kExpectedBuild,
"d7c1c34ef6b90303b01c48a6c1db6419", std::string(), kExpectedPatch, kPageId2, std::vector<std::string>(),
kClientStr, kExpectedBuild, kExpectedPatch, kPageId2, &expected_header2);
std::vector<std::string>(), &expected_header2);
CreateRequestOptions(kVersion); CreateRequestOptions(kVersion);
test_context_->RunUntilIdle(); test_context_->RunUntilIdle();
...@@ -226,21 +196,13 @@ TEST_F(DataReductionProxyRequestOptionsTest, AuthorizationOnIOThread) { ...@@ -226,21 +196,13 @@ TEST_F(DataReductionProxyRequestOptionsTest, AuthorizationOnIOThread) {
// Write headers. // Write headers.
VerifyExpectedHeader(expected_header, kPageIdValue); VerifyExpectedHeader(expected_header, kPageIdValue);
// Fast forward 24 hours. The header should be the same.
request_options()->set_offset(base::TimeDelta::FromSeconds(24 * 60 * 60));
VerifyExpectedHeader(expected_header, kPageIdValue);
// Fast forward one more second. The header should be new.
request_options()->set_offset(base::TimeDelta::FromSeconds(24 * 60 * 60 + 1));
VerifyExpectedHeader(expected_header2, kPageIdValue2);
} }
TEST_F(DataReductionProxyRequestOptionsTest, AuthorizationIgnoresEmptyKey) { TEST_F(DataReductionProxyRequestOptionsTest, AuthorizationIgnoresEmptyKey) {
std::string expected_header; std::string expected_header;
SetHeaderExpectations(kExpectedSession, kExpectedCredentials, std::string(), SetHeaderExpectations(std::string(), kClientStr, kExpectedBuild,
kClientStr, kExpectedBuild, kExpectedPatch, kPageId, kExpectedPatch, kPageId, std::vector<std::string>(),
std::vector<std::string>(), &expected_header); &expected_header);
CreateRequestOptions(kVersion); CreateRequestOptions(kVersion);
VerifyExpectedHeader(expected_header, kPageIdValue); VerifyExpectedHeader(expected_header, kPageIdValue);
...@@ -252,9 +214,9 @@ TEST_F(DataReductionProxyRequestOptionsTest, AuthorizationIgnoresEmptyKey) { ...@@ -252,9 +214,9 @@ TEST_F(DataReductionProxyRequestOptionsTest, AuthorizationIgnoresEmptyKey) {
TEST_F(DataReductionProxyRequestOptionsTest, SecureSession) { TEST_F(DataReductionProxyRequestOptionsTest, SecureSession) {
std::string expected_header; std::string expected_header;
SetHeaderExpectations(std::string(), std::string(), kSecureSession, SetHeaderExpectations(kSecureSession, kClientStr, kExpectedBuild,
kClientStr, kExpectedBuild, kExpectedPatch, kPageId, kExpectedPatch, kPageId, std::vector<std::string>(),
std::vector<std::string>(), &expected_header); &expected_header);
CreateRequestOptions(kVersion); CreateRequestOptions(kVersion);
request_options()->SetSecureSession(kSecureSession); request_options()->SetSecureSession(kSecureSession);
...@@ -263,9 +225,9 @@ TEST_F(DataReductionProxyRequestOptionsTest, SecureSession) { ...@@ -263,9 +225,9 @@ TEST_F(DataReductionProxyRequestOptionsTest, SecureSession) {
TEST_F(DataReductionProxyRequestOptionsTest, CallsHeaderCallback) { TEST_F(DataReductionProxyRequestOptionsTest, CallsHeaderCallback) {
std::string expected_header; std::string expected_header;
SetHeaderExpectations(std::string(), std::string(), kSecureSession, SetHeaderExpectations(kSecureSession, kClientStr, kExpectedBuild,
kClientStr, kExpectedBuild, kExpectedPatch, kPageId, kExpectedPatch, kPageId, std::vector<std::string>(),
std::vector<std::string>(), &expected_header); &expected_header);
CreateRequestOptionsWithCallback(kVersion); CreateRequestOptionsWithCallback(kVersion);
request_options()->SetSecureSession(kSecureSession); request_options()->SetSecureSession(kSecureSession);
...@@ -288,9 +250,9 @@ TEST_F(DataReductionProxyRequestOptionsTest, ParseExperiments) { ...@@ -288,9 +250,9 @@ TEST_F(DataReductionProxyRequestOptionsTest, ParseExperiments) {
expected_experiments.push_back("staging"); expected_experiments.push_back("staging");
expected_experiments.push_back("\"foo,bar\""); expected_experiments.push_back("\"foo,bar\"");
std::string expected_header; std::string expected_header;
SetHeaderExpectations(kExpectedSession, kExpectedCredentials, std::string(), SetHeaderExpectations(std::string(), kClientStr, kExpectedBuild,
kClientStr, kExpectedBuild, kExpectedPatch, kPageId, kExpectedPatch, kPageId, expected_experiments,
expected_experiments, &expected_header); &expected_header);
CreateRequestOptions(kVersion); CreateRequestOptions(kVersion);
VerifyExpectedHeader(expected_header, kPageIdValue); VerifyExpectedHeader(expected_header, kPageIdValue);
...@@ -355,9 +317,9 @@ TEST_F(DataReductionProxyRequestOptionsTest, ParseExperimentsFromFieldTrial) { ...@@ -355,9 +317,9 @@ TEST_F(DataReductionProxyRequestOptionsTest, ParseExperimentsFromFieldTrial) {
if (!test.expected_experiment.empty()) if (!test.expected_experiment.empty())
expected_experiments.push_back(test.expected_experiment); expected_experiments.push_back(test.expected_experiment);
SetHeaderExpectations(kExpectedSession, kExpectedCredentials, std::string(), SetHeaderExpectations(std::string(), kClientStr, kExpectedBuild,
kClientStr, kExpectedBuild, kExpectedPatch, kPageId, kExpectedPatch, kPageId, expected_experiments,
expected_experiments, &expected_header); &expected_header);
CreateRequestOptions(kVersion); CreateRequestOptions(kVersion);
VerifyExpectedHeader(expected_header, kPageIdValue); VerifyExpectedHeader(expected_header, kPageIdValue);
...@@ -382,9 +344,9 @@ TEST_F(DataReductionProxyRequestOptionsTest, TestExperimentPrecedence) { ...@@ -382,9 +344,9 @@ TEST_F(DataReductionProxyRequestOptionsTest, TestExperimentPrecedence) {
std::vector<std::string> expected_experiments; std::vector<std::string> expected_experiments;
expected_experiments.push_back("foo"); expected_experiments.push_back("foo");
std::string expected_header; std::string expected_header;
SetHeaderExpectations(kExpectedSession, kExpectedCredentials, std::string(), SetHeaderExpectations(std::string(), kClientStr, kExpectedBuild,
kClientStr, kExpectedBuild, kExpectedPatch, kPageId, kExpectedPatch, kPageId, expected_experiments,
expected_experiments, &expected_header); &expected_header);
CreateRequestOptions(kVersion); CreateRequestOptions(kVersion);
VerifyExpectedHeader(expected_header, kPageIdValue); VerifyExpectedHeader(expected_header, kPageIdValue);
...@@ -393,9 +355,9 @@ TEST_F(DataReductionProxyRequestOptionsTest, TestExperimentPrecedence) { ...@@ -393,9 +355,9 @@ TEST_F(DataReductionProxyRequestOptionsTest, TestExperimentPrecedence) {
data_reduction_proxy::switches::kDataReductionProxyExperiment, "bar"); data_reduction_proxy::switches::kDataReductionProxyExperiment, "bar");
expected_experiments.clear(); expected_experiments.clear();
expected_experiments.push_back("bar"); expected_experiments.push_back("bar");
SetHeaderExpectations(kExpectedSession, kExpectedCredentials, std::string(), SetHeaderExpectations(std::string(), kClientStr, kExpectedBuild,
kClientStr, kExpectedBuild, kExpectedPatch, kPageId, kExpectedPatch, kPageId, expected_experiments,
expected_experiments, &expected_header); &expected_header);
CreateRequestOptions(kVersion); CreateRequestOptions(kVersion);
VerifyExpectedHeader(expected_header, kPageIdValue); VerifyExpectedHeader(expected_header, kPageIdValue);
} }
......
...@@ -95,24 +95,6 @@ std::string TestDataReductionProxyRequestOptions::GetDefaultKey() const { ...@@ -95,24 +95,6 @@ std::string TestDataReductionProxyRequestOptions::GetDefaultKey() const {
return kTestKey; return kTestKey;
} }
base::Time TestDataReductionProxyRequestOptions::Now() const {
return base::Time::UnixEpoch() + now_offset_;
}
void TestDataReductionProxyRequestOptions::RandBytes(void* output,
size_t length) const {
char* c = static_cast<char*>(output);
for (size_t i = 0; i < length; ++i) {
c[i] = 'a';
}
}
// Time after the unix epoch that Now() reports.
void TestDataReductionProxyRequestOptions::set_offset(
const base::TimeDelta& now_offset) {
now_offset_ = now_offset;
}
MockDataReductionProxyRequestOptions::MockDataReductionProxyRequestOptions( MockDataReductionProxyRequestOptions::MockDataReductionProxyRequestOptions(
Client client, Client client,
DataReductionProxyConfig* config) DataReductionProxyConfig* config)
......
...@@ -70,16 +70,8 @@ class TestDataReductionProxyRequestOptions ...@@ -70,16 +70,8 @@ class TestDataReductionProxyRequestOptions
// Overrides of DataReductionProxyRequestOptions. // Overrides of DataReductionProxyRequestOptions.
std::string GetDefaultKey() const override; std::string GetDefaultKey() const override;
base::Time Now() const override;
void RandBytes(void* output, size_t length) const override;
// Time after the unix epoch that Now() reports.
void set_offset(const base::TimeDelta& now_offset);
using DataReductionProxyRequestOptions::GetHeaderValueForTesting; using DataReductionProxyRequestOptions::GetHeaderValueForTesting;
private:
base::TimeDelta now_offset_;
}; };
// Mock version of |DataReductionProxyRequestOptions|. // Mock version of |DataReductionProxyRequestOptions|.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment