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

Unified Diff: chrome/browser/chromeos/login/owner_key_utils_unittest.cc

Issue 10824112: Move Chrome OS device settings stuff to chrome/browser/chromeos/settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 5 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/login/owner_key_utils.cc ('k') | chrome/browser/chromeos/login/owner_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/owner_key_utils_unittest.cc
diff --git a/chrome/browser/chromeos/login/owner_key_utils_unittest.cc b/chrome/browser/chromeos/login/owner_key_utils_unittest.cc
deleted file mode 100644
index 3d4eb2e7555cadf6a8d44941213d2c919b3bab00..0000000000000000000000000000000000000000
--- a/chrome/browser/chromeos/login/owner_key_utils_unittest.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/chromeos/login/owner_key_utils.h"
-
-#include <string>
-#include <vector>
-
-#include "base/file_path.h"
-#include "base/file_util.h"
-#include "base/memory/ref_counted.h"
-#include "base/scoped_temp_dir.h"
-#include "crypto/nss_util.h"
-#include "crypto/nss_util_internal.h"
-#include "crypto/rsa_private_key.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace chromeos {
-
-class OwnerKeyUtilsTest : public ::testing::Test {
- public:
- OwnerKeyUtilsTest() : utils_(OwnerKeyUtils::Create()) {}
- virtual ~OwnerKeyUtilsTest() {}
-
- virtual void SetUp() {
- crypto::OpenPersistentNSSDB();
- }
-
- // Key generation parameters.
- static const uint16 kKeySizeInBits;
-
- scoped_refptr<OwnerKeyUtils> utils_;
-};
-
-// We're generating and using 2048-bit RSA keys.
-// static
-const uint16 OwnerKeyUtilsTest::kKeySizeInBits = 2048;
-
-TEST_F(OwnerKeyUtilsTest, ExportImportPublicKey) {
- scoped_ptr<crypto::RSAPrivateKey> pair(
- crypto::RSAPrivateKey::CreateSensitive(kKeySizeInBits));
- ASSERT_NE(pair.get(), reinterpret_cast<crypto::RSAPrivateKey*>(NULL));
-
- // Export public key to file.
- ScopedTempDir tmpdir;
- FilePath tmpfile;
- ASSERT_TRUE(tmpdir.CreateUniqueTempDir());
- ASSERT_TRUE(file_util::CreateTemporaryFileInDir(tmpdir.path(), &tmpfile));
- ASSERT_TRUE(utils_->ExportPublicKeyToFile(pair.get(), tmpfile));
-
- // Export public key, so that we can compare it to the one we get off disk.
- std::vector<uint8> public_key;
- ASSERT_TRUE(pair->ExportPublicKey(&public_key));
- std::vector<uint8> from_disk;
- ASSERT_TRUE(utils_->ImportPublicKey(tmpfile, &from_disk));
-
- std::vector<uint8>::iterator pubkey_it;
- std::vector<uint8>::iterator disk_it;
- for (pubkey_it = public_key.begin(), disk_it = from_disk.begin();
- pubkey_it < public_key.end();
- pubkey_it++, disk_it++) {
- EXPECT_EQ(*pubkey_it, *disk_it);
- }
-}
-
-TEST_F(OwnerKeyUtilsTest, ImportPublicKeyFailed) {
- ScopedTempDir tmpdir;
- FilePath tmpfile;
- ASSERT_TRUE(tmpdir.CreateUniqueTempDir());
-
- // First test the case where the file is missing which should fail.
- std::vector<uint8> from_disk;
- ASSERT_FALSE(utils_->ImportPublicKey(tmpfile, &from_disk));
-
- // Next try empty file. This should fail and the array should be empty.
- from_disk.resize(10);
- ASSERT_TRUE(file_util::CreateTemporaryFileInDir(tmpdir.path(), &tmpfile));
- ASSERT_FALSE(utils_->ImportPublicKey(tmpfile, &from_disk));
- ASSERT_FALSE(from_disk.size());
-}
-
-} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/login/owner_key_utils.cc ('k') | chrome/browser/chromeos/login/owner_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698