OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/login/owner_key_utils.h" | 5 #include "chrome/browser/chromeos/login/owner_key_utils.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 std::vector<uint8>::iterator pubkey_it; | 59 std::vector<uint8>::iterator pubkey_it; |
60 std::vector<uint8>::iterator disk_it; | 60 std::vector<uint8>::iterator disk_it; |
61 for (pubkey_it = public_key.begin(), disk_it = from_disk.begin(); | 61 for (pubkey_it = public_key.begin(), disk_it = from_disk.begin(); |
62 pubkey_it < public_key.end(); | 62 pubkey_it < public_key.end(); |
63 pubkey_it++, disk_it++) { | 63 pubkey_it++, disk_it++) { |
64 EXPECT_EQ(*pubkey_it, *disk_it); | 64 EXPECT_EQ(*pubkey_it, *disk_it); |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
| 68 TEST_F(OwnerKeyUtilsTest, ImportPublicKeyFailed) { |
| 69 ScopedTempDir tmpdir; |
| 70 FilePath tmpfile; |
| 71 ASSERT_TRUE(tmpdir.CreateUniqueTempDir()); |
| 72 |
| 73 // First test the case where the file is missing which should fail. |
| 74 std::vector<uint8> from_disk; |
| 75 ASSERT_FALSE(utils_->ImportPublicKey(tmpfile, &from_disk)); |
| 76 |
| 77 // Next try empty file. This should fail and the array should be empty. |
| 78 from_disk.resize(10); |
| 79 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(tmpdir.path(), &tmpfile)); |
| 80 ASSERT_FALSE(utils_->ImportPublicKey(tmpfile, &from_disk)); |
| 81 ASSERT_FALSE(from_disk.size()); |
| 82 } |
| 83 |
68 } // namespace chromeos | 84 } // namespace chromeos |
OLD | NEW |