Skip to content
Snippets Groups Projects
Verified Commit f650bd4e authored by Daniel Lyubomirov's avatar Daniel Lyubomirov Committed by Daniel Lyubomirov
Browse files

[17] crypto storage windows fixes

parent 16b915cc
No related branches found
No related tags found
1 merge request!97Crypto Storage and LoginWithNewDevice and LoginWithPreviouslyAddedDevice APIs
......@@ -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")
......
......@@ -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)
......
......@@ -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
......
#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
......
......@@ -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);
}
}
......@@ -50,8 +50,6 @@ void ServiceContext::Shutdown() {
if (service_thread_.joinable()) {
service_thread_.join();
}
boost::filesystem::remove(storage_path_);
}
ServiceContext::~ServiceContext() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment