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

Unified Diff: components/safe_browsing_db/v4_update_protocol_manager_unittest.cc

Issue 2090593003: Small: Use WebBase64/UrlBase64 encoding for requests sent to the server. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@01_UpdateDbAndStores
Patch Set: git pull 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/safe_browsing_db/v4_update_protocol_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f380e55f903d35d6d5b3c8d3d71b6a257fad0f27..b47cced59040b49150b0b24cc5eea2495f4f3c87 100644
--- a/components/safe_browsing_db/v4_update_protocol_manager_unittest.cc
+++ b/components/safe_browsing_db/v4_update_protocol_manager_unittest.cc
@@ -298,4 +298,31 @@ TEST_F(V4UpdateProtocolManagerTest, TestGetUpdatesWithOneBackoff) {
EXPECT_FALSE(pm->IsUpdateScheduled());
}
+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";
+ 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("GhMIARACGgt6LVJ-M3J1VmlRSCgB", 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("GhEIARACGglVMV8hMF_iUEwoAQ==", encoded_request_with_underscore);
+}
+
} // namespace safe_browsing
« no previous file with comments | « components/safe_browsing_db/v4_update_protocol_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698