| Index: components/data_reduction_proxy/common/data_reduction_proxy_headers_unittest.cc
|
| diff --git a/components/data_reduction_proxy/common/data_reduction_proxy_headers_unittest.cc b/components/data_reduction_proxy/common/data_reduction_proxy_headers_unittest.cc
|
| index 871d66589e0d4834e51ab59ab0bc56de6e3e1934..d62b726486236e4826a53ba93ca2c17b492ff845 100644
|
| --- a/components/data_reduction_proxy/common/data_reduction_proxy_headers_unittest.cc
|
| +++ b/components/data_reduction_proxy/common/data_reduction_proxy_headers_unittest.cc
|
| @@ -24,6 +24,102 @@ namespace data_reduction_proxy {
|
|
|
| class DataReductionProxyHeadersTest : public testing::Test {};
|
|
|
| +TEST_F(DataReductionProxyHeadersTest, GetDataReductionProxyActionValue) {
|
| + const struct {
|
| + const char* headers;
|
| + std::string action_key;
|
| + bool expected_result;
|
| + std::string expected_action_value;
|
| + } tests[] = {
|
| + { "HTTP/1.1 200 OK\n"
|
| + "Content-Length: 999\n",
|
| + "a",
|
| + false,
|
| + "",
|
| + },
|
| + { "HTTP/1.1 200 OK\n"
|
| + "connection: keep-alive\n"
|
| + "Content-Length: 999\n",
|
| + "a",
|
| + false,
|
| + "",
|
| + },
|
| + { "HTTP/1.1 200 OK\n"
|
| + "connection: keep-alive\n"
|
| + "Chrome-Proxy: bypass=86400\n"
|
| + "Content-Length: 999\n",
|
| + "bypass",
|
| + true,
|
| + "86400",
|
| + },
|
| + { "HTTP/1.1 200 OK\n"
|
| + "connection: keep-alive\n"
|
| + "Chrome-Proxy: bypass86400\n"
|
| + "Content-Length: 999\n",
|
| + "bypass",
|
| + false,
|
| + "",
|
| + },
|
| + { "HTTP/1.1 200 OK\n"
|
| + "connection: keep-alive\n"
|
| + "Chrome-Proxy: bypass=0\n"
|
| + "Content-Length: 999\n",
|
| + "bypass",
|
| + true,
|
| + "0",
|
| + },
|
| + { "HTTP/1.1 200 OK\n"
|
| + "connection: keep-alive\n"
|
| + "Chrome-Proxy: bypass=1500\n"
|
| + "Chrome-Proxy: bypass=86400\n"
|
| + "Content-Length: 999\n",
|
| + "bypass",
|
| + true,
|
| + "1500",
|
| + },
|
| + { "HTTP/1.1 200 OK\n"
|
| + "connection: keep-alive\n"
|
| + "Chrome-Proxy: block=1500, block=3600\n"
|
| + "Content-Length: 999\n",
|
| + "block",
|
| + true,
|
| + "1500",
|
| + },
|
| + { "HTTP/1.1 200 OK\n"
|
| + "connection: proxy-bypass\n"
|
| + "Chrome-Proxy: key=123 \n"
|
| + "Content-Length: 999\n",
|
| + "key",
|
| + true,
|
| + "123",
|
| + },
|
| + { "HTTP/1.1 200 OK\n"
|
| + "connection: proxy-bypass\n"
|
| + "Chrome-Proxy: key= \n"
|
| + "Content-Length: 999\n",
|
| + "key",
|
| + true,
|
| + "",
|
| + },
|
| + };
|
| + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
|
| + std::string headers(tests[i].headers);
|
| + HeadersToRaw(&headers);
|
| + scoped_refptr<net::HttpResponseHeaders> parsed(
|
| + new net::HttpResponseHeaders(headers));
|
| +
|
| + std::string action_value;
|
| + bool has_action_key = GetDataReductionProxyActionValue(parsed,
|
| + tests[i].action_key,
|
| + &action_value);
|
| + EXPECT_EQ(tests[i].expected_result, has_action_key);
|
| + if (has_action_key) {
|
| + EXPECT_EQ(tests[i].expected_action_value,
|
| + action_value);
|
| + }
|
| + }
|
| +}
|
| +
|
| TEST_F(DataReductionProxyHeadersTest, GetProxyBypassInfo) {
|
| const struct {
|
| const char* headers;
|
|
|