diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 3a833a5df6edb8f99e0f56fe8df2f83280f2ce73..35a77a1a47dd339cb229a2fc1ab63a90f3605997 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -142,8 +142,6 @@ else() endif() find_package(nlohmann_json 3.7.3 REQUIRED) - -set(SQLite3_DIR ${VENDOR_INSTALL_DIR}) find_package(SQLite3 REQUIRED) add_subdirectory("src") diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt index 62c0db650441125d6066b1826169ddeabe99525f..c97a2279b2700354c0e8a94e36dda3887c7769df 100644 --- a/cpp/src/CMakeLists.txt +++ b/cpp/src/CMakeLists.txt @@ -93,6 +93,10 @@ if (LINUX) list(APPEND VEREIGNLIB_SRC vereign/kvstore/detail/linux_crypto_storage.cc ) +elseif (WIN32) + list(APPEND VEREIGNLIB_SRC + vereign/kvstore/detail/linux_crypto_storage.cc + ) endif() # file(GLOB GENERATED_SERVICES_SRC vereign/service/gen/*.cc) diff --git a/cpp/src/vereign/bytes/view.hh b/cpp/src/vereign/bytes/view.hh index fb3f5b95ed72eed0da837cb984d4c557a69156d3..ddf1c7514b8df61731d6d96c6e38ad3937c18309 100644 --- a/cpp/src/vereign/bytes/view.hh +++ b/cpp/src/vereign/bytes/view.hh @@ -5,6 +5,7 @@ #include <string> #include <string_view> #include <stdexcept> +#include <algorithm> namespace vereign::bytes { @@ -61,7 +62,7 @@ public: return size_; } - auto String() noexcept -> std::string_view { + auto String() const noexcept -> std::string_view { return std::string_view{CharData(), size_}; } @@ -82,8 +83,8 @@ public: } private: - std::size_t size_; - const uint8_t* data_; + std::size_t size_ = 0; + const uint8_t* data_ = nullptr; }; } // namespace vereign::bytes diff --git a/cpp/src/vereign/kvstore/crypto_storage.cc b/cpp/src/vereign/kvstore/crypto_storage.cc index 4a24ea5d01b9b907b24929a33d991cafc1c81a52..20b29579f5101e52a5f09c214d42a00c68066148 100644 --- a/cpp/src/vereign/kvstore/crypto_storage.cc +++ b/cpp/src/vereign/kvstore/crypto_storage.cc @@ -1,7 +1,8 @@ #include <vereign/kvstore/crypto_storage.hh> #if defined(_WIN32) -# include <vereign/kvstore/detail/win_crypto_storage.hh> +// # include <vereign/kvstore/detail/win_crypto_storage.hh> +# include <vereign/kvstore/detail/linux_crypto_storage.hh> #else # include <vereign/kvstore/detail/linux_crypto_storage.hh> #endif diff --git a/cpp/tests/vereign/service/identity_service_test.cc b/cpp/tests/vereign/service/identity_service_test.cc index f793944772decf11e213a7f5502190d8873bae61..7c94edc56ca382916336af8722c5e71274975e07 100644 --- a/cpp/tests/vereign/service/identity_service_test.cc +++ b/cpp/tests/vereign/service/identity_service_test.cc @@ -9,6 +9,7 @@ #include <vereign/test/device.hh> #include <vereign/test/service_context.hh> #include <vereign/core/temp.hh> +#include <vereign/core/fs.hh> #include <util/env.hh> #include <util/protobuf.hh> @@ -23,11 +24,15 @@ TEST_CASE("service::IdentityService::LoginWithNewDevice", "[vereign/service][.in auto port = test::GetEnv("TEST_VEREIGN_API_PORT", "https"); // the old device is used later for new device confirmation and authorization - auto old_device_ctx = test::ServiceContext{host, port, core::TempFilePath("test_db_")}; + auto old_storage_path = core::TempFilePath("test_db_"); + auto rm_old_storage_path = core::RemoveFileGuard{old_storage_path}; + auto old_device_ctx = test::ServiceContext{host, port, old_storage_path}; auto old_device = test::Device{old_device_ctx}; old_device.Login(public_key); - auto service_context = test::ServiceContext{host, port, core::TempFilePath("test_db_")}; + auto storage_path = core::TempFilePath("test_db_"); + auto rm_storage_path = core::RemoveFileGuard{storage_path}; + auto service_context = test::ServiceContext{host, port, storage_path}; auto service = service::IdentityService{ service_context.IdentityProvider(), service_context.ClientSession() @@ -65,7 +70,7 @@ TEST_CASE("service::IdentityService::LoginWithNewDevice", "[vereign/service][.in CHECK(list->status() == "OK"); REQUIRE(list->code() == "200"); CHECK(list->data().size() > 0); - for (auto& passport : list->data()) { + for (const auto& passport : list->data()) { CHECK(passport.uuid().size() == 36); } } @@ -75,9 +80,13 @@ TEST_CASE("service::IdentityService::LoginWithPreviouslyAddedDevice", "[vereign/ auto host = test::RequireEnv("TEST_VEREIGN_API_HOST"); auto port = test::GetEnv("TEST_VEREIGN_API_PORT", "https"); - // prepare new device auto storage_path = core::TempFilePath("test_db_"); - auto old_device_ctx = test::ServiceContext{host, port, core::TempFilePath("test_db_")}; + auto rm_storage_path = core::RemoveFileGuard{storage_path}; + + // prepare new device + auto old_storage_path = core::TempFilePath("test_db_"); + auto rm_old_storage_path = core::RemoveFileGuard{old_storage_path}; + auto old_device_ctx = test::ServiceContext{host, port, old_storage_path}; auto old_device = test::Device{old_device_ctx}; old_device.Login(public_key); auto old_service_context = test::ServiceContext{host, port, storage_path}; @@ -115,7 +124,7 @@ TEST_CASE("service::IdentityService::LoginWithPreviouslyAddedDevice", "[vereign/ CHECK(list->status() == "OK"); REQUIRE(list->code() == "200"); CHECK(list->data().size() > 0); - for (auto& passport : list->data()) { + for (const auto& passport : list->data()) { CHECK(passport.uuid().size() == 36); } } diff --git a/cpp/tests/vereign/test/service_context.cc b/cpp/tests/vereign/test/service_context.cc index 7f326c9cf81259d2c4fa76f1da9f0c05ff88ae2b..0e76643d1d6434b9b622a2c19076398aa06c439b 100644 --- a/cpp/tests/vereign/test/service_context.cc +++ b/cpp/tests/vereign/test/service_context.cc @@ -50,8 +50,6 @@ void ServiceContext::Shutdown() { if (service_thread_.joinable()) { service_thread_.join(); } - - boost::filesystem::remove(storage_path_); } ServiceContext::~ServiceContext() {