2015-04-27 16:38:09 +02:00
|
|
|
#include <google/gtest/gtest.h>
|
|
|
|
#include <messmer/cpp-utils/tempfile/TempDir.h>
|
|
|
|
#include <messmer/cpp-utils/tempfile/TempFile.h>
|
2015-06-21 17:44:45 +02:00
|
|
|
#include <messmer/cpp-utils/pointer/cast.h>
|
2015-04-27 16:38:09 +02:00
|
|
|
#include <messmer/blockstore/implementations/ondisk/OnDiskBlockStore.h>
|
|
|
|
#include "../src/CryDevice.h"
|
|
|
|
#include "../src/CryDir.h"
|
2015-04-27 18:00:11 +02:00
|
|
|
#include "../src/CryFile.h"
|
|
|
|
#include "../src/CryOpenFile.h"
|
2015-04-27 16:38:09 +02:00
|
|
|
|
|
|
|
//TODO (whole project) Make constructors explicit when implicit construction not needed
|
|
|
|
|
|
|
|
using ::testing::Test;
|
|
|
|
using cpputils::TempDir;
|
|
|
|
using cpputils::TempFile;
|
|
|
|
using cpputils::dynamic_pointer_move;
|
|
|
|
using std::make_unique;
|
|
|
|
using blockstore::ondisk::OnDiskBlockStore;
|
|
|
|
|
|
|
|
namespace bf = boost::filesystem;
|
|
|
|
using namespace cryfs;
|
|
|
|
|
|
|
|
class CryFsTest: public Test {
|
|
|
|
public:
|
|
|
|
CryFsTest(): rootdir(), config(false) {}
|
|
|
|
TempDir rootdir;
|
|
|
|
TempFile config;
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(CryFsTest, CreatedRootdirIsLoadableAfterClosing) {
|
|
|
|
{
|
2015-06-17 12:28:18 +02:00
|
|
|
CryDevice dev(CryConfigLoader::createNewWithWeakKey(config.path()), make_unique<OnDiskBlockStore>(rootdir.path()));
|
2015-04-27 16:38:09 +02:00
|
|
|
}
|
2015-06-28 17:02:20 +02:00
|
|
|
CryDevice dev(CryConfigLoader::loadExisting(config.path()).value(), make_unique<OnDiskBlockStore>(rootdir.path()));
|
2015-06-17 12:28:18 +02:00
|
|
|
auto root = dev.Load(bf::path("/"));
|
2015-06-18 19:36:05 +02:00
|
|
|
dynamic_pointer_move<CryDir>(root.get()).get()->children();
|
2015-06-17 12:28:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(CryFsTest, UsingStrongKey1_CreatedRootdirIsLoadableAfterClosing) {
|
|
|
|
{
|
|
|
|
CryDevice dev(CryConfigLoader::createNew(config.path()), make_unique<OnDiskBlockStore>(rootdir.path()));
|
|
|
|
}
|
2015-06-28 17:02:20 +02:00
|
|
|
CryDevice dev(CryConfigLoader::loadExisting(config.path()).value(), make_unique<OnDiskBlockStore>(rootdir.path()));
|
2015-06-17 12:28:18 +02:00
|
|
|
auto root = dev.Load(bf::path("/"));
|
2015-06-18 19:36:05 +02:00
|
|
|
dynamic_pointer_move<CryDir>(root.get()).get()->children();
|
2015-06-17 12:28:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(CryFsTest, UsingStrongKey2_CreatedRootdirIsLoadableAfterClosing) {
|
|
|
|
{
|
|
|
|
CryDevice dev(CryConfigLoader::loadOrCreate(config.path()), make_unique<OnDiskBlockStore>(rootdir.path()));
|
|
|
|
}
|
|
|
|
CryDevice dev(CryConfigLoader::loadOrCreate(config.path()), make_unique<OnDiskBlockStore>(rootdir.path()));
|
2015-04-27 18:00:11 +02:00
|
|
|
auto root = dev.Load(bf::path("/"));
|
2015-06-18 19:36:05 +02:00
|
|
|
dynamic_pointer_move<CryDir>(root.get()).get()->children();
|
2015-04-27 16:38:09 +02:00
|
|
|
}
|