blob: f4f73a3580eefe363d6a0a6d11c815e17aeeba92 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// 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_driver/system_encryptor.h"
#include "components/os_crypt/os_crypt.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace sync_driver {
namespace {
const char kPlaintext[] = "The Magic Words are Squeamish Ossifrage";
class SystemEncryptorTest : public testing::Test {
protected:
SystemEncryptor encryptor_;
};
TEST_F(SystemEncryptorTest, EncryptDecrypt) {
#if defined(OS_MACOSX)
// SystemEncryptor ends up needing access to the keychain on OS X,
// so use the mock keychain to prevent prompts.
::OSCrypt::UseMockKeychain(true);
#endif
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 sync_driver
|