blob: 9c31a8dc248f9bda9e08688ba6c5c6548d3d6081 [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/sync/base/system_encryptor.h"
#include "build/build_config.h"
#include "components/os_crypt/os_crypt_mocker.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace syncer {
namespace {
const char kPlaintext[] = "The Magic Words are Squeamish Ossifrage";
class SystemEncryptorTest : public testing::Test {
SystemEncryptor encryptor_;
TEST_F(SystemEncryptorTest, EncryptDecrypt) {
// SystemEncryptor ends up needing access to the keychain on OS X,
// so use the mock keychain to prevent prompts.
std::string ciphertext;
EXPECT_TRUE(encryptor_.EncryptString(kPlaintext, &ciphertext));
EXPECT_NE(kPlaintext, ciphertext);
std::string plaintext;
EXPECT_TRUE(encryptor_.DecryptString(ciphertext, &plaintext));
EXPECT_EQ(kPlaintext, plaintext);
} // namespace
} // namespace syncer