Add basic test case for cryfs
This commit is contained in:
parent
74e9ffb9f4
commit
8f7853f01a
@ -28,6 +28,8 @@ using blobstore::onblocks::BlobStoreOnBlocks;
|
||||
using blobstore::onblocks::BlobOnBlocks;
|
||||
using blockstore::caching::CachingBlockStore;
|
||||
|
||||
namespace bf = boost::filesystem;
|
||||
|
||||
namespace cryfs {
|
||||
|
||||
constexpr uint32_t CryDevice::BLOCKSIZE_BYTES;
|
||||
|
@ -15,8 +15,6 @@
|
||||
namespace cryfs {
|
||||
class DirBlob;
|
||||
|
||||
namespace bf = boost::filesystem;
|
||||
|
||||
class CryDevice: public fspp::Device {
|
||||
public:
|
||||
static constexpr uint32_t BLOCKSIZE_BYTES = 32 * 1024;
|
||||
@ -32,9 +30,9 @@ public:
|
||||
std::unique_ptr<blobstore::Blob> LoadBlob(const blockstore::Key &key);
|
||||
void RemoveBlob(const blockstore::Key &key);
|
||||
|
||||
std::unique_ptr<fspp::Node> Load(const bf::path &path) override;
|
||||
std::unique_ptr<fspp::Node> Load(const boost::filesystem::path &path) override;
|
||||
|
||||
std::unique_ptr<DirBlob> LoadDirBlob(const bf::path &path);
|
||||
std::unique_ptr<DirBlob> LoadDirBlob(const boost::filesystem::path &path);
|
||||
|
||||
private:
|
||||
blockstore::Key GetOrCreateRootKey(CryConfig *config);
|
||||
|
35
test/CryFsTest.cpp
Normal file
35
test/CryFsTest.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include <google/gtest/gtest.h>
|
||||
#include <messmer/cpp-utils/tempfile/TempDir.h>
|
||||
#include <messmer/cpp-utils/tempfile/TempFile.h>
|
||||
#include <messmer/cpp-utils/pointer.h>
|
||||
#include <messmer/blockstore/implementations/ondisk/OnDiskBlockStore.h>
|
||||
#include "../src/CryDevice.h"
|
||||
#include "../src/CryDir.h"
|
||||
|
||||
//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) {
|
||||
{
|
||||
CryDevice dev(make_unique<CryConfig>(config.path()), make_unique<OnDiskBlockStore>(rootdir.path()));
|
||||
dev.Load(bf::path("/"));
|
||||
}
|
||||
CryDevice dev(make_unique<CryConfig>(config.path()), make_unique<OnDiskBlockStore>(rootdir.path()));
|
||||
dev.Load(bf::path("/"));
|
||||
}
|
Loading…
Reference in New Issue
Block a user