Commit e4521a0a authored by Tarun Bansal's avatar Tarun Bansal Committed by Commit Bot

Remove some more tamper detection code from data reduction proxy

The removed code is dead and unreachable since the tanper
detection experiment is no longer enabled, and there are no plans
to reenable that experiment.

Bug: 675761
Change-Id: I70465d498111d15e01f6ea8fce784cd28cc8902f
Reviewed-on: https://chromium-review.googlesource.com/663847
Commit-Queue: Tarun Bansal <tbansal@chromium.org>
Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501426}
parent 0ab09fb0
......@@ -445,10 +445,7 @@ DataReductionProxyBypassType GetDataReductionProxyBypassType(
return BYPASS_EVENT_TYPE_MISSING_VIA_HEADER_4XX;
}
// Missing the via header should not trigger bypass if the client is
// included in the tamper detection experiment.
if (!params::IsIncludedInTamperDetectionExperiment())
return BYPASS_EVENT_TYPE_MISSING_VIA_HEADER_OTHER;
return BYPASS_EVENT_TYPE_MISSING_VIA_HEADER_OTHER;
}
// There is no bypass event.
return BYPASS_EVENT_TYPE_MAX;
......
......@@ -620,132 +620,123 @@ TEST_F(DataReductionProxyHeadersTest, HasDataReductionProxyViaHeader) {
TEST_F(DataReductionProxyHeadersTest, GetDataReductionProxyBypassEventType) {
const struct {
const char* headers;
bool in_tamper_detection_experiment;
DataReductionProxyBypassType expected_result;
} tests[] = {
{
"HTTP/1.1 200 OK\n"
"Chrome-Proxy: bypass=0\n"
"Via: 1.1 Chrome-Compression-Proxy\n",
false, BYPASS_EVENT_TYPE_MEDIUM,
BYPASS_EVENT_TYPE_MEDIUM,
},
{
"HTTP/1.1 200 OK\n"
"Chrome-Proxy: bypass=1\n"
"Via: 1.1 Chrome-Compression-Proxy\n",
false, BYPASS_EVENT_TYPE_SHORT,
BYPASS_EVENT_TYPE_SHORT,
},
{
"HTTP/1.1 200 OK\n"
"Chrome-Proxy: bypass=59\n"
"Via: 1.1 Chrome-Compression-Proxy\n",
false, BYPASS_EVENT_TYPE_SHORT,
BYPASS_EVENT_TYPE_SHORT,
},
{
"HTTP/1.1 200 OK\n"
"Chrome-Proxy: bypass=60\n"
"Via: 1.1 Chrome-Compression-Proxy\n",
false, BYPASS_EVENT_TYPE_MEDIUM,
BYPASS_EVENT_TYPE_MEDIUM,
},
{
"HTTP/1.1 200 OK\n"
"Chrome-Proxy: bypass=300\n"
"Via: 1.1 Chrome-Compression-Proxy\n",
false, BYPASS_EVENT_TYPE_MEDIUM,
BYPASS_EVENT_TYPE_MEDIUM,
},
{
"HTTP/1.1 200 OK\n"
"Chrome-Proxy: bypass=301\n"
"Via: 1.1 Chrome-Compression-Proxy\n",
false, BYPASS_EVENT_TYPE_LONG,
BYPASS_EVENT_TYPE_LONG,
},
{
"HTTP/1.1 200 OK\n"
"Chrome-Proxy: block-once\n"
"Via: 1.1 Chrome-Compression-Proxy\n",
false, BYPASS_EVENT_TYPE_CURRENT,
BYPASS_EVENT_TYPE_CURRENT,
},
{
"HTTP/1.1 500 Internal Server Error\n"
"Via: 1.1 Chrome-Compression-Proxy\n",
false, BYPASS_EVENT_TYPE_STATUS_500_HTTP_INTERNAL_SERVER_ERROR,
BYPASS_EVENT_TYPE_STATUS_500_HTTP_INTERNAL_SERVER_ERROR,
},
{
"HTTP/1.1 501 Not Implemented\n"
"Via: 1.1 Chrome-Compression-Proxy\n",
false, BYPASS_EVENT_TYPE_MAX,
BYPASS_EVENT_TYPE_MAX,
},
{
"HTTP/1.1 502 Bad Gateway\n"
"Via: 1.1 Chrome-Compression-Proxy\n",
false, BYPASS_EVENT_TYPE_STATUS_502_HTTP_BAD_GATEWAY,
BYPASS_EVENT_TYPE_STATUS_502_HTTP_BAD_GATEWAY,
},
{
"HTTP/1.1 503 Service Unavailable\n"
"Via: 1.1 Chrome-Compression-Proxy\n",
false, BYPASS_EVENT_TYPE_STATUS_503_HTTP_SERVICE_UNAVAILABLE,
BYPASS_EVENT_TYPE_STATUS_503_HTTP_SERVICE_UNAVAILABLE,
},
{
"HTTP/1.1 504 Gateway Timeout\n"
"Via: 1.1 Chrome-Compression-Proxy\n",
false, BYPASS_EVENT_TYPE_MAX,
BYPASS_EVENT_TYPE_MAX,
},
{
"HTTP/1.1 505 HTTP Version Not Supported\n"
"Via: 1.1 Chrome-Compression-Proxy\n",
false, BYPASS_EVENT_TYPE_MAX,
BYPASS_EVENT_TYPE_MAX,
},
{
"HTTP/1.1 304 Not Modified\n", false, BYPASS_EVENT_TYPE_MAX,
"HTTP/1.1 304 Not Modified\n", BYPASS_EVENT_TYPE_MAX,
},
{
"HTTP/1.1 200 OK\n", false,
BYPASS_EVENT_TYPE_MISSING_VIA_HEADER_OTHER,
"HTTP/1.1 200 OK\n", BYPASS_EVENT_TYPE_MISSING_VIA_HEADER_OTHER,
},
{
"HTTP/1.1 200 OK\n"
"Chrome-Proxy: bypass=59\n",
false, BYPASS_EVENT_TYPE_SHORT,
BYPASS_EVENT_TYPE_SHORT,
},
{
"HTTP/1.1 502 Bad Gateway\n", false,
"HTTP/1.1 502 Bad Gateway\n",
BYPASS_EVENT_TYPE_STATUS_502_HTTP_BAD_GATEWAY,
},
{
"HTTP/1.1 502 Bad Gateway\n"
"Chrome-Proxy: bypass=59\n",
false, BYPASS_EVENT_TYPE_SHORT,
BYPASS_EVENT_TYPE_SHORT,
},
{
"HTTP/1.1 502 Bad Gateway\n"
"Chrome-Proxy: bypass=59\n",
false, BYPASS_EVENT_TYPE_SHORT,
BYPASS_EVENT_TYPE_SHORT,
},
{
"HTTP/1.1 414 Request-URI Too Long\n", false,
"HTTP/1.1 414 Request-URI Too Long\n",
BYPASS_EVENT_TYPE_MISSING_VIA_HEADER_4XX,
},
{
"HTTP/1.1 414 Request-URI Too Long\n"
"Via: 1.1 Chrome-Compression-Proxy\n",
false, BYPASS_EVENT_TYPE_MAX,
BYPASS_EVENT_TYPE_MAX,
},
{
"HTTP/1.1 407 Proxy Authentication Required\n", false,
"HTTP/1.1 407 Proxy Authentication Required\n",
BYPASS_EVENT_TYPE_MALFORMED_407,
},
{
"HTTP/1.1 407 Proxy Authentication Required\n"
"Proxy-Authenticate: Basic\n"
"Via: 1.1 Chrome-Compression-Proxy\n",
false, BYPASS_EVENT_TYPE_MAX,
},
{
"HTTP/1.1 200 OK\n", true, BYPASS_EVENT_TYPE_MAX,
},
{
"HTTP/1.1 414 Request-URI Too Long\n", true,
BYPASS_EVENT_TYPE_MISSING_VIA_HEADER_4XX,
BYPASS_EVENT_TYPE_MAX,
}};
for (size_t i = 0; i < arraysize(tests); ++i) {
std::string headers(tests[i].headers);
......@@ -754,12 +745,6 @@ TEST_F(DataReductionProxyHeadersTest, GetDataReductionProxyBypassEventType) {
new net::HttpResponseHeaders(headers));
DataReductionProxyInfo chrome_proxy_info;
base::FieldTrialList trial_list(nullptr);
base::FieldTrialList::CreateFieldTrial(
"DataReductionProxyServerExperiments",
tests[i].in_tamper_detection_experiment ? "TamperDetection_Enabled"
: "TamperDetection_Disabled");
EXPECT_EQ(tests[i].expected_result,
GetDataReductionProxyBypassType(std::vector<GURL>(), *parsed,
&chrome_proxy_info));
......
......@@ -148,12 +148,6 @@ bool IsIncludedInServerExperimentsFieldTrial() {
base::FieldTrialList::FindFullName(kServerExperimentsFieldTrial)
.find(kDisabled) != 0;
}
bool IsIncludedInTamperDetectionExperiment() {
return IsIncludedInServerExperimentsFieldTrial() &&
base::StartsWith(
base::FieldTrialList::FindFullName(kServerExperimentsFieldTrial),
"TamperDetection_Enabled", base::CompareCase::SENSITIVE);
}
bool FetchWarmupURLEnabled() {
// Fetching of the warmup URL can be enabled only for Enabled* and Control*
......
......@@ -64,9 +64,6 @@ const char* GetLoFiFlagFieldTrialName();
// server experiments for the data reduction proxy.
bool IsIncludedInServerExperimentsFieldTrial();
// Returns true if this client is part of the tamper detection experiment.
bool IsIncludedInTamperDetectionExperiment();
// Returns true if this client has any of the values to enable Lo-Fi mode for
// the "data-reduction-proxy-lo-fi" command line switch. This includes the
// "always-on", "cellular-only", and "slow-connections-only" values.
......
......@@ -205,48 +205,6 @@ TEST_F(DataReductionProxyParamsTest, AreServerExperimentsEnabled) {
}
}
TEST_F(DataReductionProxyParamsTest, IsTamperDetectionEnabled) {
const struct {
std::string test_case;
std::string trial_group_value;
bool disable_flag_set;
bool expected;
} tests[] = {
{
"Field trial not set", "", false, false,
},
{
"Field trial not set, flag set", "", true, false,
},
{
"Enabled", "Enabled", false, false,
},
{
"TamperDetection_Enabled but disabled via flag",
"TamperDetection_Enabled", true, false,
},
{
"TamperDetection_Enabled", "TamperDetection_Enabled", false, true,
},
};
for (const auto& test : tests) {
base::FieldTrialList field_trial_list(nullptr);
if (!test.trial_group_value.empty()) {
ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
"DataReductionProxyServerExperiments", test.trial_group_value));
}
base::CommandLine::ForCurrentProcess()->InitFromArgv(0, NULL);
if (test.disable_flag_set) {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kDataReductionProxyServerExperimentsDisabled, "");
}
EXPECT_EQ(test.expected, params::IsIncludedInTamperDetectionExperiment())
<< test.test_case;
}
}
// Tests if the QUIC field trial is set correctly.
TEST_F(DataReductionProxyParamsTest, QuicFieldTrial) {
const struct {
......
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