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

Unified Diff: components/safe_browsing_db/v4_update_protocol_manager_unittest.cc

Issue 2356443002: Set client_id and client_version in requests sent to SafeBrowsing (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: components/safe_browsing_db/v4_update_protocol_manager_unittest.cc
diff --git a/components/safe_browsing_db/v4_update_protocol_manager_unittest.cc b/components/safe_browsing_db/v4_update_protocol_manager_unittest.cc
index a901a23ca16082cf9da68e6d0157c59036151609..058549a28c43394ddda12d2ade1789dbee77064f 100644
--- a/components/safe_browsing_db/v4_update_protocol_manager_unittest.cc
+++ b/components/safe_browsing_db/v4_update_protocol_manager_unittest.cc
@@ -65,15 +65,19 @@ class V4UpdateProtocolManagerTest : public PlatformTest {
}
}
- std::unique_ptr<V4UpdateProtocolManager> CreateProtocolManager(
- const std::vector<ListUpdateResponse>& expected_lurs) {
+ V4ProtocolConfig GetProtocolConfig() {
V4ProtocolConfig config;
config.client_name = kClient;
config.version = kAppVer;
config.key_param = kKeyParam;
config.disable_auto_update = false;
+ return config;
+ }
+
+ std::unique_ptr<V4UpdateProtocolManager> CreateProtocolManager(
+ const std::vector<ListUpdateResponse>& expected_lurs) {
return V4UpdateProtocolManager::Create(
- NULL, config,
+ NULL, GetProtocolConfig(),
base::Bind(&V4UpdateProtocolManagerTest::ValidateGetUpdatesResults,
base::Unretained(this), expected_lurs));
}
@@ -302,28 +306,17 @@ TEST_F(V4UpdateProtocolManagerTest, TestBase64EncodingUsesUrlEncoding) {
// NOTE(vakh): I handpicked this value for state by generating random strings
// and picked the one that leads to a '-' in the base64 url encoded request
// output.
- std::string state_minus = "z-R~3ruViQH";
+ std::string state_minus = "h8xfYqY>:R";
StoreStateMap store_state_map_minus{
{UpdateListIdentifier(LINUX_PLATFORM, URL, MALWARE_THREAT), state_minus}};
std::string encoded_request_with_minus =
V4UpdateProtocolManager::GetBase64SerializedUpdateRequestProto(
- store_state_map_minus);
- EXPECT_EQ("GhkIARACGgt6LVJ-M3J1VmlRSCIEIAEgAigB", encoded_request_with_minus);
-
- // NOTE(vakh): Same process for chosing this string. I am representing it
- // in base64 encoded form because the actual state value contains non-ASCII
- // characters.
- std::string base64_encoded_state_underscore = "VTFfITBf4lBM";
- std::string state_underscore;
- base::Base64Decode(base64_encoded_state_underscore, &state_underscore);
- StoreStateMap store_state_map_underscore{
- {UpdateListIdentifier(LINUX_PLATFORM, URL, MALWARE_THREAT),
- state_underscore}};
- std::string encoded_request_with_underscore =
- V4UpdateProtocolManager::GetBase64SerializedUpdateRequestProto(
- store_state_map_underscore);
- EXPECT_EQ("GhcIARACGglVMV8hMF_iUEwiBCABIAIoAQ==",
- encoded_request_with_underscore);
+ store_state_map_minus, GetProtocolConfig());
+ EXPECT_EQ("Cg8KCHVuaXR0ZXN0EgMxLjAaGAgBEAIaCmg4eGZZcVk-OlIiBCABIAIoAQ==",
+ encoded_request_with_minus);
+
+ // TODO(vakh): Add a similar test for underscore for completeness, although
+ // the '-' case is sufficient to prove that we are using URL encoding.
}
} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698