libcryfs/test/cryfs/filesystem/FileSystemTest.cpp
Sebastian Messmer 9c83d3b2a4 If CRYFS_FRONTEND=noninteractive is set in the environment, assume we're used by a tool and:
- Don't ask for config. Use default settings for everything that is not specified as command line parameter.
- Don't ask for password confirmation. Password only has to be passed in once to stdin.
2016-02-21 01:36:14 +01:00

40 lines
1.2 KiB
C++

#include <blockstore/implementations/testfake/FakeBlockStore.h>
#include <fspp/fstest/FsTest.h>
#include <cpp-utils/tempfile/TempFile.h>
#include <cryfs/filesystem/CryDevice.h>
#include <cryfs/config/CryConfigLoader.h>
#include "../testutils/MockConsole.h"
using cpputils::unique_ref;
using cpputils::make_unique_ref;
using cpputils::Random;
using cpputils::SCrypt;
using fspp::Device;
using ::testing::Return;
using ::testing::_;
using boost::none;
using blockstore::testfake::FakeBlockStore;
using namespace cryfs;
class CryFsTestFixture: public FileSystemTestFixture, public TestWithMockConsole {
public:
CryFsTestFixture()
// Don't create config tempfile yet
: configFile(false) {}
unique_ref<Device> createDevice() override {
auto blockStore = cpputils::make_unique_ref<FakeBlockStore>();
auto askPassword = [] {return "mypassword";};
auto config = CryConfigLoader(mockConsole(), Random::PseudoRandom(), SCrypt::TestSettings, askPassword, askPassword, none, true)
.loadOrCreate(configFile.path()).value();
return make_unique_ref<CryDevice>(std::move(config), std::move(blockStore));
}
cpputils::TempFile configFile;
};
FSPP_ADD_FILESYTEM_TESTS(CryFS, CryFsTestFixture);