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

Unified Diff: chrome/browser/chromeos/settings/device_settings_service_unittest.cc

Issue 660343002: Look for Owner key in both private and public slots (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Created 6 years, 2 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 | « chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/settings/device_settings_service_unittest.cc
diff --git a/chrome/browser/chromeos/settings/device_settings_service_unittest.cc b/chrome/browser/chromeos/settings/device_settings_service_unittest.cc
index 226c1e41aa211fdb88b4f170fb2a1cd325323ea1..85d60c1071c04d0ec74b085db8e7dc89a11f84a9 100644
--- a/chrome/browser/chromeos/settings/device_settings_service_unittest.cc
+++ b/chrome/browser/chromeos/settings/device_settings_service_unittest.cc
@@ -531,6 +531,42 @@ TEST_F(DeviceSettingsServiceTest, OnTPMTokenReadyForNonOwner) {
EXPECT_FALSE(is_owner_);
}
+TEST_F(DeviceSettingsServiceTest, OwnerPrivateKeyInTPMToken) {
+ owner_key_util_->Clear();
+
+ EXPECT_FALSE(device_settings_service_.HasPrivateOwnerKey());
+ EXPECT_FALSE(device_settings_service_.GetPublicKey().get());
+ EXPECT_EQ(DeviceSettingsService::OWNERSHIP_UNKNOWN,
+ device_settings_service_.GetOwnershipStatus());
+
+ const std::string& user_id = device_policy_.policy_data().username();
+ owner_key_util_->SetPublicKeyFromPrivateKey(*device_policy_.GetSigningKey());
+ InitOwner(user_id, false);
+ OwnerSettingsServiceChromeOS* service =
+ OwnerSettingsServiceChromeOSFactory::GetForProfile(profile_.get());
+ ASSERT_TRUE(service);
+ ReloadDeviceSettings();
+
+ EXPECT_FALSE(device_settings_service_.HasPrivateOwnerKey());
+ ASSERT_TRUE(device_settings_service_.GetPublicKey().get());
+ ASSERT_TRUE(device_settings_service_.GetPublicKey()->is_loaded());
+ std::vector<uint8> key;
+ ASSERT_TRUE(device_policy_.GetSigningKey()->ExportPublicKey(&key));
+ EXPECT_EQ(device_settings_service_.GetPublicKey()->data(), key);
+ EXPECT_EQ(DeviceSettingsService::OWNERSHIP_TAKEN,
+ device_settings_service_.GetOwnershipStatus());
+
+ owner_key_util_->SetPrivateKey(device_policy_.GetSigningKey());
+ service->OnTPMTokenReady(true /* is ready */);
+ FlushDeviceSettings();
+
+ EXPECT_TRUE(device_settings_service_.HasPrivateOwnerKey());
+ ASSERT_TRUE(device_settings_service_.GetPublicKey().get());
+ ASSERT_TRUE(device_settings_service_.GetPublicKey()->is_loaded());
+ ASSERT_TRUE(device_policy_.GetSigningKey()->ExportPublicKey(&key));
+ EXPECT_EQ(device_settings_service_.GetPublicKey()->data(), key);
+}
+
TEST_F(DeviceSettingsServiceTest, OnTPMTokenReadyForOwner) {
owner_key_util_->Clear();
« no previous file with comments | « chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698