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

Side by Side Diff: chrome/utility/importer/firefox_importer_unittest.cc

Issue 427303004: Fix various bits of error-handling in NSSDecryptor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add test Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/utility/importer/nss_decryptor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/common/chrome_paths.h" 9 #include "chrome/common/chrome_paths.h"
10 #include "chrome/utility/importer/firefox_importer_unittest_utils.h" 10 #include "chrome/utility/importer/firefox_importer_unittest_utils.h"
(...skipping 27 matching lines...) Expand all
38 ASSERT_TRUE(decryptor_proxy.Setup(nss_path)); 38 ASSERT_TRUE(decryptor_proxy.Setup(nss_path));
39 39
40 ASSERT_TRUE(decryptor_proxy.DecryptorInit(nss_path, db_path)); 40 ASSERT_TRUE(decryptor_proxy.DecryptorInit(nss_path, db_path));
41 EXPECT_EQ(base::ASCIIToUTF16("hello"), 41 EXPECT_EQ(base::ASCIIToUTF16("hello"),
42 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECKa" 42 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECKa"
43 "jtRg4qFSHBAhv9luFkXgDJA==")); 43 "jtRg4qFSHBAhv9luFkXgDJA=="));
44 // Test UTF-16 encoding. 44 // Test UTF-16 encoding.
45 EXPECT_EQ(base::WideToUTF16(L"\x4E2D"), 45 EXPECT_EQ(base::WideToUTF16(L"\x4E2D"),
46 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECLW" 46 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECLW"
47 "qqiccfQHWBAie74hxnULxlw==")); 47 "qqiccfQHWBAie74hxnULxlw=="));
48
49 // Test empty string edge case.
50 EXPECT_EQ(base::string16(), decryptor_proxy.Decrypt(""));
Ilya Sherman 2014/08/06 01:29:16 nit: Prefer std::string() to "".
davidben 2014/08/06 17:47:59 Done.
51
52 // Test invalid base64.
53 EXPECT_EQ(base::string16(), decryptor_proxy.Decrypt("Not! Valid! Base64!"));
48 } 54 }
49 55
50 // The following test verifies proper detection of authentication scheme in 56 // The following test verifies proper detection of authentication scheme in
51 // firefox's signons db. We insert two entries into moz_logins table. The first 57 // firefox's signons db. We insert two entries into moz_logins table. The first
52 // has httpRealm column filled with non-empty string, therefore resulting 58 // has httpRealm column filled with non-empty string, therefore resulting
53 // PasswordForm should have SCHEME_BASIC in scheme. The second entry has NULL 59 // PasswordForm should have SCHEME_BASIC in scheme. The second entry has NULL
54 // httpRealm, so it should produce a SCHEME_HTML PasswordForm. 60 // httpRealm, so it should produce a SCHEME_HTML PasswordForm.
55 TEST(FirefoxImporterTest, MAYBE_NSS(FirefoxNSSDecryptorDeduceAuthScheme)) { 61 TEST(FirefoxImporterTest, MAYBE_NSS(FirefoxNSSDecryptorDeduceAuthScheme)) {
56 base::ScopedTempDir temp_dir; 62 base::ScopedTempDir temp_dir;
57 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 63 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 ASSERT_TRUE(decryptor_proxy.Setup(nss_path)); 106 ASSERT_TRUE(decryptor_proxy.Setup(nss_path));
101 107
102 ASSERT_TRUE(decryptor_proxy.DecryptorInit(nss_path, db_path)); 108 ASSERT_TRUE(decryptor_proxy.DecryptorInit(nss_path, db_path));
103 std::vector<autofill::PasswordForm> forms = 109 std::vector<autofill::PasswordForm> forms =
104 decryptor_proxy.ParseSignons(signons_path); 110 decryptor_proxy.ParseSignons(signons_path);
105 111
106 ASSERT_EQ(2u, forms.size()); 112 ASSERT_EQ(2u, forms.size());
107 EXPECT_EQ(autofill::PasswordForm::SCHEME_BASIC, forms[0].scheme); 113 EXPECT_EQ(autofill::PasswordForm::SCHEME_BASIC, forms[0].scheme);
108 EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, forms[1].scheme); 114 EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, forms[1].scheme);
109 } 115 }
OLDNEW
« no previous file with comments | « no previous file | chrome/utility/importer/nss_decryptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698