initial commit
Some checks failed
BlockStorage/repertory_osx/pipeline/head There was a failure building this commit
BlockStorage/repertory_windows/pipeline/head This commit looks good
BlockStorage/repertory_linux_builds/pipeline/head This commit looks good

This commit is contained in:
2022-03-05 00:30:50 -06:00
commit 3ff46723b8
626 changed files with 178600 additions and 0 deletions

69
tests/fixtures/aws_s3_comm_fixture.hpp vendored Normal file
View File

@ -0,0 +1,69 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef REPERTORY_AWS_S3_COMM_FIXTURE_H
#define REPERTORY_AWS_S3_COMM_FIXTURE_H
#if defined(REPERTORY_ENABLE_S3_TESTING)
#include "comm/aws_s3/aws_s3_comm.hpp"
#include "app_config.hpp"
#include "test_common.hpp"
#include "utils/path_utils.hpp"
namespace repertory {
class aws_s3_comm_test : public ::testing::Test {
private:
console_consumer c_;
protected:
std::unique_ptr<app_config> config_;
std::unique_ptr<aws_s3_comm> s3_comm_;
public:
void SetUp() override {
const auto path = utils::path::absolute("./aws_test/");
utils::file::delete_directory_recursively(path);
{
app_config config(provider_type::s3, "../../filebase");
config_ = std::make_unique<app_config>(provider_type::s3, "./aws_test");
config_->set_event_level(event_level::verbose);
config_->set_value_by_name("S3Config.AccessKey", config.get_s3_config().access_key);
config_->set_value_by_name("S3Config.SecretKey", config.get_s3_config().secret_key);
config_->set_value_by_name("S3Config.Region", config.get_s3_config().region);
config_->set_value_by_name("S3Config.URL", config.get_s3_config().url);
config_->set_value_by_name("S3Config.Bucket", "");
}
s3_comm_ = std::make_unique<aws_s3_comm>(*config_);
event_system::instance().start();
}
void TearDown() override {
event_system::instance().stop();
s3_comm_.reset();
config_.reset();
const auto path = utils::path::absolute("./aws_test/");
utils::file::delete_directory_recursively(path);
}
};
} // namespace repertory
#endif // REPERTORY_ENABLE_S3_TESTING
#endif // REPERTORY_AWS_S3_COMM_FIXTURE_H

52
tests/fixtures/directory_db_fixture.hpp vendored Normal file
View File

@ -0,0 +1,52 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef REPERTORY_DIRECTORY_DB_FIXTURE_H
#define REPERTORY_DIRECTORY_DB_FIXTURE_H
#include "app_config.hpp"
#include "db/directory_db.hpp"
#include "test_common.hpp"
#include "utils/path_utils.hpp"
namespace repertory {
class directory_db_test : public ::testing::Test {
private:
const std::string config_location_ = utils::path::absolute("./directorydb");
protected:
std::unique_ptr<app_config> config_;
std::unique_ptr<directory_db> db_;
public:
void SetUp() override {
utils::file::delete_directory_recursively(config_location_);
config_ = std::make_unique<app_config>(provider_type::skynet, config_location_);
db_ = std::make_unique<directory_db>(*config_.get());
}
void TearDown() override {
db_.reset();
config_.reset();
utils::file::delete_directory_recursively(config_location_);
}
};
} // namespace repertory
#endif // REPERTORY_DIRECTORY_DB_FIXTURE_H

133
tests/fixtures/fuse_fixture.hpp vendored Normal file
View File

