Skip to content

Update seed dependencies #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ class SeedCppConan(ConanFile):
license = "MIT"
generators = "cmake_find_package"
settings = "os", "compiler", "build_type", "arch"
options = {"boost": ["1.67.0"], "OpenSSL": ["1.0.2n"], "gtest": ["1.8.1"]}
default_options = {"boost": "1.67.0", "OpenSSL":"1.0.2n", "gtest":"1.8.1"}
options = {"boost": ["1.67.0", "1.72.0", "1.75.0"], "openssl": ["1.1.1g", "1.1.1k"], "gtest": ["1.8.1", "1.10.0"]}
default_options = {"boost": "1.72.0", "openssl":"1.1.1k", "gtest":"1.10.0"}

def configure(self):
self.options["DbSQLiteAdapter"].boost = self.options.boost
self.options["BoostAsioWebServerAdapter"].boost = self.options.boost
self.options["BoostAsioWebServerAdapter"].OpenSSL = self.options.OpenSSL
self.options["JWTUtils"].OpenSSL = self.options.OpenSSL
self.options["RESTAPICore"].OpenSSL = self.options.OpenSSL
self.options["BoostAsioWebServerAdapter"].openssl = self.options.openssl
self.options["JWTUtils"].openssl = self.options.openssl
self.options["RESTAPICore"].openssl = self.options.openssl
self.options["JSONSettings"].boost = self.options.boost

self.options["DbAdapterTestUtilities"].gtest = self.options.gtest
Expand All @@ -28,21 +28,21 @@ def configure(self):
self.options["JSONSettingsTestUtilities"].gtest = self.options.gtest

def requirements(self):
self.requires("DbSQLiteAdapter/1.1.5@systelab/stable")
self.requires("RapidJSONAdapter/1.0.4@systelab/stable")
self.requires("BoostAsioWebServerAdapter/1.0.2@systelab/stable")
self.requires("JWTUtils/1.0.4@systelab/stable")
self.requires("RESTAPICore/1.0.3@systelab/stable")
self.requires("JSONSettings/1.0.2@systelab/stable")
self.requires("DbSQLiteAdapter/1.1.10@systelab/stable")
self.requires("RapidJSONAdapter/1.1.3@systelab/stable")
self.requires("BoostAsioWebServerAdapter/1.1.5@systelab/stable")
self.requires("JWTUtils/1.1.7@systelab/stable")
self.requires("RESTAPICore/1.1.7@systelab/stable")
self.requires("JSONSettings/1.3.8@systelab/stable")

def build_requirements(self):
self.build_requires("TestUtilitiesInterface/1.0.3@systelab/stable")
self.build_requires("DbAdapterTestUtilities/1.1.5@systelab/stable")
self.build_requires("JSONAdapterTestUtilities/1.0.4@systelab/stable")
self.build_requires("JWTUtilsTestUtilities/1.0.4@systelab/stable")
self.build_requires("JSONSettingsTestUtilities/1.0.2@systelab/stable")
self.build_requires("gtest/1.8.1@bincrafters/stable")

self.build_requires("TestUtilitiesInterface/1.0.7@systelab/stable")
self.build_requires("DbAdapterTestUtilities/1.1.12@systelab/stable")
self.build_requires("JSONAdapterTestUtilities/1.1.3@systelab/stable")
self.build_requires("JWTUtilsTestUtilities/1.1.7@systelab/stable")
self.build_requires("JSONSettingsTestUtilities/1.3.8@systelab/stable")
self.build_requires("gtest/1.10.0")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version of google test package should be gathered from the options considering that now there are multiple values (1.10.0 and 1.8.1).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the options, it is contemplated to use version 1.8.1 or 1.10.0. Version 1.10.0 is required since the rest of the dependencies use it

