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.
5 #include "chrome/browser/sync/glue/chrome_encryptor.h"
6 #include "components/webdata/encryptor/encryptor.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace browser_sync
{
13 const char kPlaintext
[] = "The Magic Words are Squeamish Ossifrage";
15 class ChromeEncryptorTest
: public testing::Test
{
17 ChromeEncryptor encryptor_
;
20 TEST_F(ChromeEncryptorTest
, EncryptDecrypt
) {
21 #if defined(OS_MACOSX)
22 // ChromeEncryptor ends up needing access to the keychain on OS X,
23 // so use the mock keychain to prevent prompts.
24 ::Encryptor::UseMockKeychain(true);
26 std::string ciphertext
;
27 EXPECT_TRUE(encryptor_
.EncryptString(kPlaintext
, &ciphertext
));
28 EXPECT_NE(kPlaintext
, ciphertext
);
29 std::string plaintext
;
30 EXPECT_TRUE(encryptor_
.DecryptString(ciphertext
, &plaintext
));
31 EXPECT_EQ(kPlaintext
, plaintext
);
36 } // namespace browser_sync