libcryfs/test/cryfs/filesystem/FileSystemTest.cpp

42 lines
1.6 KiB
C++
Raw Normal View History

#include <blockstore/implementations/inmemory/InMemoryBlockStore2.h>
2016-02-11 16:39:42 +01:00
#include <fspp/fstest/FsTest.h>
#include <cpp-utils/tempfile/TempFile.h>
2016-09-25 02:50:28 +02:00
#include <cpp-utils/io/NoninteractiveConsole.h>
2016-02-11 16:39:42 +01:00
#include <cryfs/filesystem/CryDevice.h>
#include <cryfs/config/CryConfigLoader.h>
2015-10-22 18:48:04 +02:00
#include "../testutils/MockConsole.h"
#include "../testutils/TestWithFakeHomeDirectory.h"
2015-03-16 02:15:51 +01:00
using cpputils::unique_ref;
using cpputils::make_unique_ref;
using cpputils::Random;
using cpputils::SCrypt;
2016-09-25 02:50:28 +02:00
using cpputils::NoninteractiveConsole;
2015-03-16 02:15:51 +01:00
using fspp::Device;
using boost::none;
2016-09-25 02:50:28 +02:00
using std::make_shared;
using blockstore::inmemory::InMemoryBlockStore2;
2015-03-16 02:15:51 +01:00
using namespace cryfs;
class CryFsTestFixture: public FileSystemTestFixture, public TestWithMockConsole, public TestWithFakeHomeDirectory {
2015-03-16 02:15:51 +01:00
public:
CryFsTestFixture()
// Don't create config tempfile yet
: tempLocalStateDir(), localStateDir(tempLocalStateDir.path()), configFile(false) {}
2015-03-16 02:15:51 +01:00
unique_ref<Device> createDevice() override {
auto blockStore = cpputils::make_unique_ref<InMemoryBlockStore2>();
auto askPassword = [] {return "mypassword";};
auto config = CryConfigLoader(make_shared<NoninteractiveConsole>(mockConsole()), Random::PseudoRandom(), localStateDir, SCrypt::TestSettings, askPassword, askPassword, none, none, none)
2018-02-08 08:08:01 +01:00
.loadOrCreate(configFile.path(), false, false).value();
return make_unique_ref<CryDevice>(std::move(config.configFile), std::move(blockStore), localStateDir, config.myClientId, false, false);
2015-03-16 02:15:51 +01:00
}
cpputils::TempDir tempLocalStateDir;
LocalStateDir localStateDir;
cpputils::TempFile configFile;
2015-03-16 02:15:51 +01:00
};
2015-03-16 02:57:01 +01:00
FSPP_ADD_FILESYTEM_TESTS(CryFS, CryFsTestFixture);