OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/common/chrome_paths.h" | 8 #include "chrome/common/chrome_paths.h" |
9 #include "chrome/utility/importer/firefox_importer_unittest_utils.h" | 9 #include "chrome/utility/importer/firefox_importer_unittest_utils.h" |
10 #include "chrome/utility/importer/nss_decryptor.h" | 10 #include "chrome/utility/importer/nss_decryptor.h" |
(...skipping 26 matching lines...) Loading... | |
37 | 37 |
38 ASSERT_TRUE(decryptor_proxy.DecryptorInit(nss_path, db_path)); | 38 ASSERT_TRUE(decryptor_proxy.DecryptorInit(nss_path, db_path)); |
39 EXPECT_EQ(base::ASCIIToUTF16("hello"), | 39 EXPECT_EQ(base::ASCIIToUTF16("hello"), |
40 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECKa" | 40 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECKa" |
41 "jtRg4qFSHBAhv9luFkXgDJA==")); | 41 "jtRg4qFSHBAhv9luFkXgDJA==")); |
42 // Test UTF-16 encoding. | 42 // Test UTF-16 encoding. |
43 EXPECT_EQ(base::WideToUTF16(L"\x4E2D"), | 43 EXPECT_EQ(base::WideToUTF16(L"\x4E2D"), |
44 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECLW" | 44 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECLW" |
45 "qqiccfQHWBAie74hxnULxlw==")); | 45 "qqiccfQHWBAie74hxnULxlw==")); |
46 } | 46 } |
47 | |
48 TEST(FirefoxImporterTest, MAYBE_NSS(FirefoxNSSDecryptorParseSignons)) { | |
vabr (Chromium)
2014/06/05 16:36:20
Please comment on what is the goal of this test.
I
| |
49 base::FilePath nss_path; | |
50 PasswordFormVector forms_from_signons, forms_template; | |
vabr (Chromium)
2014/06/05 16:36:20
nit: It seems to be more common in Chromium to hav
vabr (Chromium)
2014/06/05 16:36:20
nit: Consider renaming forms_template to expected_
| |
51 autofill::PasswordForm form; | |
52 form.origin = GURL("http://test1.server.com:1234/"); | |
53 form.action = GURL(""); | |
vabr (Chromium)
2014/06/05 16:36:20
nit: Please leave out assignments to the fields if
| |
54 form.username_element = base::ASCIIToUTF16(""); | |
55 form.username_value = base::ASCIIToUTF16("user1"); | |
56 form.password_element = base::ASCIIToUTF16(""); | |
57 form.password_value = base::ASCIIToUTF16("secret1"); | |
58 form.submit_element = base::ASCIIToUTF16(""); | |
59 form.signon_realm = "http://test1.server.com:1234/http_realm1"; | |
60 form.scheme = autofill::PasswordForm::SCHEME_BASIC; | |
61 forms_template.push_back(form); | |
62 | |
63 form.origin = GURL("http://test2.server.com:1234/"); | |
vabr (Chromium)
2014/06/05 16:36:20
nit: Please use a separate variable for the second
| |
64 form.action = GURL("http://test2.server.com:1234/action"); | |
65 form.username_element = base::ASCIIToUTF16("username"); | |
66 form.username_value = base::ASCIIToUTF16("user2"); | |
67 form.password_element = base::ASCIIToUTF16("password"); | |
68 form.password_value = base::ASCIIToUTF16("secret2"); | |
69 form.submit_element = base::ASCIIToUTF16(""); | |
70 form.signon_realm = "http://test2.server.com:1234/"; | |
71 form.scheme = autofill::PasswordForm::SCHEME_HTML; | |
72 forms_template.push_back(form); | |
73 | |
74 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path)); | |
75 #if defined(OS_MACOSX) | |
76 nss_path = nss_path.AppendASCII("firefox3_nss_mac"); | |
77 #else | |
78 nss_path = nss_path.AppendASCII("firefox3_nss"); | |
79 #endif // !OS_MACOSX | |
80 base::FilePath db_path; | |
81 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path)); | |
82 db_path = db_path.AppendASCII("firefox3_profile"); | |
83 | |
84 FFUnitTestDecryptorProxy decryptor_proxy; | |
85 ASSERT_TRUE(decryptor_proxy.Setup(nss_path)); | |
86 | |
87 ASSERT_TRUE(decryptor_proxy.DecryptorInit(nss_path, db_path)); | |
88 forms_from_signons = | |
89 decryptor_proxy.ParseSignons(db_path.AppendASCII("signons.sqlite")); | |
90 ASSERT_EQ(forms_template, forms_from_signons); | |
vabr (Chromium)
2014/06/05 16:36:20
Did you mean EXPECT_EQ instead of ASSERT_EQ?
ASSER
| |
91 } | |
OLD | NEW |