2015-03-16 02:15:51 +01:00
|
|
|
#include <messmer/blockstore/implementations/testfake/FakeBlockStore.h>
|
|
|
|
#include <messmer/fspp/fstest/FsTest.h>
|
2015-04-25 03:37:25 +02:00
|
|
|
#include <messmer/cpp-utils/tempfile/TempFile.h>
|
2015-03-16 02:15:51 +01:00
|
|
|
|
2015-09-12 20:16:13 +02:00
|
|
|
#include "../../src/filesystem/CryDevice.h"
|
2015-10-24 19:35:37 +02:00
|
|
|
#include "../../src/config/CryConfigLoader.h"
|
2015-10-22 18:48:04 +02:00
|
|
|
#include "../testutils/MockConsole.h"
|
2015-03-16 02:15:51 +01:00
|
|
|
|
2015-06-18 19:36:05 +02:00
|
|
|
using cpputils::unique_ref;
|
|
|
|
using cpputils::make_unique_ref;
|
2015-10-24 19:35:37 +02:00
|
|
|
using cpputils::Random;
|
2015-03-16 02:15:51 +01:00
|
|
|
|
|
|
|
using fspp::Device;
|
2015-10-22 18:48:04 +02:00
|
|
|
using ::testing::Return;
|
|
|
|
using ::testing::_;
|
2015-03-16 02:15:51 +01:00
|
|
|
|
|
|
|
using blockstore::testfake::FakeBlockStore;
|
|
|
|
|
|
|
|
using namespace cryfs;
|
|
|
|
|
2015-10-23 12:16:23 +02:00
|
|
|
class CryFsTestFixture: public FileSystemTestFixture, public TestWithMockConsole {
|
2015-03-16 02:15:51 +01:00
|
|
|
public:
|
|
|
|
CryFsTestFixture()
|
|
|
|
// Don't create config tempfile yet
|
|
|
|
: configFile(false) {}
|
|
|
|
|
2015-06-18 19:36:05 +02:00
|
|
|
unique_ref<Device> createDevice() override {
|
2015-07-21 18:22:03 +02:00
|
|
|
auto blockStore = cpputils::make_unique_ref<FakeBlockStore>();
|
2015-10-24 19:35:37 +02:00
|
|
|
auto config = CryConfigLoader(mockConsole(), Random::PseudoRandom(), [] {return "mypassword";})
|
2015-10-26 16:36:57 +01:00
|
|
|
.loadOrCreate(configFile.path()).value();
|
2015-06-18 19:36:05 +02:00
|
|
|
return make_unique_ref<CryDevice>(std::move(config), std::move(blockStore));
|
2015-03-16 02:15:51 +01:00
|
|
|
}
|
|
|
|
|
2015-04-25 03:37:25 +02: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);
|