v2.0.1-rc (#13)
All checks were successful
BlockStorage/repertory_osx_builds/pipeline/head This commit looks good
BlockStorage/repertory_linux_builds/pipeline/head This commit looks good

Reviewed-on: #13
This commit is contained in:
2023-12-10 18:11:20 +00:00
parent f43c41f88a
commit 1b8de3b097
404 changed files with 410072 additions and 146106 deletions

View File

@@ -1,57 +0,0 @@
/*
Copyright <2018-2023> <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 "test_common.hpp"
#include "app_config.hpp"
#include "db/directory_db.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 {
ASSERT_TRUE(utils::file::delete_directory_recursively(config_location_));
config_ =
std::make_unique<app_config>(provider_type::encrypt, config_location_);
db_ = std::make_unique<directory_db>(*config_.get());
}
void TearDown() override {
db_.reset();
config_.reset();
EXPECT_TRUE(utils::file::delete_directory_recursively(config_location_));
}
};
} // namespace repertory
#endif // REPERTORY_DIRECTORY_DB_FIXTURE_H

View File

@@ -1,57 +0,0 @@
/*
Copyright <2018-2023> <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_META_DB_FIXTURE_H
#define REPERTORY_META_DB_FIXTURE_H
#include "test_common.hpp"
#include "app_config.hpp"
#include "db/meta_db.hpp"
#include "utils/path_utils.hpp"
namespace repertory {
class meta_db_test : public ::testing::Test {
private:
const std::string config_location_ = utils::path::absolute("./metadb");
protected:
std::unique_ptr<app_config> config_;
std::unique_ptr<meta_db> db_;
public:
void SetUp() override {
ASSERT_TRUE(utils::file::delete_directory_recursively(config_location_));
config_ =
std::make_unique<app_config>(provider_type::sia, config_location_);
db_ = std::make_unique<meta_db>(*config_.get());
}
void TearDown() override {
db_.reset();
config_.reset();
EXPECT_TRUE(utils::file::delete_directory_recursively(config_location_));
}
};
} // namespace repertory
#endif // REPERTORY_META_DB_FIXTURE_H

View File

@@ -1,88 +0,0 @@
/*
Copyright <2018-2023> <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_S3_COMM_FIXTURE_H
#define REPERTORY_S3_COMM_FIXTURE_H
#if defined(REPERTORY_ENABLE_S3) && defined(REPERTORY_ENABLE_S3_TESTING)
#include "test_common.hpp"
#include "app_config.hpp"
#include "comm/s3/s3_comm.hpp"
#include "utils/path_utils.hpp"
namespace repertory {
class s3_comm_test : public ::testing::Test {
private:
console_consumer c_;
protected:
std::unique_ptr<app_config> config_;
std::unique_ptr<s3_comm> s3_comm_;
public:
void SetUp() override {
const auto path = utils::path::absolute("./test/");
ASSERT_TRUE(utils::file::delete_directory_recursively(path));
{
app_config config(provider_type::s3,
utils::path::combine(get_test_dir(), {"filebase"}));
config_ = std::make_unique<app_config>(provider_type::s3, "./test");
config_->set_event_level(event_level::verbose);
EXPECT_FALSE(config_
->set_value_by_name("S3Config.AccessKey",
config.get_s3_config().access_key)
.empty());
EXPECT_FALSE(config_
->set_value_by_name("S3Config.SecretKey",
config.get_s3_config().secret_key)
.empty());
EXPECT_FALSE(config_
->set_value_by_name("S3Config.Region",
config.get_s3_config().region)
.empty());
EXPECT_FALSE(
config_->set_value_by_name("S3Config.URL", config.get_s3_config().url)
.empty());
EXPECT_FALSE(
config_->set_value_by_name("S3Config.Bucket", "repertory").empty());
}
s3_comm_ = std::make_unique<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("./test/");
EXPECT_TRUE(utils::file::delete_directory_recursively(path));
}
};
} // namespace repertory
#endif // REPERTORY_ENABLE_S3_TESTING
#endif // REPERTORY_S3_COMM_FIXTURE_H

View File

@@ -1,149 +0,0 @@
/*
Copyright <2018-2023> <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_S3_PROVIDER_FILE_LIST_FIXTURE_H
#define REPERTORY_S3_PROVIDER_FILE_LIST_FIXTURE_H
#if defined(REPERTORY_ENABLE_S3) && defined(REPERTORY_ENABLE_S3_TESTING)
#include "test_common.hpp"
#include "mocks/mock_s3_comm.hpp"
#include "providers/s3/s3_provider.hpp"
#include "types/s3.hpp"
#include "utils/path_utils.hpp"
namespace repertory {
class s3_provider_file_list_test : public ::testing::Test {
public:
console_consumer c;
api_file_list list;
std::unique_ptr<app_config> cfg;
std::unique_ptr<mock_s3_comm> comm;
std::unique_ptr<s3_provider> provider;
std::array<std::uint64_t, 10> times = {
utils::get_file_time_now(), utils::get_file_time_now(),
utils::get_file_time_now(), utils::get_file_time_now(),
utils::get_file_time_now(), utils::get_file_time_now(),
utils::get_file_time_now(), utils::get_file_time_now(),
utils::get_file_time_now(), utils::get_file_time_now(),
};
public:
void SetUp() override {
ASSERT_TRUE(utils::file::delete_directory_recursively(
utils::path::absolute("./data")));
event_system::instance().start();
cfg = std::make_unique<app_config>(provider_type::s3,
utils::path::absolute("./data"));
EXPECT_FALSE(cfg->set_value_by_name("S3Config.Bucket", "bucket").empty());
EXPECT_FALSE(
cfg->set_value_by_name("S3Config.URL", "https://url.com").empty());
comm = std::make_unique<mock_s3_comm>(cfg->get_s3_config());
provider = std::make_unique<s3_provider>(*cfg, *comm);
const auto create_file = [this](std::size_t idx,
bool create_sub_directory = false) {
api_file file{};
file.accessed_date = times[idx];
if (create_sub_directory) {
file.api_path = utils::path::create_api_path(
"/dir/file_" + std::to_string(idx) + ".txt");
} else {
file.api_path = utils::path::create_api_path(
"/file_" + std::to_string(idx) + ".txt");
}
file.api_parent = utils::path::get_parent_api_path(file.api_path);
file.changed_date = times[idx] + 1u;
file.creation_date = times[idx] + 2u;
file.encryption_token = "";
file.file_size = 100u + idx;
file.modified_date = times[idx] + 3u;
this->list.emplace_back(std::move(file));
};
for (std::size_t idx = 0u; idx < times.size(); idx++) {
create_file(idx);
}
for (std::size_t idx = 0u; idx < times.size(); idx++) {
create_file(idx, true);
}
EXPECT_CALL(*comm, get_file_list)
.WillRepeatedly(
[this](const get_api_file_token_callback &get_api_file_token,
const get_name_callback &get_name, api_file_list &l) {
for (auto i : list) {
auto object_name = i.api_path;
object_name = get_name(
*(utils::string::split(i.api_path, '/', false).end() - 1u),
object_name);
i.api_path = object_name;
i.api_parent = utils::path::get_parent_api_path(i.api_path);
i.encryption_token = get_api_file_token(i.api_path);
l.emplace_back(i);
}
return api_error::success;
});
EXPECT_CALL(*comm, get_file)
.WillRepeatedly(
[this](const std::string &api_path, const get_key_callback &get_key,
const get_name_callback &get_name,
const get_token_callback &get_token, api_file &file) {
auto f = std::find_if(list.begin(), list.end(),
[&api_path](const auto &f) -> bool {
return f.api_path == api_path;
});
if (f == list.end()) {
return api_error::item_not_found;
}
file = *f;
auto object_name = api_path;
const auto key = get_key();
object_name = get_name(key, object_name);
file.api_path = utils::path::create_api_path(object_name);
file.api_parent = utils::path::get_parent_api_path(file.api_path);
file.encryption_token = get_token();
return api_error::success;
});
}
void TearDown() override {
provider->stop();
comm.reset();
provider.reset();
cfg.reset();
event_system::instance().stop();
EXPECT_TRUE(utils::file::delete_directory_recursively(
utils::path::absolute("./data")));
}
};
} // namespace repertory
#endif // REPERTORY_ENABLE_S3_TESTING
#endif // REPERTORY_S3_PROVIDER_FILE_LIST_FIXTURE_H

View File

@@ -1,150 +1,148 @@
/*
Copyright <2018-2023> <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 "test_common.hpp"
#include "app_config.hpp"
#include "comm/s3/s3_comm.hpp"
#include "comm/curl/curl_comm.hpp"
#include "drives/winfsp/winfsp_drive.hpp"
#include "platform/platform.hpp"
#include "providers/s3/s3_provider.hpp"
#include "providers/sia/sia_provider.hpp"
extern std::size_t PROVIDER_INDEX;
namespace repertory {
class winfsp_test : public ::testing::Test {
public:
lock_data lock_data_;
std::unique_ptr<app_config> config;
std::unique_ptr<curl_comm> comm;
std::unique_ptr<i_provider> provider;
std::unique_ptr<winfsp_drive> drive;
#ifdef REPERTORY_ENABLE_S3
std::unique_ptr<s3_comm> s3_comm_;
#endif
protected:
void SetUp() override {
if (PROVIDER_INDEX != 0) {
if (PROVIDER_INDEX == 1) {
#ifdef REPERTORY_ENABLE_S3
EXPECT_TRUE(utils::file::delete_directory_recursively(
"./winfsp_test" + std::to_string(PROVIDER_INDEX)));
app_config src_cfg(provider_type::s3,
utils::path::combine(get_test_dir(), {"filebase"}));
config = std::make_unique<app_config>(
provider_type::s3,
"./winfsp_test" + std::to_string(PROVIDER_INDEX));
EXPECT_FALSE(config
->set_value_by_name("S3Config.AccessKey",
src_cfg.get_s3_config().access_key)
.empty());
EXPECT_FALSE(config
->set_value_by_name("S3Config.SecretKey",
src_cfg.get_s3_config().secret_key)
.empty());
EXPECT_FALSE(config
->set_value_by_name("S3Config.Region",
src_cfg.get_s3_config().region)
.empty());
EXPECT_FALSE(
config
->set_value_by_name("S3Config.URL", src_cfg.get_s3_config().url)
.empty());
EXPECT_FALSE(
config->set_value_by_name("S3Config.Bucket", "repertory").empty());
config->set_event_level(event_level::verbose);
config->set_enable_drive_events(true);
event_system::instance().start();
s3_comm_ = std::make_unique<s3_comm>(*config);
provider = std::make_unique<s3_provider>(*config, *s3_comm_);
drive = std::make_unique<winfsp_drive>(*config, lock_data_, *provider);
#endif
return;
}
if (PROVIDER_INDEX == 2) {
EXPECT_TRUE(utils::file::delete_directory_recursively(
"./winfsp_test" + std::to_string(PROVIDER_INDEX)));
app_config src_cfg(provider_type::sia,
utils::path::combine(get_test_dir(), {"sia"}));
config = std::make_unique<app_config>(
provider_type::sia,
"./winfsp_test" + std::to_string(PROVIDER_INDEX));
[[maybe_unused]] auto val = config->set_value_by_name(
"HostConfig.AgentString", src_cfg.get_host_config().agent_string);
EXPECT_FALSE(
config
->set_value_by_name("HostConfig.ApiPassword",
src_cfg.get_host_config().api_password)
.empty());
EXPECT_FALSE(config
->set_value_by_name(
"HostConfig.ApiPort",
std::to_string(src_cfg.get_host_config().api_port))
.empty());
EXPECT_FALSE(
config
->set_value_by_name("HostConfig.HostNameOrIp",
src_cfg.get_host_config().host_name_or_ip)
.empty());
config->set_event_level(event_level::debug);
config->set_enable_drive_events(true);
event_system::instance().start();
comm = std::make_unique<curl_comm>(config->get_host_config());
provider = std::make_unique<sia_provider>(*config, *comm);
drive = std::make_unique<winfsp_drive>(*config, lock_data_, *provider);
return;
}
}
}
void TearDown() override {
if (PROVIDER_INDEX != 0) {
drive.reset();
provider.reset();
#ifdef REPERTORY_ENABLE_S3
s3_comm_.reset();
#endif
comm.reset();
config.reset();
event_system::instance().stop();
EXPECT_TRUE(utils::file::delete_directory_recursively(
"./winfsp_test" + std::to_string(PROVIDER_INDEX)));
}
}
};
} // namespace repertory
#endif
#endif // REPERTORY_WINFSP_FIXTURE_H
/*
Copyright <2018-2023> <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 "test_common.hpp"
#include "app_config.hpp"
#include "comm/curl/curl_comm.hpp"
#include "drives/winfsp/winfsp_drive.hpp"
#include "platform/platform.hpp"
#include "providers/s3/s3_provider.hpp"
#include "providers/sia/sia_provider.hpp"
extern std::size_t PROVIDER_INDEX;
namespace repertory {
class winfsp_test : public ::testing::Test {
public:
lock_data lock_data_;
std::unique_ptr<app_config> config;
std::unique_ptr<curl_comm> comm;
std::unique_ptr<i_provider> provider;
std::unique_ptr<winfsp_drive> drive;
protected:
void SetUp() override {
if (PROVIDER_INDEX != 0) {
if (PROVIDER_INDEX == 1) {
#ifdef REPERTORY_ENABLE_S3
EXPECT_TRUE(utils::file::delete_directory_recursively(
"./winfsp_test" + std::to_string(PROVIDER_INDEX)));
app_config src_cfg(provider_type::s3,
utils::path::combine(get_test_dir(), {"storj"}));
config = std::make_unique<app_config>(
provider_type::s3,
"./winfsp_test" + std::to_string(PROVIDER_INDEX));
EXPECT_FALSE(config
->set_value_by_name("S3Config.AccessKey",
src_cfg.get_s3_config().access_key)
.empty());
EXPECT_FALSE(config
->set_value_by_name("S3Config.SecretKey",
src_cfg.get_s3_config().secret_key)
.empty());
EXPECT_FALSE(config
->set_value_by_name("S3Config.Region",
src_cfg.get_s3_config().region)
.empty());
EXPECT_FALSE(
config
->set_value_by_name("S3Config.EncryptionToken",
src_cfg.get_s3_config().encryption_token)
.empty());
EXPECT_FALSE(
config
->set_value_by_name("S3Config.URL", src_cfg.get_s3_config().url)
.empty());
EXPECT_FALSE(
config->set_value_by_name("S3Config.Bucket", "repertory").empty());
config->set_event_level(event_level::verbose);
config->set_enable_drive_events(true);
event_system::instance().start();
comm = std::make_unique<curl_comm>(config->get_s3_config());
provider = std::make_unique<s3_provider>(*config, *comm);
drive = std::make_unique<winfsp_drive>(*config, lock_data_, *provider);
#endif
return;
}
if (PROVIDER_INDEX == 2) {
EXPECT_TRUE(utils::file::delete_directory_recursively(
"./winfsp_test" + std::to_string(PROVIDER_INDEX)));
app_config src_cfg(provider_type::sia,
utils::path::combine(get_test_dir(), {"sia"}));
config = std::make_unique<app_config>(
provider_type::sia,
"./winfsp_test" + std::to_string(PROVIDER_INDEX));
[[maybe_unused]] auto val = config->set_value_by_name(
"HostConfig.AgentString", src_cfg.get_host_config().agent_string);
EXPECT_FALSE(
config
->set_value_by_name("HostConfig.ApiPassword",
src_cfg.get_host_config().api_password)
.empty());
EXPECT_FALSE(config
->set_value_by_name(
"HostConfig.ApiPort",
std::to_string(src_cfg.get_host_config().api_port))
.empty());
EXPECT_FALSE(
config
->set_value_by_name("HostConfig.HostNameOrIp",
src_cfg.get_host_config().host_name_or_ip)
.empty());
config->set_event_level(event_level::debug);
config->set_enable_drive_events(true);
event_system::instance().start();
comm = std::make_unique<curl_comm>(config->get_host_config());
provider = std::make_unique<sia_provider>(*config, *comm);
drive = std::make_unique<winfsp_drive>(*config, lock_data_, *provider);
return;
}
}
}
void TearDown() override {
if (PROVIDER_INDEX != 0) {
drive.reset();
provider.reset();
comm.reset();
config.reset();
event_system::instance().stop();
EXPECT_TRUE(utils::file::delete_directory_recursively(
"./winfsp_test" + std::to_string(PROVIDER_INDEX)));
}
}
};
} // namespace repertory
#endif
#endif // REPERTORY_WINFSP_FIXTURE_H