OLD | NEW |
1 // Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009-2010 The Chromium OS 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 // Creates credential stores for testing | 5 // Creates credential stores for testing |
6 | 6 |
7 #include "make_tests.h" | 7 #include "make_tests.h" |
8 | 8 |
9 #include <base/file_path.h> | 9 #include <base/file_path.h> |
10 #include <base/file_util.h> | 10 #include <base/file_util.h> |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "vault_keyset.h" | 21 #include "vault_keyset.h" |
22 | 22 |
23 namespace cryptohome { | 23 namespace cryptohome { |
24 using ::testing::NiceMock; | 24 using ::testing::NiceMock; |
25 | 25 |
26 // struct TestUserInfo { | 26 // struct TestUserInfo { |
27 // const char* username; | 27 // const char* username; |
28 // const char* password; | 28 // const char* password; |
29 // bool create; | 29 // bool create; |
30 // bool use_old_format; | 30 // bool use_old_format; |
31 // const char* tracked_dirs[2]; | |
32 // }; | 31 // }; |
33 | 32 |
34 const TestUserInfo kDefaultUsers[] = { | 33 const TestUserInfo kDefaultUsers[] = { |
35 {"testuser0@invalid.domain", "zero", true, false, {NULL}}, | 34 {"testuser0@invalid.domain", "zero", true, false}, |
36 {"testuser1@invalid.domain", "one", true, false, {NULL}}, | 35 {"testuser1@invalid.domain", "one", true, false}, |
37 {"testuser2@invalid.domain", "two", true, false, {NULL}}, | 36 {"testuser2@invalid.domain", "two", true, false}, |
38 {"testuser3@invalid.domain", "three", true, false, {NULL}}, | 37 {"testuser3@invalid.domain", "three", true, false}, |
39 {"testuser4@invalid.domain", "four", true, false, {NULL}}, | 38 {"testuser4@invalid.domain", "four", true, false}, |
40 {"testuser5@invalid.domain", "five", false, false, {NULL}}, | 39 {"testuser5@invalid.domain", "five", false, false}, |
41 {"testuser6@invalid.domain", "six", true, false, {NULL}}, | 40 {"testuser6@invalid.domain", "six", true, false}, |
42 {"testuser7@invalid.domain", "seven", true, true, {NULL}}, | 41 {"testuser7@invalid.domain", "seven", true, true}, |
43 {"testuser8@invalid.domain", "eight", true, false, {NULL}}, | 42 {"testuser8@invalid.domain", "eight", true, false}, |
44 {"testuser9@invalid.domain", "nine", true, false, {"DIR0", NULL}}, | 43 {"testuser9@invalid.domain", "nine", true, false}, |
45 {"testuser10@invalid.domain", "ten", true, false, {"DIR0", NULL}}, | 44 {"testuser10@invalid.domain", "ten", true, false}, |
46 {"testuser11@invalid.domain", "eleven", true, false, {"DIR0", NULL}}, | 45 {"testuser11@invalid.domain", "eleven", true, false}, |
47 {"testuser12@invalid.domain", "twelve", false, false, {"DIR0", NULL}}, | 46 {"testuser12@invalid.domain", "twelve", false, false}, |
48 }; | 47 }; |
49 const size_t kDefaultUserCount = | 48 const size_t kDefaultUserCount = |
50 sizeof(kDefaultUsers) / sizeof(kDefaultUsers[0]); | 49 sizeof(kDefaultUsers) / sizeof(kDefaultUsers[0]); |
51 | 50 |
52 const TestUserInfo kAlternateUsers[] = { | 51 const TestUserInfo kAlternateUsers[] = { |
53 {"altuser0@invalid.domain", "zero", true, false, {"DIR0", NULL}}, | 52 {"altuser0@invalid.domain", "zero", true, false}, |
54 {"altuser1@invalid.domain", "odin", true, false}, | 53 {"altuser1@invalid.domain", "odin", true, false}, |
55 }; | 54 }; |
56 const size_t kAlternateUserCount = | 55 const size_t kAlternateUserCount = |
57 sizeof(kAlternateUsers) / sizeof(kAlternateUsers[0]); | 56 sizeof(kAlternateUsers) / sizeof(kAlternateUsers[0]); |
58 | 57 |
59 MakeTests::MakeTests() { | 58 MakeTests::MakeTests() { |
60 } | 59 } |
61 | 60 |
62 void MakeTests::InitTestData(const std::string& image_dir, | 61 void MakeTests::InitTestData(const std::string& image_dir, |
63 const TestUserInfo* test_users, | 62 const TestUserInfo* test_users, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 mount.set_fallback_to_scrypt(false); | 94 mount.set_fallback_to_scrypt(false); |
96 mount.Init(); | 95 mount.Init(); |
97 | 96 |
98 cryptohome::SecureBlob passkey; | 97 cryptohome::SecureBlob passkey; |
99 cryptohome::Crypto::PasswordToPasskey(test_users[i].password, | 98 cryptohome::Crypto::PasswordToPasskey(test_users[i].password, |
100 salt, | 99 salt, |
101 &passkey); | 100 &passkey); |
102 UsernamePasskey up(test_users[i].username, passkey); | 101 UsernamePasskey up(test_users[i].username, passkey); |
103 bool created; | 102 bool created; |
104 Mount::MountArgs mount_args; | 103 Mount::MountArgs mount_args; |
105 if (test_users[i].tracked_dirs[0] != NULL) { | |
106 mount_args.AssignSubdirsNullTerminatedList( | |
107 const_cast<const char**>(test_users[i].tracked_dirs)); | |
108 } | |
109 mount.EnsureCryptohome(up, mount_args, &created); | 104 mount.EnsureCryptohome(up, mount_args, &created); |
110 | 105 |
111 if (test_users[i].use_old_format) { | 106 if (test_users[i].use_old_format) { |
112 VaultKeyset vault_keyset; | 107 VaultKeyset vault_keyset; |
113 SerializedVaultKeyset serialized; | 108 SerializedVaultKeyset serialized; |
114 cryptohome::Mount::MountError error; | 109 cryptohome::Mount::MountError error; |
115 if (mount.DecryptVaultKeyset(up, false, &vault_keyset, &serialized, | 110 if (mount.DecryptVaultKeyset(up, false, &vault_keyset, &serialized, |
116 &error)) { | 111 &error)) { |
117 mount.RemoveOldFiles(up); | 112 mount.RemoveOldFiles(up); |
118 mount.SaveVaultKeysetOld(up, vault_keyset); | 113 mount.SaveVaultKeysetOld(up, vault_keyset); |
119 } | 114 } |
120 } | 115 } |
121 } | 116 } |
122 } | 117 } |
123 } | 118 } |
124 | 119 |
125 } // namespace cryptohome | 120 } // namespace cryptohome |
OLD | NEW |