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 3 // found in the LICENSE file. 4 5 #include "base/files/file_path.h" 6 #include "base/path_service.h" 7 #include "base/strings/utf_string_conversions.h" 8 #include "chrome/common/chrome_paths.h" 9 #include "chrome/utility/importer/firefox_importer_unittest_utils.h" 10 #include "chrome/utility/importer/nss_decryptor.h" 11 #include "testing/gtest/include/gtest/gtest.h" 12 13 // TODO(jschuh): Disabled on Win64 build. http://crbug.com/179688 14 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) 15 #define MAYBE_NSS(x) DISABLED_##x 16 #else 17 #define MAYBE_NSS(x) x 18 #endif 19 20 // The following test requires the use of the NSSDecryptor, on OSX this needs 21 // to run in a separate process, so we use a proxy object so we can share the 22 // same test between platforms. 23 TEST(FirefoxImporterTest, MAYBE_NSS(Firefox3NSS3Decryptor)) { 24 base::FilePath nss_path; 25 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path)); 26 #if defined(OS_MACOSX) 27 nss_path = nss_path.AppendASCII("firefox3_nss_mac"); 28 #else 29 nss_path = nss_path.AppendASCII("firefox3_nss"); 30 #endif // !OS_MACOSX 31 base::FilePath db_path; 32 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path)); 33 db_path = db_path.AppendASCII("firefox3_profile"); 34 35 FFUnitTestDecryptorProxy decryptor_proxy; 36 ASSERT_TRUE(decryptor_proxy.Setup(nss_path)); 37 38 ASSERT_TRUE(decryptor_proxy.DecryptorInit(nss_path, db_path)); 39 EXPECT_EQ(ASCIIToUTF16("hello"), 40 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECKa" 41 "jtRg4qFSHBAhv9luFkXgDJA==")); 42 // Test UTF-16 encoding. 43 EXPECT_EQ(WideToUTF16(L"\x4E2D"), 44 decryptor_proxy.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAEwFAYIKoZIhvcNAwcECLW" 45 "qqiccfQHWBAie74hxnULxlw==")); 46 } 47