chromium/components/os_crypt/sync/key_storage_libsecret_unittest.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <string>
#include <unordered_map>

#include "base/lazy_instance.h"
#include "components/os_crypt/sync/key_storage_libsecret.h"
#include "components/os_crypt/sync/libsecret_util_linux.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/glib/scoped_gobject.h"

namespace {

const SecretSchema kKeystoreSchemaV2 =;

// This test mocks C-functions used by Libsecret. In order to present a
// consistent world view, we need a single backing instance that contains all
// the relevant data.
class MockPasswordStore {};
base::LazyInstance<MockPasswordStore>::Leaky g_password_store =;

// Replaces some of LibsecretLoader's methods with mocked ones.
class MockLibsecretLoader : public LibsecretLoader {};

const gchar* MockLibsecretLoader::mock_secret_value_get_text(
    SecretValue* value) {}

// static
gboolean MockLibsecretLoader::mock_secret_password_store_sync(
    const SecretSchema* schema,
    const gchar* collection,
    const gchar* label,
    const gchar* password,
    GCancellable* cancellable,
    GError** error,
    ...) {}

// static
void MockLibsecretLoader::mock_secret_value_unref(gpointer value) {}

// static
GList* MockLibsecretLoader::mock_secret_service_search_sync(
    SecretService* service,
    const SecretSchema* schema,
    GHashTable* attributes,
    SecretSearchFlags flags,
    GCancellable* cancellable,
    GError** error) {}

// static
SecretValue* MockLibsecretLoader::mock_secret_item_get_secret(
    SecretItem* item) {}

// static
guint64 MockLibsecretLoader::mock_secret_item_get_created(SecretItem* item) {}

// static
guint64 MockLibsecretLoader::mock_secret_item_get_modified(SecretItem* item) {}

// static
bool MockLibsecretLoader::ResetForOSCrypt() {}

// static
void MockLibsecretLoader::TearDown() {}

class LibsecretTest : public testing::Test {};

TEST_F(LibsecretTest, LibsecretRepeats) {}

TEST_F(LibsecretTest, LibsecretCreatesRandomised) {}

}  // namespace