| OLD | NEW |
| 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_update_protocol_manager.h" | 5 #include "components/safe_browsing_db/v4_update_protocol_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 TEST_F(V4UpdateProtocolManagerTest, TestBase64EncodingUsesUrlEncoding) { | 301 TEST_F(V4UpdateProtocolManagerTest, TestBase64EncodingUsesUrlEncoding) { |
| 302 // NOTE(vakh): I handpicked this value for state by generating random strings | 302 // NOTE(vakh): I handpicked this value for state by generating random strings |
| 303 // and picked the one that leads to a '-' in the base64 url encoded request | 303 // and picked the one that leads to a '-' in the base64 url encoded request |
| 304 // output. | 304 // output. |
| 305 std::string state_minus = "z-R~3ruViQH"; | 305 std::string state_minus = "z-R~3ruViQH"; |
| 306 StoreStateMap store_state_map_minus{ | 306 StoreStateMap store_state_map_minus{ |
| 307 {UpdateListIdentifier(LINUX_PLATFORM, URL, MALWARE_THREAT), state_minus}}; | 307 {UpdateListIdentifier(LINUX_PLATFORM, URL, MALWARE_THREAT), state_minus}}; |
| 308 std::string encoded_request_with_minus = | 308 std::string encoded_request_with_minus = |
| 309 V4UpdateProtocolManager::GetBase64SerializedUpdateRequestProto( | 309 V4UpdateProtocolManager::GetBase64SerializedUpdateRequestProto( |
| 310 store_state_map_minus); | 310 store_state_map_minus); |
| 311 EXPECT_EQ("GhcIARACGgt6LVJ-M3J1VmlRSCICIAEoAQ==", encoded_request_with_minus); | 311 EXPECT_EQ("GhkIARACGgt6LVJ-M3J1VmlRSCIEIAEgAigB", encoded_request_with_minus); |
| 312 | 312 |
| 313 // NOTE(vakh): Same process for chosing this string. I am representing it | 313 // NOTE(vakh): Same process for chosing this string. I am representing it |
| 314 // in base64 encoded form because the actual state value contains non-ASCII | 314 // in base64 encoded form because the actual state value contains non-ASCII |
| 315 // characters. | 315 // characters. |
| 316 std::string base64_encoded_state_underscore = "VTFfITBf4lBM"; | 316 std::string base64_encoded_state_underscore = "VTFfITBf4lBM"; |
| 317 std::string state_underscore; | 317 std::string state_underscore; |
| 318 base::Base64Decode(base64_encoded_state_underscore, &state_underscore); | 318 base::Base64Decode(base64_encoded_state_underscore, &state_underscore); |
| 319 StoreStateMap store_state_map_underscore{ | 319 StoreStateMap store_state_map_underscore{ |
| 320 {UpdateListIdentifier(LINUX_PLATFORM, URL, MALWARE_THREAT), | 320 {UpdateListIdentifier(LINUX_PLATFORM, URL, MALWARE_THREAT), |
| 321 state_underscore}}; | 321 state_underscore}}; |
| 322 std::string encoded_request_with_underscore = | 322 std::string encoded_request_with_underscore = |
| 323 V4UpdateProtocolManager::GetBase64SerializedUpdateRequestProto( | 323 V4UpdateProtocolManager::GetBase64SerializedUpdateRequestProto( |
| 324 store_state_map_underscore); | 324 store_state_map_underscore); |
| 325 EXPECT_EQ("GhUIARACGglVMV8hMF_iUEwiAiABKAE=", | 325 EXPECT_EQ("GhcIARACGglVMV8hMF_iUEwiBCABIAIoAQ==", |
| 326 encoded_request_with_underscore); | 326 encoded_request_with_underscore); |
| 327 } | 327 } |
| 328 | 328 |
| 329 } // namespace safe_browsing | 329 } // namespace safe_browsing |
| OLD | NEW |