@ -0,0 +1,133 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef TESTS_FIXTURES_FUSE_FIXTURE_HPP_
#define TESTS_FIXTURES_FUSE_FIXTURE_HPP_
#if !_WIN32
#include "app_config.hpp"
#include "drives/fuse/fuse_drive.hpp"
#include "mocks/mock_comm.hpp"
#include "mocks/mock_s3_comm.hpp"
#include "platform/platform.hpp"
#include "providers/s3/s3_provider.hpp"
#include "providers/skynet/skynet_provider.hpp"
#include "providers/sia/sia_provider.hpp"
#include "test_common.hpp"
namespace repertory {
class fuse_test : public ::testing::Test {
public:
mock_comm mock_sia_comm_;
#ifdef REPERTORY_ENABLE_SKYNET
mock_comm mock_skynet_comm_;
#endif
#ifdef REPERTORY_ENABLE_S3_TESTING
/* mock_s3_comm mock_s3_comm_; */
#ifdef REPERTORY_ENABLE_SKYNET
std::array<std::tuple<std::shared_ptr<app_config>, std::shared_ptr<i_provider>,
std::shared_ptr<fuse_drive>>,
2>
provider_tests_;
#else
std::array<std::tuple<std::shared_ptr<app_config>, std::shared_ptr<i_provider>,
std::shared_ptr<fuse_drive>>,
1>
provider_tests_;
#endif
#else
#ifdef REPERTORY_ENABLE_SKYNET
std::array<std::tuple<std::shared_ptr<app_config>, std::shared_ptr<i_provider>,
std::shared_ptr<fuse_drive>>,
2>
provider_tests_;
#else
std::array<std::tuple<std::shared_ptr<app_config>, std::shared_ptr<i_provider>,
std::shared_ptr<fuse_drive>>,
1>
provider_tests_;
#endif
#endif
lock_data lock_data_;
protected:
void SetUp() override {
std::size_t provider_index = 0u;
utils::file::delete_directory_recursively("./fuse_test");
auto config = std::make_shared<app_config>(provider_type::sia, "./fuse_test");
config->set_enable_drive_events(true);
config->set_event_level(event_level::verbose);
config->set_api_port(11115);
auto sp = std::make_shared<sia_provider>(*config, mock_sia_comm_);
auto drive = std::make_shared<fuse_drive>(*config, lock_data_, *sp);
provider_tests_[provider_index++] = {config, sp, drive};
#ifdef REPERTORY_ENABLE_SKYNET
utils::file::delete_directory_recursively("./fuse_test2");
config = std::make_shared<app_config>(provider_type::skynet, "./fuse_test2");
config->set_enable_drive_events(true);
config->set_event_level(event_level::verbose);
config->set_api_port(11116);
auto skp = std::make_shared<skynet_provider>(*config, mock_skynet_comm_);
drive = std::make_shared<fuse_drive>(*config, lock_data_, *skp);
provider_tests_[provider_index++] = {config, skp, drive};
#endif
#ifdef REPERTORY_ENABLE_S3_TESTING
// utils::file::delete_directory_recursively("./fuse_test3");
// config = std::make_shared<app_config>(provider_type::s3, "./fuse_test3");
// config->SetEnableDriveEvents(true);
// config->set_event_level(event_level::Verbose);
// config->SetAPIPort(11117);
//{
// app_config config(provider_type::s3, "../../filebase");
// config->set_event_level(event_level::Verbose);
// config->set_value_by_name("S3Config.AccessKey", config.get_s3_config().AccessKey);
// config->set_value_by_name("S3Config.SecretKey", config.get_s3_config().SecretKey);
// config->set_value_by_name("S3Config.Region", config.get_s3_config().Region);
// config->set_value_by_name("S3Config.URL", config.get_s3_config().URL);
// config->set_value_by_name("S3Config.Bucket", "repertory");
//}
// mock_s3_comm_.SetS3Config(config->get_s3_config());
// auto s3p = std::make_shared<s3_provider>(*config, mock_s3_comm_);
// drive = std::make_shared<fuse_drive>(*config, lock_data_, *s3p);
// provider_tests_[provider_index++] = {config, s3p, drive};
#endif
event_system::instance().start();
}
void TearDown() override {
for (auto &i : provider_tests_) {
std::get<2>(i).reset();
}
event_system::instance().stop();
for (auto &i : provider_tests_) {
std::get<1>(i).reset();
std::get<0>(i).reset();
}
utils::file::delete_directory_recursively("./fuse_test");
utils::file::delete_directory_recursively("./fuse_test2");
utils::file::delete_directory_recursively("./fuse_test3");
}
};
} // namespace repertory
#endif
#endif // TESTS_FIXTURES_FUSE_FIXTURE_HPP_

View File

