Index: components/data_reduction_proxy/core/common/data_reduction_proxy_headers_unittest.cc |
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_headers_unittest.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_headers_unittest.cc |
index e2f884493325f168f9be12986e7c3b37cbb85f1e..ebd09d4e251e2bcb1a021cb25573904db98c92f9 100644 |
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_headers_unittest.cc |
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_headers_unittest.cc |
@@ -18,6 +18,7 @@ |
#include "net/http/http_response_headers.h" |
#include "net/proxy/proxy_service.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+#include "url/gurl.h" |
namespace data_reduction_proxy { |
@@ -768,8 +769,79 @@ TEST_F(DataReductionProxyHeadersTest, GetDataReductionProxyBypassEventType) { |
tests[i].in_tamper_detection_experiment ? "TamperDetection_Enabled" |
: "TamperDetection_Disabled"); |
- EXPECT_EQ(tests[i].expected_result, GetDataReductionProxyBypassType( |
- parsed.get(), &chrome_proxy_info)); |
+ EXPECT_EQ(tests[i].expected_result, |
+ GetDataReductionProxyBypassType(std::vector<GURL>(), *parsed, |
+ &chrome_proxy_info)); |
+ } |
+} |
+ |
+TEST_F(DataReductionProxyHeadersTest, |
+ GetDataReductionProxyBypassEventTypeURLRedirectCycle) { |
+ const struct { |
+ const char* headers; |
+ std::vector<GURL> url_chain; |
+ DataReductionProxyBypassType expected_result; |
+ } tests[] = { |
+ { |
+ "HTTP/1.1 200 OK\n" |
+ "Via: 1.1 Chrome-Compression-Proxy\n", |
+ std::vector<GURL>{GURL("http://google.com/1"), |
+ GURL("http://google.com/2"), |
+ GURL("http://google.com/1")}, |
+ BYPASS_EVENT_TYPE_URL_REDIRECT_CYCLE, |
+ }, |
+ { |
+ "HTTP/1.1 200 OK\n" |
+ "Via: 1.1 Chrome-Compression-Proxy\n", |
+ std::vector<GURL>{ |
+ GURL("http://google.com/1"), GURL("http://google.com/2"), |
+ GURL("http://google.com/1"), GURL("http://google.com/2")}, |
+ BYPASS_EVENT_TYPE_URL_REDIRECT_CYCLE, |
+ }, |
+ { |
+ "HTTP/1.1 200 OK\n" |
+ "Via: 1.1 Chrome-Compression-Proxy\n", |
+ std::vector<GURL>{GURL("http://google.com/1")}, BYPASS_EVENT_TYPE_MAX, |
+ }, |
+ { |
+ "HTTP/1.1 200 OK\n" |
+ "Via: 1.1 Chrome-Compression-Proxy\n", |
+ std::vector<GURL>{GURL("http://google.com/1"), |
+ GURL("http://google.com/2")}, |
+ BYPASS_EVENT_TYPE_MAX, |
+ }, |
+ { |
+ "HTTP/1.1 200 OK\n" |
+ "Via: 1.1 Chrome-Compression-Proxy\n", |
+ std::vector<GURL>{GURL("http://google.com/1"), |
+ GURL("http://google.com/2"), |
+ GURL("http://google.com/3")}, |
+ BYPASS_EVENT_TYPE_MAX, |
+ }, |
+ { |
+ "HTTP/1.1 200 OK\n" |
+ "Via: 1.1 Chrome-Compression-Proxy\n", |
+ std::vector<GURL>{ |
+ GURL("http://google.com/1"), GURL("http://google.com/2"), |
+ GURL("http://google.com/3"), GURL("http://google.com/1")}, |
+ BYPASS_EVENT_TYPE_URL_REDIRECT_CYCLE, |
+ }, |
+ { |
+ "HTTP/1.1 200 OK\n" |
+ "Via: 1.1 Chrome-Compression-Proxy\n", |
+ std::vector<GURL>(), BYPASS_EVENT_TYPE_MAX, |
+ }}; |
+ |
+ for (const auto& test : tests) { |
+ std::string headers(test.headers); |
+ HeadersToRaw(&headers); |
+ scoped_refptr<net::HttpResponseHeaders> parsed( |
+ new net::HttpResponseHeaders(headers)); |
+ DataReductionProxyInfo chrome_proxy_info; |
+ |
+ EXPECT_EQ(test.expected_result, |
+ GetDataReductionProxyBypassType(test.url_chain, *parsed, |
+ &chrome_proxy_info)); |
} |
} |