def imports(self):
self.copy("*.dll", dst=("bin/SeedCpp/%s" % self.settings.build_type), src="bin")
self.copy("*.dll", dst=("bin/SeedCppCoreUnitTest/%s" % self.settings.build_type), src="bin")
Expand Down
2 changes: 1 addition & 1 deletion src/SeedCpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set(SEED_CPP_PROJECT SeedCpp)
file(GLOB_RECURSE SEED_CPP_PROJECT_SRC "*.cpp")
file(GLOB_RECURSE SEED_CPP_PROJECT_HDR "*.h")
add_executable(${SEED_CPP_PROJECT} ${SEED_CPP_PROJECT_SRC} ${SEED_CPP_PROJECT_HDR})
target_link_libraries(${SEED_CPP_PROJECT} SeedCppCore boost::boost)
target_link_libraries(${SEED_CPP_PROJECT} SeedCppCore Boost::boost)
set_target_properties(${SEED_CPP_PROJECT} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${SEED_CPP_PROJECT})

#Configure source groups
Expand Down
2 changes: 2 additions & 0 deletions src/SeedCppCore/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.2)

# Find external dependencies
find_package(Boost)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New packages shouldn't be required because they are transitive dependencies of existing packages. I think previous version of this file should be kept.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree not to add the new packages, but the conversion from boost to Boost is necessary