@ -0,0 +1,105 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef REPERTORY_SKYNET_PROVIDER_FIXTURE_H
#define REPERTORY_SKYNET_PROVIDER_FIXTURE_H
#if defined(REPERTORY_ENABLE_SKYNET)
#include "comm/curl/curl_comm.hpp"
#include "app_config.hpp"
#include "mocks/mock_open_file_table.hpp"
#include "providers/skynet/skynet_provider.hpp"
#include "test_common.hpp"
#include "utils/path_utils.hpp"
namespace repertory {
class skynet_provider_test : public ::testing::Test {
private:
console_consumer c_;
const std::string config_location_ = utils::path::absolute("./skynetprovider");
protected:
std::unique_ptr<app_config> config_;
std::unique_ptr<curl_comm> curl_comm_;
std::unique_ptr<skynet_provider> provider_;
mock_open_file_table oft_;
public:
void SetUp() override {
utils::file::delete_directory_recursively(config_location_);
config_ = std::make_unique<app_config>(provider_type::skynet, config_location_);
config_->set_event_level(event_level::verbose);
event_system::instance().start();
curl_comm_ = std::make_unique<curl_comm>(*config_.get());
provider_ = std::make_unique<skynet_provider>(*config_.get(), *curl_comm_.get());
const auto res = provider_->start(
[&](const std::string &api_path, const std::string &api_parent, const std::string &source,
const bool &directory, const std::uint64_t &created_date,
const std::uint64_t &accessed_date, const std::uint64_t &modified_date,
const std::uint64_t &changed_date) {
event_system::instance().raise<filesystem_item_added>(api_path, api_parent, directory);
#ifdef _WIN32
provider_->set_item_meta(
api_path, {{META_ATTRIBUTES, std::to_string(directory ? FILE_ATTRIBUTE_DIRECTORY
: FILE_ATTRIBUTE_NORMAL |
FILE_ATTRIBUTE_ARCHIVE)},
{META_CREATION, std::to_string(created_date)},
{META_WRITTEN, std::to_string(modified_date)},
{META_MODIFIED, std::to_string(modified_date)},
{ META_ACCESSED,
std::to_string(accessed_date) }});
#else
provider_->set_item_meta(
api_path,
{{META_CREATION, std::to_string(created_date)},
{META_MODIFIED, std::to_string(modified_date)},
{META_WRITTEN, std::to_string(modified_date)},
{META_ACCESSED, std::to_string(accessed_date)},
{META_OSXFLAGS, "0"},
{META_BACKUP, "0"},
{META_CHANGED, std::to_string(changed_date)},
{META_MODE, utils::string::from_uint32(directory ? S_IRUSR | S_IWUSR | S_IXUSR
: S_IRUSR | S_IWUSR)},
{META_UID, utils::string::from_uint32(getuid())},
{META_GID, utils::string::from_uint32(getgid())}});
#endif
if (not directory && not source.empty()) {
provider_->set_source_path(api_path, source);
}
},
&oft_);
EXPECT_FALSE(res);
}
void TearDown() override {
provider_->stop();
event_system::instance().stop();
curl_comm_.reset();
config_.reset();
provider_.reset();
utils::file::delete_directory_recursively(config_location_);
}
};
} // namespace repertory
#endif // REPERTORY_ENABLE_SKYNET
#endif // REPERTORY_SKYNET_PROVIDER_FIXTURE_H

85
tests/fixtures/winfsp_fixture.hpp vendored Normal file
View File

@ -0,0 +1,85 @@
/*
Copyright <2018-2022> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef REPERTORY_WINFSP_FIXTURE_H
#define REPERTORY_WINFSP_FIXTURE_H
#if _WIN32
#include "app_config.hpp"
#include "drives/winfsp/winfsp_drive.hpp"
#include "mocks/mock_comm.hpp"
#include "platform/platform.hpp"
#include "providers/sia/sia_provider.hpp"
#include "providers/skynet/skynet_provider.hpp"
#include "test_common.hpp"
extern std::size_t PROVIDER_INDEX;
namespace repertory {
class winfsp_test : public ::testing::Test {
public:
mock_comm mock_sia_comm_;
mock_comm mock_skynet_comm_;
std::array<std::tuple<std::shared_ptr<app_config>, std::shared_ptr<i_provider>,
std::shared_ptr<winfsp_drive>>,
2>
provider_tests_;
lock_data lock_data_;
protected:
void SetUp() override {
if (PROVIDER_INDEX != 0) {
utils::file::delete_directory_recursively("./winfsp_test");
auto config = std::make_shared<app_config>(provider_type::sia, "./winfsp_test");
config->set_enable_drive_events(true);
config->set_event_level(event_level::verbose);
config->set_api_port(11115);
auto sp = std::make_shared<sia_provider>(*config, mock_sia_comm_);
auto drive = std::make_shared<winfsp_drive>(*config, lock_data_, *sp);
provider_tests_[0] = {config, sp, drive};
config = std::make_shared<app_config>(provider_type::skynet, "./winfsp_test");
config->set_enable_drive_events(true);
config->set_event_level(event_level::verbose);
config->set_api_port(11116);
auto skp = std::make_shared<skynet_provider>(*config, mock_skynet_comm_);
drive = std::make_shared<winfsp_drive>(*config, lock_data_, *skp);
provider_tests_[1] = {config, skp, drive};
event_system::instance().start();
}
}
void TearDown() override {
if (PROVIDER_INDEX != 0) {
for (auto &i : provider_tests_) {
std::get<2>(i).reset();
}
event_system::instance().stop();
for (auto &i : provider_tests_) {
std::get<1>(i).reset();
std::get<0>(i).reset();
}
utils::file::delete_directory_recursively("./winfsp_test");
}
}
};
} // namespace repertory
#endif
#endif // REPERTORY_WINFSP_FIXTURE_H