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

Unified Diff: components/webdata/encryptor/ie7_password_unittest_win.cc

Issue 26465006: Fix IE password import (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Renaming ie7_password to ie7_password_win Created 7 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 | « components/webdata/encryptor/ie7_password.cc ('k') | components/webdata/encryptor/ie7_password_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/webdata/encryptor/ie7_password_unittest_win.cc
diff --git a/components/webdata/encryptor/ie7_password_unittest_win.cc b/components/webdata/encryptor/ie7_password_unittest_win.cc
index 37021e8b99e7eba37389c19aa111e079c875d119..4c705fe4acc8b4ba8c2f40fb90136d99eb6531e6 100644
--- a/components/webdata/encryptor/ie7_password_unittest_win.cc
+++ b/components/webdata/encryptor/ie7_password_unittest_win.cc
@@ -8,53 +8,83 @@
#include <vector>
-#include "base/strings/string16.h"
-#include "components/webdata/encryptor/ie7_password.h"
+#include "components/webdata/encryptor/ie7_password_win.h"
TEST(IE7PasswordTest, GetUserPassword) {
// This is the unencrypted values of my keys under Storage2.
// The passwords have been manually changed to abcdef... but the size remains
// the same.
- unsigned char data1[] = "\x0c\x00\x00\x00\x38\x00\x00\x00\x2c\x00\x00\x00"
- "\x57\x49\x43\x4b\x18\x00\x00\x00\x02\x00\x00\x00"
- "\x67\x00\x72\x00\x01\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x4e\xfa\x67\x76\x22\x94\xc8\x01"
- "\x08\x00\x00\x00\x12\x00\x00\x00\x4e\xfa\x67\x76"
- "\x22\x94\xc8\x01\x0c\x00\x00\x00\x61\x00\x62\x00"
- "\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00"
- "\x00\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00"
- "\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00"
- "\x6c\x00\x00\x00";
-
- unsigned char data2[] = "\x0c\x00\x00\x00\x38\x00\x00\x00\x24\x00\x00\x00"
- "\x57\x49\x43\x4b\x18\x00\x00\x00\x02\x00\x00\x00"
- "\x67\x00\x72\x00\x01\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\xa8\xea\xf4\xe5\x9f\x9a\xc8\x01"
- "\x09\x00\x00\x00\x14\x00\x00\x00\xa8\xea\xf4\xe5"
- "\x9f\x9a\xc8\x01\x07\x00\x00\x00\x61\x00\x62\x00"
- "\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00"
- "\x69\x00\x00\x00\x61\x00\x62\x00\x63\x00\x64\x00"
- "\x65\x00\x66\x00\x67\x00\x00\x00";
-
+ const unsigned char kData1[] =
+ "\x0c\x00\x00\x00\x38\x00\x00\x00\x2c\x00\x00\x00"
+ "\x57\x49\x43\x4b\x18\x00\x00\x00\x02\x00\x00\x00"
+ "\x67\x00\x72\x00\x01\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x4e\xfa\x67\x76\x22\x94\xc8\x01"
+ "\x08\x00\x00\x00\x12\x00\x00\x00\x4e\xfa\x67\x76"
+ "\x22\x94\xc8\x01\x0c\x00\x00\x00\x61\x00\x62\x00"
+ "\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00"
+ "\x00\x00\x61\x00\x62\x00\x63\x00\x64\x00\x65\x00"
+ "\x66\x00\x67\x00\x68\x00\x69\x00\x6a\x00\x6b\x00"
+ "\x6c\x00\x00\x00";
+ const unsigned char kData2[] =
+ "\x0c\x00\x00\x00\x38\x00\x00\x00\x24\x00\x00\x00"
+ "\x57\x49\x43\x4b\x18\x00\x00\x00\x02\x00\x00\x00"
+ "\x67\x00\x72\x00\x01\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\xa8\xea\xf4\xe5\x9f\x9a\xc8\x01"
+ "\x09\x00\x00\x00\x14\x00\x00\x00\xa8\xea\xf4\xe5"
+ "\x9f\x9a\xc8\x01\x07\x00\x00\x00\x61\x00\x62\x00"
+ "\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00"
+ "\x69\x00\x00\x00\x61\x00\x62\x00\x63\x00\x64\x00"
+ "\x65\x00\x66\x00\x67\x00\x00\x00";
std::vector<unsigned char> decrypted_data1;
- decrypted_data1.resize(arraysize(data1));
- memcpy(&decrypted_data1.front(), data1, sizeof(data1));
+ decrypted_data1.resize(arraysize(kData1));
+ memcpy(&decrypted_data1.front(), kData1, sizeof(kData1));
std::vector<unsigned char> decrypted_data2;
- decrypted_data2.resize(arraysize(data2));
- memcpy(&decrypted_data2.front(), data2, sizeof(data2));
-
- string16 password;
- string16 username;
- ASSERT_TRUE(ie7_password::GetUserPassFromData(decrypted_data1, &username,
- &password));
- EXPECT_EQ(L"abcdefgh", username);
- EXPECT_EQ(L"abcdefghijkl", password);
-
- ASSERT_TRUE(ie7_password::GetUserPassFromData(decrypted_data2, &username,
- &password));
- EXPECT_EQ(L"abcdefghi", username);
- EXPECT_EQ(L"abcdefg", password);
+ decrypted_data2.resize(arraysize(kData2));
+ memcpy(&decrypted_data2.front(), kData2, sizeof(kData2));
+
+ std::vector<ie7_password::DecryptedCredentials> credentials;
+ ASSERT_TRUE(ie7_password::GetUserPassFromData(decrypted_data1, &credentials));
+ ASSERT_EQ(1u, credentials.size());
+ EXPECT_EQ(L"abcdefgh", credentials[0].username);
+ EXPECT_EQ(L"abcdefghijkl", credentials[0].password);
+
+ credentials.clear();
+ ASSERT_TRUE(ie7_password::GetUserPassFromData(decrypted_data2, &credentials));
+ ASSERT_EQ(1u, credentials.size());
+ EXPECT_EQ(L"abcdefghi", credentials[0].username);
+ EXPECT_EQ(L"abcdefg", credentials[0].password);
+}
+
+TEST(IE7PasswordTest, GetThreeUserPasswords) {
+ // Unencrypted binary data holding 3 sets of credentials
+ const unsigned char kData[] =
+ "\x0c\x00\x00\x00\x78\x00\x00\x00\x48\x00\x00\x00\x57\x49\x43\x4b\x18"
+ "\x00\x00\x00\x06\x00\x00\x00\x5c\x00\x55\x00\x01\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\xc3\xf2\x4b\xda\x1d\xc4\xce\x01\x04\x00\x00"
+ "\x00\x0a\x00\x00\x00\xc3\xf2\x4b\xda\x1d\xc4\xce\x01\x06\x00\x00\x00"
+ "\x18\x00\x00\x00\xbe\x5e\xe9\xe1\x1d\xc4\xce\x01\x04\x00\x00\x00\x22"
+ "\x00\x00\x00\xbe\x5e\xe9\xe1\x1d\xc4\xce\x01\x06\x00\x00\x00\x30\x00"
+ "\x00\x00\x07\x50\x1f\xe6\x1d\xc4\xce\x01\x04\x00\x00\x00\x3a\x00\x00"
+ "\x00\x07\x50\x1f\xe6\x1d\xc4\xce\x01\x06\x00\x00\x00\x71\x00\x77\x00"
+ "\x65\x00\x72\x00\x00\x00\x71\x00\x77\x00\x65\x00\x72\x00\x74\x00\x79"
+ "\x00\x00\x00\x61\x00\x73\x00\x64\x00\x66\x00\x00\x00\x61\x00\x73\x00"
+ "\x64\x00\x66\x00\x67\x00\x68\x00\x00\x00\x7a\x00\x78\x00\x63\x00\x76"
+ "\x00\x00\x00\x7a\x00\x78\x00\x63\x00\x76\x00\x62\x00\x6e\x00\x00\x00";
+
+ std::vector<unsigned char> decrypted_data;
+ decrypted_data.resize(arraysize(kData));
+ memcpy(&decrypted_data.front(), kData, sizeof(kData));
+
+ std::vector<ie7_password::DecryptedCredentials> credentials;
+ ASSERT_TRUE(ie7_password::GetUserPassFromData(decrypted_data, &credentials));
+ ASSERT_EQ(3u, credentials.size());
+ EXPECT_EQ(L"qwer", credentials[0].username);
+ EXPECT_EQ(L"qwerty", credentials[0].password);
+ EXPECT_EQ(L"asdf", credentials[1].username);
+ EXPECT_EQ(L"asdfgh", credentials[1].password);
+ EXPECT_EQ(L"zxcv", credentials[2].username);
+ EXPECT_EQ(L"zxcvbn", credentials[2].password);
}
« no previous file with comments | « components/webdata/encryptor/ie7_password.cc ('k') | components/webdata/encryptor/ie7_password_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698