find_package(DbSQLiteAdapter)
find_package(RapidJSONAdapter)
find_package(BoostAsioWebServerAdapter)
Expand All @@ -17,6 +18,7 @@ file(GLOB_RECURSE SEED_CPP_CORE_SRC "*.cpp")
file(GLOB_RECURSE SEED_CPP_CORE_HDR "*.h")
add_library(${SEED_CPP_CORE} STATIC ${SEED_CPP_CORE_SRC} ${SEED_CPP_CORE_HDR})
target_link_libraries(${SEED_CPP_CORE}
Boost::boost
DbSQLiteAdapter::DbSQLiteAdapter
RapidJSONAdapter::RapidJSONAdapter
BoostAsioWebServerAdapter::BoostAsioWebServerAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "RESTAPICore/RouteAccess/TokenExpirationAccessValidator.h"
#include "RESTAPICore/RouteAccess/UserRoleRouteAccessValidator.h"

#include "TimeAdapter/TimeAdapter.h"


namespace seed_cpp { namespace rest {

Expand All @@ -23,9 +25,9 @@ namespace seed_cpp { namespace rest {
std::unique_ptr<IRouteAccessValidator> RouteAccessValidatorsFactory::buildTokenExpirationRouteAccessValidator() const
{
long expirationSeconds = 600; // 10 minutes
auto& epochTimeService = m_context.getServicesMgr()->getSystemServicesMgr().getEpochTimeService();
systelab::time::TimeAdapter timeAdapter;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TimeAdapter shouldn't be declared as a local variable because it is injected to the service being built, but it will be destroyed once exiting the factory method. Thus, this will cause a crash when accessing to an object that has been destroyed from the service.

Thus, I would suggest defining the TimeAdapter as part of the context, as we do with other adapters (i.e db adapter). Moreover, it should be injected on constructor of the Context object and as an interface (ITimeAdapter), so we allow using a mock version of it (we are not assuming to have always the real implementation).


return std::make_unique<TokenExpirationAccessValidator>(expirationSeconds, epochTimeService);
return std::make_unique<TokenExpirationAccessValidator>(timeAdapter, expirationSeconds);
};

std::unique_ptr<IRouteAccessValidator> RouteAccessValidatorsFactory::buildAdminRoleRouteAccessValidator() const
Expand Down
6 changes: 5 additions & 1 deletion src/SeedCppCore/Services/System/SystemServicesFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "JSONSettings/SettingsService.h"
#include "RESTAPICore/RouteAccess/EpochTimeService.h"

#include "TimeAdapter/TimeAdapter.h"


namespace seed_cpp { namespace service {

Expand All @@ -31,7 +33,9 @@ namespace seed_cpp { namespace service {

std::unique_ptr<systelab::rest_api_core::IEpochTimeService> SystemServicesFactory::buildEpochTimeService() const
{
return std::make_unique<systelab::rest_api_core::EpochTimeService>();
systelab::time::TimeAdapter TimeAdapter;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the change on REST API core to not require an epoch service to build a TokenExpirationAccessValidator, I think that this method is not used anywhere else. If that's the case, I would get rid of this factory method.


return std::make_unique<systelab::rest_api_core::EpochTimeService>(TimeAdapter);
}

std::unique_ptr<IUUIDGeneratorService> SystemServicesFactory::buildUUIDGeneratorService() const
Expand Down
2 changes: 1 addition & 1 deletion test/DatabaseIntegrationTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ file(GLOB_RECURSE DATABASE_INTEGRATION_TEST_PROJECT_SRC "*.cpp")
file(GLOB_RECURSE DATABASE_INTEGRATION_TEST_PROJECT_HDR "*.h")
file(GLOB_RECURSE DATABASE_INTEGRATION_TEST_PROJECT_SQL "*.sql")
add_executable(${DATABASE_INTEGRATION_TEST_PROJECT} ${DATABASE_INTEGRATION_TEST_PROJECT_SRC} ${DATABASE_INTEGRATION_TEST_PROJECT_HDR} ${DATABASE_INTEGRATION_TEST_PROJECT_SQL})
target_link_libraries(${DATABASE_INTEGRATION_TEST_PROJECT} SeedCppCore SeedCppCoreTestUtilities gtest::gtest)
target_link_libraries(${DATABASE_INTEGRATION_TEST_PROJECT} SeedCppCore SeedCppCoreTestUtilities GTest::gtest)
set_target_properties(${DATABASE_INTEGRATION_TEST_PROJECT} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${DATABASE_INTEGRATION_TEST_PROJECT})

# Ignored missing PDBs link warning on Visual Studio
Expand Down
2 changes: 1 addition & 1 deletion test/SeedCppCoreTestUtilities/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set(SEED_CPP_CORE_TEST_UTILITIES SeedCppCoreTestUtilities)
file(GLOB_RECURSE SEED_CPP_CORE_TEST_UTILITIES_SRC "*.cpp")
file(GLOB_RECURSE SEED_CPP_CORE_TEST_UTILITIES_HDR "*.h")
add_library(${SEED_CPP_CORE_TEST_UTILITIES} STATIC ${SEED_CPP_CORE_TEST_UTILITIES_SRC} ${SEED_CPP_CORE_TEST_UTILITIES_HDR})
target_link_libraries(${SEED_CPP_CORE_TEST_UTILITIES} SeedCppCore gtest::gtest TestUtilitiesInterface::TestUtilitiesInterface)
target_link_libraries(${SEED_CPP_CORE_TEST_UTILITIES} SeedCppCore GTest::gtest TestUtilitiesInterface::TestUtilitiesInterface)

#Configure source groups
foreach(FILE ${SEED_CPP_CORE_TEST_UTILITIES_SRC} ${SEED_CPP_CORE_TEST_UTILITIES_HDR})
Expand Down
2 changes: 1 addition & 1 deletion test/SeedCppCoreUnitTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ file(GLOB_RECURSE SEED_CPP_CORE_UNIT_TEST_PROJECT_SRC "*.cpp")
file(GLOB_RECURSE SEED_CPP_CORE_UNIT_TEST_PROJECT_HDR "*.h")
add_executable(${SEED_CPP_CORE_UNIT_TEST_PROJECT} ${SEED_CPP_CORE_UNIT_TEST_PROJECT_SRC} ${SEED_CPP_CORE_UNIT_TEST_PROJECT_HDR})
target_link_libraries(${SEED_CPP_CORE_UNIT_TEST_PROJECT} SeedCppCore SeedCppCoreTestUtilities
gtest::gtest
GTest::gtest
DbAdapterTestUtilities::DbAdapterTestUtilities
JSONAdapterTestUtilities::JSONAdapterTestUtilities
JWTUtilsTestUtilities::JWTUtilsTestUtilities
Expand Down