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

Side by Side Diff: components/cryptauth/cryptauth_device_manager_unittest.cc

Issue 2611913002: Tweak CryptauthDeviceManager to store fetched BeaconSeed data in Base64URL encoding, and retrieve i… (Closed)
Patch Set: Fixing a comment. Created 3 years, 11 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
« no previous file with comments | « components/cryptauth/cryptauth_device_manager.cc ('k') | components/cryptauth/eid_generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/cryptauth/cryptauth_device_manager.h" 5 #include "components/cryptauth/cryptauth_device_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 const base::ListValue* beacon_seeds_from_prefs; 251 const base::ListValue* beacon_seeds_from_prefs;
252 if (device_dictionary->GetList("beacon_seeds", 252 if (device_dictionary->GetList("beacon_seeds",
253 &beacon_seeds_from_prefs)) { 253 &beacon_seeds_from_prefs)) {
254 ASSERT_EQ( 254 ASSERT_EQ(
255 (size_t) expected_device.beacon_seeds_size(), 255 (size_t) expected_device.beacon_seeds_size(),
256 beacon_seeds_from_prefs->GetSize()); 256 beacon_seeds_from_prefs->GetSize());
257 for (size_t i = 0; i < beacon_seeds_from_prefs->GetSize(); i++) { 257 for (size_t i = 0; i < beacon_seeds_from_prefs->GetSize(); i++) {
258 const base::DictionaryValue* seed; 258 const base::DictionaryValue* seed;
259 ASSERT_TRUE(beacon_seeds_from_prefs->GetDictionary(i, &seed)); 259 ASSERT_TRUE(beacon_seeds_from_prefs->GetDictionary(i, &seed));
260 260
261 std::string data, start_ms, end_ms; 261 std::string data_b64, start_ms, end_ms;
262 EXPECT_TRUE(seed->GetString("beacon_seed_data", &data)); 262 EXPECT_TRUE(seed->GetString("beacon_seed_data", &data_b64));
263 EXPECT_TRUE(seed->GetString("beacon_seed_start_ms", &start_ms)); 263 EXPECT_TRUE(seed->GetString("beacon_seed_start_ms", &start_ms));
264 EXPECT_TRUE(seed->GetString("beacon_seed_end_ms", &end_ms)); 264 EXPECT_TRUE(seed->GetString("beacon_seed_end_ms", &end_ms));
265 265
266 const cryptauth::BeaconSeed& expected_seed = 266 const cryptauth::BeaconSeed& expected_seed =
267 expected_device.beacon_seeds((int) i); 267 expected_device.beacon_seeds((int) i);
268
269 std::string data;
270 EXPECT_TRUE(base::Base64UrlDecode(
271 data_b64, base::Base64UrlDecodePolicy::REQUIRE_PADDING, &data));
268 EXPECT_TRUE(expected_seed.has_data()); 272 EXPECT_TRUE(expected_seed.has_data());
269 EXPECT_EQ(expected_seed.data(), data); 273 EXPECT_EQ(expected_seed.data(), data);
270 274
271 EXPECT_TRUE(expected_seed.has_start_time_millis()); 275 EXPECT_TRUE(expected_seed.has_start_time_millis());
272 EXPECT_EQ(expected_seed.start_time_millis(), std::stol(start_ms)); 276 EXPECT_EQ(expected_seed.start_time_millis(), std::stol(start_ms));
273 277
274 EXPECT_TRUE(expected_seed.has_end_time_millis()); 278 EXPECT_TRUE(expected_seed.has_end_time_millis());
275 EXPECT_EQ(expected_seed.end_time_millis(), std::stol(end_ms)); 279 EXPECT_EQ(expected_seed.end_time_millis(), std::stol(end_ms));
276 } 280 }
277 } else { 281 } else {
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 std::vector<cryptauth::ExternalDeviceInfo>(1, devices_in_response_[0]), 899 std::vector<cryptauth::ExternalDeviceInfo>(1, devices_in_response_[0]),
896 device_manager_->GetUnlockKeys()); 900 device_manager_->GetUnlockKeys());
897 901
898 // Only tether hosts. 902 // Only tether hosts.
899 ExpectSyncedDevicesAreEqual( 903 ExpectSyncedDevicesAreEqual(
900 std::vector<cryptauth::ExternalDeviceInfo>(1, devices_in_response_[0]), 904 std::vector<cryptauth::ExternalDeviceInfo>(1, devices_in_response_[0]),
901 device_manager_->GetTetherHosts()); 905 device_manager_->GetTetherHosts());
902 } 906 }
903 907
904 } // namespace cryptauth 908 } // namespace cryptauth
OLDNEW
« no previous file with comments | « components/cryptauth/cryptauth_device_manager.cc ('k') | components/cryptauth/eid_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698