Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: components/safe_browsing_db/v4_protocol_manager_util_unittest.cc

Issue 2057433002: Replace the old URL format for PVer4 requests with the new format. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move #include to *.cc and use forward declaration in .h Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/safe_browsing_db/v4_protocol_manager_util.h" 5 #include "components/safe_browsing_db/v4_protocol_manager_util.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "net/base/escape.h" 11 #include "net/base/escape.h"
12 #include "net/http/http_request_headers.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 using base::Time; 15 using base::Time;
15 using base::TimeDelta; 16 using base::TimeDelta;
16 17
17 namespace { 18 namespace {
18 19
19 const char kClient[] = "unittest"; 20 const char kClient[] = "unittest";
20 const char kAppVer[] = "1.0"; 21 const char kAppVer[] = "1.0";
21 const char kKeyParam[] = "test_key_param"; 22 const char kKeyParam[] = "test_key_param";
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 EXPECT_EQ(TimeDelta::FromHours(24), next); 101 EXPECT_EQ(TimeDelta::FromHours(24), next);
101 102
102 // 9 errors, reached max backoff and multiplier capped. 103 // 9 errors, reached max backoff and multiplier capped.
103 next = V4ProtocolManagerUtil::GetNextBackOffInterval( 104 next = V4ProtocolManagerUtil::GetNextBackOffInterval(
104 &error_count, &back_off_multiplier); 105 &error_count, &back_off_multiplier);
105 EXPECT_EQ(9U, error_count); 106 EXPECT_EQ(9U, error_count);
106 EXPECT_EQ(128U, back_off_multiplier); 107 EXPECT_EQ(128U, back_off_multiplier);
107 EXPECT_EQ(TimeDelta::FromHours(24), next); 108 EXPECT_EQ(TimeDelta::FromHours(24), next);
108 } 109 }
109 110
110 TEST_F(SafeBrowsingV4ProtocolManagerUtilTest, TestGetRequestUrl) { 111 TEST_F(SafeBrowsingV4ProtocolManagerUtilTest,
112 TestGetRequestUrlAndUpdateHeaders) {
111 V4ProtocolConfig config; 113 V4ProtocolConfig config;
112 PopulateV4ProtocolConfig(&config); 114 PopulateV4ProtocolConfig(&config);
113 115
114 std::string expectedUrl = 116 std::string expectedUrl =
115 "https://safebrowsing.googleapis.com/v4/someMethod/request_base64?" 117 "https://safebrowsing.googleapis.com/v4/someMethod?"
116 "alt=proto&client_id=unittest&client_version=1.0&key=test_key_param"; 118 "$req=request_base64&$ct=application/x-protobuf&key=test_key_param";
117 EXPECT_EQ(expectedUrl, V4ProtocolManagerUtil::GetRequestUrl( 119 net::HttpRequestHeaders headers;
118 "request_base64", "someMethod", config) 120 EXPECT_EQ(expectedUrl, V4ProtocolManagerUtil::GetRequestUrlAndUpdateHeaders(
121 "request_base64", "someMethod", config, &headers)
119 .spec()); 122 .spec());
123 std::string header_value;
124 EXPECT_TRUE(headers.GetHeader("X-HTTP-Method-Override", &header_value));
125 EXPECT_EQ("POST", header_value);
120 } 126 }
121 127
122 } // namespace safe_browsing 128 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698