libcryfs/test/cryfs/filesystem/FileSystemTest.cpp

40 lines
1.2 KiB
C++
Raw Normal View History

2016-02-11 16:39:42 +01:00
#include <blockstore/implementations/testfake/FakeBlockStore.h>
#include <fspp/fstest/FsTest.h>
#include <cpp-utils/tempfile/TempFile.h>
2015-03-16 02:15:51 +01:00
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"
2015-03-16 02:15:51 +01:00
using cpputils::unique_ref;
using cpputils::make_unique_ref;
using cpputils::Random;
using cpputils::SCrypt;
2015-03-16 02:15:51 +01:00
using fspp::Device;
2015-10-22 18:48:04 +02:00
using ::testing::Return;
using ::testing::_;
using boost::none;
2015-03-16 02:15:51 +01:00
using blockstore::testfake::FakeBlockStore;
using namespace cryfs;
class CryFsTestFixture: public FileSystemTestFixture, public TestWithMockConsole {
2015-03-16 02:15:51 +01:00
public:
CryFsTestFixture()
// Don't create config tempfile yet
: configFile(false) {}
unique_ref<Device> createDevice() override {
2015-07-21 18:22:03 +02:00
auto blockStore = cpputils::make_unique_ref<FakeBlockStore>();
auto askPassword = [] {return "mypassword";};
auto config = CryConfigLoader(mockConsole(), Random::PseudoRandom(), SCrypt::TestSettings, askPassword, askPassword, none, none, true)
.loadOrCreate(configFile.path()).value();
return make_unique_ref<CryDevice>(std::move(config), std::move(blockStore));
2015-03-16 02:15:51 +01:00
}
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);