From 818c7f6e103afa49ab2bb77b8dac226b5f411906 Mon Sep 17 00:00:00 2001 From: Bartosz Wieczorek Date: Sun, 6 Jan 2019 21:58:56 +0100 Subject: [PATCH] Resolve "Prepare chaiscript bindings for current code" --- src/libs/chaiscript_bindings/CMakeLists.txt | 5 +- .../chaiscript_bindings/src/chai_bindings.cpp | 53 ++++++++++++------- .../db/postgresql_connector/CMakeLists.txt | 27 +++++++++- .../include/eedb/pg/AuthIdentity.hpp | 4 +- .../include/eedb/pg/Category.hpp | 2 +- .../include/eedb/pg/Item.hpp | 2 +- .../include/eedb/pg/model/CMakeLists.txt | 18 +++++++ .../postgresql_connector/mock/CMakeLists.txt | 23 ++++++++ .../postgresql_connector/src/AuthIdentity.cpp | 4 +- .../db/postgresql_connector/src/Category.cpp | 2 +- src/libs/db/postgresql_connector/src/Item.cpp | 4 +- .../src/ItemsRepository.cpp | 2 +- .../postgresql_connector/test/DbTestBase.hpp | 4 +- src/libs/eedb/CMakeLists.txt | 25 +++++++++ src/libs/eedb/include/eedb/AuthIdentities.hpp | 9 ++++ .../eedb/include/eedb/AuthIdentitiesConst.hpp | 4 ++ src/libs/eedb/include/eedb/AuthIdentity.hpp | 17 +++--- .../eedb/include/eedb/AuthIdentityConst.hpp | 24 +++++---- src/libs/eedb/include/eedb/Category.hpp | 13 ++--- src/libs/eedb/include/eedb/Item.hpp | 26 ++++++--- src/libs/eedb/include/eedb/User.hpp | 18 ++++++- src/libs/eedb/mock/CMakeLists.txt | 22 ++++++++ .../mock/include/eedb/mock/CategoryMock.hpp | 2 +- src/libs/webapp/src/DefaultAuthPage.cpp | 2 +- 24 files changed, 241 insertions(+), 71 deletions(-) create mode 100644 src/libs/db/postgresql_connector/include/eedb/pg/model/CMakeLists.txt diff --git a/src/libs/chaiscript_bindings/CMakeLists.txt b/src/libs/chaiscript_bindings/CMakeLists.txt index 68d12f6..034b77a 100644 --- a/src/libs/chaiscript_bindings/CMakeLists.txt +++ b/src/libs/chaiscript_bindings/CMakeLists.txt @@ -9,7 +9,10 @@ set(${PKG_CONFIG_USE_CMAKE_PREFIX_PATH} ON) pkg_check_modules(chaiscript REQUIRED) # create library -add_library(${LIB} src/chai_bindings.cpp) +add_library(${LIB} + src/chai_bindings.cpp + include/eedb/chai/chai_bindings.hpp +) # link all target_include_directories(${LIB} diff --git a/src/libs/chaiscript_bindings/src/chai_bindings.cpp b/src/libs/chaiscript_bindings/src/chai_bindings.cpp index cb05846..f4124f1 100644 --- a/src/libs/chaiscript_bindings/src/chai_bindings.cpp +++ b/src/libs/chaiscript_bindings/src/chai_bindings.cpp @@ -2,19 +2,20 @@ #include #include - #include -#include - #include #include #include #include +#include +#include +#include +#include +#include #include #include - -#include +#include void eedb::script::chai_bootstrap(chaiscript::Module & module) { using namespace chaiscript; @@ -25,25 +26,35 @@ void eedb::script::chai_bootstrap(chaiscript::Module & module) { * CATEGORY *******************/ - module.add(user_type< CategoriesRepository >(), "CategoriesRepository"); - module.add(fun(&CategoriesRepository::create), "create"); - module.add(fun(&CategoriesRepository::root), "root"); + chaiscript::utility::add_class< CategoriesRepository >(module, // + "CategoriesRepository", + {}, // + { + {fun(&CategoriesRepository::create), "create"}, // + {fun(&CategoriesRepository::root), "root"} // + }); - module.add(user_type< exceptions::CategoryAddException >(), "CategoryAddException"); - // module.add(constructor< exceptions::CategoryAddException(std::unique_ptr< Category >) >(), "CategoryAddException"); - module.add(fun(&exceptions::CategoryAddException::what), "what"); + chaiscript::utility::add_class< exceptions::CategoryAddException >(module, + "CategoryAddException", + { + {constructor< exceptions::CategoryAddException(std::unique_ptr< Category > &&, std::string) >()} // + }, + { + {fun(&exceptions::CategoryAddException::get), "get"}, // + {fun(&exceptions::CategoryAddException::what), "what"} // + }); chaiscript::utility::add_class< Category >(module, "Category", {}, - {// + { {fun(&Category::addChild), "addChild"}, {fun(&Category::attachTo), "attachTo"}, {fun(&Category::children), "children"}, {fun(&Category::detach), "detach"}, {fun(&Category::displayName), "displayName"}, - {fun(&Category::parent), "parent"}}); - + {fun(&Category::parent), "parent"} // + }); module.add(user_type< CategoriesChildren >(), "CategoriesChildren"); bootstrap::standard_library::input_range_type< CategoriesChildren >("CategoriesChildren", module); @@ -64,8 +75,9 @@ void eedb::script::chai_bootstrap(chaiscript::Module & module) { chaiscript::utility::add_class< AuthIdentities >(module, "AuthIdentities", {}, - {// - {fun(&AuthIdentities::removeProvider), "removeProvider"}}); + { + {fun(&AuthIdentities::removeProvider), "removeProvider"} // + }); /******************** * FACTORY @@ -74,8 +86,9 @@ void eedb::script::chai_bootstrap(chaiscript::Module & module) { chaiscript::utility::add_class< Factory >(module, "Factory", {}, - {// - {fun(&Factory::categoriesRepository), "categoriesRepository"}}); - - // module.add(fun(&Factory::itemsRepository), "itemsRepository"); + { + // + {fun(&Factory::categoriesRepository), "categoriesRepository"}, + {fun(&Factory::itemsRepository), "itemsRepository"} // + }); } diff --git a/src/libs/db/postgresql_connector/CMakeLists.txt b/src/libs/db/postgresql_connector/CMakeLists.txt index 2cc97d0..e03201e 100644 --- a/src/libs/db/postgresql_connector/CMakeLists.txt +++ b/src/libs/db/postgresql_connector/CMakeLists.txt @@ -1,6 +1,27 @@ set(LIB postgres_connector) -file(GLOB ${LIB}_SOURCE src/*) +set(HEADERS + ./include/eedb/pg/AuthIdentity.hpp + ./include/eedb/pg/Parameter.hpp + ./include/eedb/pg/Users.hpp + ./include/eedb/pg/config.hpp + ./include/eedb/pg/User.hpp + ./include/eedb/pg/AuthToken.hpp + ./include/eedb/pg/Item.hpp + ./include/eedb/pg/ItemsRepository.hpp + ./include/eedb/pg/Session.hpp + ./include/eedb/pg/Items.hpp + ./include/eedb/pg/Factory.hpp + ./include/eedb/pg/connection.hpp + ./include/eedb/pg/RawSql.hpp + ./include/eedb/pg/Stats.hpp + ./include/eedb/pg/Category.hpp + ./include/eedb/pg/CategoriesRepository.hpp + ./include/eedb/pg/utils.hpp + ./include/eedb/pg/ParametersRepository.hpp +) + +file(GLOB SOURCES src/*) # find packages find_package(Sqlpp11 REQUIRED) @@ -8,7 +29,8 @@ find_package(Sqlpp-connector-postgresql REQUIRED) # create library add_library(${LIB} STATIC - ${${LIB}_SOURCE} + ${SOURCES} + ${HEADERS} ) # link all @@ -53,5 +75,6 @@ set_target_properties(${LIB} ) cotire(${LIB}) +add_subdirectory(include/eedb/pg/model) add_subdirectory(mock) add_subdirectory(test) diff --git a/src/libs/db/postgresql_connector/include/eedb/pg/AuthIdentity.hpp b/src/libs/db/postgresql_connector/include/eedb/pg/AuthIdentity.hpp index 86e50af..f4dd92f 100644 --- a/src/libs/db/postgresql_connector/include/eedb/pg/AuthIdentity.hpp +++ b/src/libs/db/postgresql_connector/include/eedb/pg/AuthIdentity.hpp @@ -17,9 +17,9 @@ class AuthIdentityImpl final : public AuthIdentity { AuthIdentityImpl(Connection & db, std::string identity, std::string provider); // PgAuthIdentity(Connection & db, nlohmann::json data); - string_view identity() const override; + std::string_view identity() const override; - string_view provider() const override; + std::string_view provider() const override; private: struct PgAuthIdentityPriv; diff --git a/src/libs/db/postgresql_connector/include/eedb/pg/Category.hpp b/src/libs/db/postgresql_connector/include/eedb/pg/Category.hpp index 4dffce4..9758b0c 100644 --- a/src/libs/db/postgresql_connector/include/eedb/pg/Category.hpp +++ b/src/libs/db/postgresql_connector/include/eedb/pg/Category.hpp @@ -48,7 +48,7 @@ class CategoryImpl : public impl::PgCategory { // creates category from private data CategoryImpl(spimpl::unique_impl_ptr< CategoryImplPrivate > && priv); - string_view displayName() const override; + std::string_view displayName() const override; Category * parent() const override; diff --git a/src/libs/db/postgresql_connector/include/eedb/pg/Item.hpp b/src/libs/db/postgresql_connector/include/eedb/pg/Item.hpp index 758155c..125b9da 100644 --- a/src/libs/db/postgresql_connector/include/eedb/pg/Item.hpp +++ b/src/libs/db/postgresql_connector/include/eedb/pg/Item.hpp @@ -19,7 +19,7 @@ class ItemImpl : public Item { CategoriesIt attachedToCategories() const override; - bool attach(const Category * category) override; + void attach(const Category * category) override; private: struct ItemPriv; diff --git a/src/libs/db/postgresql_connector/include/eedb/pg/model/CMakeLists.txt b/src/libs/db/postgresql_connector/include/eedb/pg/model/CMakeLists.txt new file mode 100644 index 0000000..a0903cb --- /dev/null +++ b/src/libs/db/postgresql_connector/include/eedb/pg/model/CMakeLists.txt @@ -0,0 +1,18 @@ +set(HEADERS + ./unit.h + ./auth_info.h + ./parameter.h + ./item.h + ./system_info.h + ./stat.h + ./user_audit.h + ./category_items.h + ./file.h + ./category.h + ./auth_token.h + ./group.h + ./all.hpp + ./auth_identity.h +) + +add_custom_target(postgresql_model-ide SOURCES ${HEADERS}) diff --git a/src/libs/db/postgresql_connector/mock/CMakeLists.txt b/src/libs/db/postgresql_connector/mock/CMakeLists.txt index 02033ba..c5ebdff 100644 --- a/src/libs/db/postgresql_connector/mock/CMakeLists.txt +++ b/src/libs/db/postgresql_connector/mock/CMakeLists.txt @@ -1,8 +1,31 @@ set(LIB postgres_connector-mock) +set(HEADERS + ./include/eedb/mock/db/pg/ParameterMock.hpp + ./include/eedb/mock/db/pg/SignalBaseMock.hpp + ./include/eedb/mock/db/pg/AuthIdentitiesMock.hpp + ./include/eedb/mock/db/pg/ItemsMock.hpp + ./include/eedb/mock/db/pg/ItemQueryFiltersMock.hpp + ./include/eedb/mock/db/pg/UserMock.hpp + ./include/eedb/mock/db/pg/SessionMock.hpp + ./include/eedb/mock/db/pg/AuthTokenMock.hpp + ./include/eedb/mock/db/pg/ParametersRepositoryMock.hpp + ./include/eedb/mock/db/pg/UserNameMock.hpp + ./include/eedb/mock/db/pg/CategoryMock.hpp + ./include/eedb/mock/db/pg/CategoriesMock.hpp + ./include/eedb/mock/db/pg/ItemMock.hpp + ./include/eedb/mock/db/pg/AuthInfoMock.hpp + ./include/eedb/mock/db/pg/AuthTokensMock.hpp + ./include/eedb/mock/db/pg/CategoriesRepositoryMock.hpp + ./include/eedb/mock/db/pg/UsersMock.hpp +) + # create library add_library(${LIB} INTERFACE) +# make ide happy +add_custom_target(${LIB}_ide SOURCES ${HEADERS}) + # link all target_include_directories(${LIB} INTERFACE include diff --git a/src/libs/db/postgresql_connector/src/AuthIdentity.cpp b/src/libs/db/postgresql_connector/src/AuthIdentity.cpp index 22d3d24..1c2459b 100644 --- a/src/libs/db/postgresql_connector/src/AuthIdentity.cpp +++ b/src/libs/db/postgresql_connector/src/AuthIdentity.cpp @@ -21,11 +21,11 @@ struct AuthIdentityImpl::PgAuthIdentityPriv { AuthIdentityImpl::AuthIdentityImpl(Connection & db, std::string identity, std::string provider) : _priv{spimpl::make_unique_impl< PgAuthIdentityPriv >(db, identity, provider)} {} -AuthIdentity::string_view AuthIdentityImpl::identity() const { +std::string_view AuthIdentityImpl::identity() const { return _priv->identity; } -AuthIdentity::string_view AuthIdentityImpl::provider() const { +std::string_view AuthIdentityImpl::provider() const { return _priv->provider; } diff --git a/src/libs/db/postgresql_connector/src/Category.cpp b/src/libs/db/postgresql_connector/src/Category.cpp index 34aa249..e0b204d 100644 --- a/src/libs/db/postgresql_connector/src/Category.cpp +++ b/src/libs/db/postgresql_connector/src/Category.cpp @@ -209,7 +209,7 @@ CategoryImpl::CategoryImpl(spimpl::unique_impl_ptr< CategoryImplPrivate > && pri _priv->_self = this; } -Category::string_view CategoryImpl::displayName() const { +std::string_view CategoryImpl::displayName() const { return _priv->displayName(); } diff --git a/src/libs/db/postgresql_connector/src/Item.cpp b/src/libs/db/postgresql_connector/src/Item.cpp index 5bdc961..ceaaac8 100644 --- a/src/libs/db/postgresql_connector/src/Item.cpp +++ b/src/libs/db/postgresql_connector/src/Item.cpp @@ -47,8 +47,8 @@ Item::CategoriesIt ItemImpl::attachedToCategories() const { return {}; } -bool ItemImpl::attach(const Category * category) { - return _priv->attachToCategory(category); +void ItemImpl::attach(const Category * category) { + _priv->attachToCategory(category); } } // namespace eedb::pg diff --git a/src/libs/db/postgresql_connector/src/ItemsRepository.cpp b/src/libs/db/postgresql_connector/src/ItemsRepository.cpp index a4f4799..69dd047 100644 --- a/src/libs/db/postgresql_connector/src/ItemsRepository.cpp +++ b/src/libs/db/postgresql_connector/src/ItemsRepository.cpp @@ -18,7 +18,7 @@ #include -SQLPP_ALIAS_PROVIDER(_match); +SQLPP_ALIAS_PROVIDER(_match) namespace eedb::pg { struct ItemsRepositoryImpl::temsRepositoryImplPriv { diff --git a/src/libs/db/postgresql_connector/test/DbTestBase.hpp b/src/libs/db/postgresql_connector/test/DbTestBase.hpp index 90f69c8..3ba544a 100644 --- a/src/libs/db/postgresql_connector/test/DbTestBase.hpp +++ b/src/libs/db/postgresql_connector/test/DbTestBase.hpp @@ -55,7 +55,7 @@ class DockerRunner { "POSTGRES_PASSWORD=postgres", "-e", "POSTGRES_DB=eedb", - "postgres:9.6-alpine"); + "postgres:latest"); } } @@ -117,7 +117,7 @@ class DbTestBase : public testing::Test { static void SetUpTestCase() { _test_db = std::make_unique< PgTestDatabasePrepare >(); _test_db->db().execute("SET synchronous_commit=off;"); - eedb::pg::exec_file(_test_db->db(), "/home/wieczbar/src/eedb/sql/schema.sql"); + eedb::pg::exec_file(_test_db->db(), "/home/bwieczor/src/eedb/sql/schema.sql"); } static void TearDownTestCase() { diff --git a/src/libs/eedb/CMakeLists.txt b/src/libs/eedb/CMakeLists.txt index 136bcef..956e8be 100644 --- a/src/libs/eedb/CMakeLists.txt +++ b/src/libs/eedb/CMakeLists.txt @@ -1,11 +1,36 @@ set(LIB eedb_api) +set(HEADERS + ./include/eedb/AuthIdentity.hpp + ./include/eedb/Parameter.hpp + ./include/eedb/AuthIdentitiesConst.hpp + ./include/eedb/AuthInfoConst.hpp + ./include/eedb/Users.hpp + ./include/eedb/User.hpp + ./include/eedb/AuthToken.hpp + ./include/eedb/Password.hpp + ./include/eedb/AuthIdentities.hpp + ./include/eedb/Item.hpp + ./include/eedb/Session.hpp + ./include/eedb/AuthInfo.hpp + ./include/eedb/Factory.hpp + ./include/eedb/Value.hpp + ./include/eedb/Unit.hpp + ./include/eedb/Category.hpp + ./include/eedb/AuthTokens.hpp + ./include/eedb/AuthIdentityConst.hpp + ./include/eedb/Email.hpp +) + # find packages find_package(nlohmann_json CONFIG REQUIRED) # create library add_library(${LIB} INTERFACE) +# make ide happy +add_custom_target(${LIB}_ide SOURCES ${HEADERS}) + # link all target_include_directories(${LIB} INTERFACE include diff --git a/src/libs/eedb/include/eedb/AuthIdentities.hpp b/src/libs/eedb/include/eedb/AuthIdentities.hpp index bfc2231..96f83aa 100644 --- a/src/libs/eedb/include/eedb/AuthIdentities.hpp +++ b/src/libs/eedb/include/eedb/AuthIdentities.hpp @@ -16,8 +16,17 @@ class AuthIdentities { */ virtual AuthIdentity * addIdentity(std::unique_ptr< AuthIdentity > identity) = 0; + /** + * @brief byProvider + * @param provider + * @return + */ virtual AuthIdentity * byProvider(std::string_view provider) const = 0; + /** + * @brief removeProvider + * @param provider + */ virtual void removeProvider(std::string_view provider) = 0; }; diff --git a/src/libs/eedb/include/eedb/AuthIdentitiesConst.hpp b/src/libs/eedb/include/eedb/AuthIdentitiesConst.hpp index 871d505..0c756f8 100644 --- a/src/libs/eedb/include/eedb/AuthIdentitiesConst.hpp +++ b/src/libs/eedb/include/eedb/AuthIdentitiesConst.hpp @@ -6,6 +6,10 @@ namespace eebd { class AuthIdentity; +/** + * @brief The AuthIdentitiesConst class + * Immutable implementation of identities + */ class AuthIdentitiesConst final : public AuthIdentities { public: AuthIdentitiesConst(std::initializer_list< AuthIdentityConst > identities) { diff --git a/src/libs/eedb/include/eedb/AuthIdentity.hpp b/src/libs/eedb/include/eedb/AuthIdentity.hpp index 968d5af..9e77d14 100644 --- a/src/libs/eedb/include/eedb/AuthIdentity.hpp +++ b/src/libs/eedb/include/eedb/AuthIdentity.hpp @@ -6,15 +6,20 @@ namespace eedb { class AuthIdentity { - protected: - using string_view = std::string_view; - using string = std::string; - public: virtual ~AuthIdentity() = default; - virtual string_view identity() const = 0; - virtual string_view provider() const = 0; + /** + * @brief identity + * @return string representation of identity (e.g. einstein) + */ + virtual std::string_view identity() const = 0; + + /** + * @brief provider + * @return a string key of provider for identity (e.g. facebook" + */ + virtual std::string_view provider() const = 0; private: }; diff --git a/src/libs/eedb/include/eedb/AuthIdentityConst.hpp b/src/libs/eedb/include/eedb/AuthIdentityConst.hpp index bc44c72..be210c1 100644 --- a/src/libs/eedb/include/eedb/AuthIdentityConst.hpp +++ b/src/libs/eedb/include/eedb/AuthIdentityConst.hpp @@ -3,22 +3,24 @@ #include namespace eedb { +/** + * @brief The AuthIdentityConst class + * This is an immutable version of AuthIdentity class + */ class AuthIdentityConst final : public AuthIdentity { - protected: - using string_view = std::string_view; - using string = std::string; + public: + AuthIdentityConst(std::string identity, std::string provider) : _identity{std::move(identity)}, _provider{std::move(provider)} {} -public: - AuthIdentityConst(string identity, string provider) : _identity{std::move(identity)}, _provider{std::move(provider)} {} - virtual string_view identity() const override { + virtual std::string_view identity() const override { return _identity; } - virtual string_view provider() const override { + + virtual std::string_view provider() const override { return _provider; } -private: - string _identity; - string _provider; + private: + std::string _identity; + std::string _provider; }; -} +} // namespace eedb diff --git a/src/libs/eedb/include/eedb/Category.hpp b/src/libs/eedb/include/eedb/Category.hpp index 5d1e5d7..aa1f0bc 100644 --- a/src/libs/eedb/include/eedb/Category.hpp +++ b/src/libs/eedb/include/eedb/Category.hpp @@ -8,7 +8,6 @@ #include namespace eedb { - class Category; class CategoriesRepository { @@ -41,10 +40,10 @@ namespace exceptions { class CategoryAddException : public std::logic_error { // exception interface public: - CategoryAddException(std::unique_ptr< Category > category, std::string reason) + CategoryAddException(std::unique_ptr< Category > && category, std::string reason) : std::logic_error(std::move(reason)), _badCategory{std::move(category)} {} - std::unique_ptr< Category > get() { + auto get() { return std::move(_badCategory); } @@ -64,11 +63,9 @@ class CategoriesChildren : public details::CategoryPtrIteratorRange { /** * @brief The Category class + * Categories are organized in a tree like hierarchy where each category has own id and parent */ class Category { - public: - using string_view = std::string_view; - public: virtual ~Category() = default; @@ -76,7 +73,7 @@ class Category { * @brief displayName * @return category display name */ - virtual string_view displayName() const = 0; + virtual std::string_view displayName() const = 0; /** * @brief parent @@ -86,7 +83,7 @@ class Category { /** * @brief addChild - * @param category + * @param category that should be added to this category * @throws CategoryAddException() * @return pointer to newely added category */ diff --git a/src/libs/eedb/include/eedb/Item.hpp b/src/libs/eedb/include/eedb/Item.hpp index 042ff97..b6dfda4 100644 --- a/src/libs/eedb/include/eedb/Item.hpp +++ b/src/libs/eedb/include/eedb/Item.hpp @@ -49,6 +49,12 @@ class ItemQueryFilters { }; namespace item { + namespace exception{ + ///TODO FIX + class ItemAlreadyInCategory : public std::exception{ + + }; + } using Iterator = IteratorTypeErasure::any_iterator< std::unique_ptr< Item >, std::forward_iterator_tag, std::unique_ptr< Item > >; using IteratorRange = boost::iterator_range< Iterator >; @@ -56,11 +62,11 @@ namespace item { public: Identyfier(std::string symbol, std::string producer_symbol = {}) : _sym{std::move(symbol)}, _prod{std::move(producer_symbol)} {} - std::string_view symbol() const { + std::string_view symbol() const noexcept { return _sym; } - std::string_view producerSymbol() const { + std::string_view producerSymbol() const noexcept { return _prod.empty() ? _sym : _prod; } @@ -69,6 +75,10 @@ namespace item { std::string _prod; }; + /** + * @brief The Attributes class + * Attributes of item saved in database e.g. + */ class Attributes { public: using Mass = boost::units::quantity< boost::units::si::mass >; @@ -174,27 +184,27 @@ class Item { /** * @brief displayName - * @return + * @return name of item */ virtual std::string_view displayName() const = 0; /** * @brief assignedUnits - * @return + * @return values stored in this item */ virtual Values values() const = 0; /** * @brief attachedToCategories - * @return + * @return return list of categories that this item applies to */ virtual CategoriesIt attachedToCategories() const = 0; /** - * @brief attach + * @brief attach attach to given category * @param category - * @return + * @throw */ - virtual bool attach(const Category * category) = 0; + virtual void attach(const Category * category) noexcept(false)= 0; }; } // namespace eedb diff --git a/src/libs/eedb/include/eedb/User.hpp b/src/libs/eedb/include/eedb/User.hpp index bc6a408..2ded455 100644 --- a/src/libs/eedb/include/eedb/User.hpp +++ b/src/libs/eedb/include/eedb/User.hpp @@ -16,13 +16,29 @@ class AuthIdentity; class User { public: virtual ~User() = default; - + /** + * @brief config + * @returnvalid user config object + */ virtual const UserConfig & config() const = 0; + /** + * user auth token + * authorization tokens + */ virtual AuthTokens & authTokens() const = 0; + /** + * @brief authIdentities + * @return user identities + */ virtual AuthIdentities & authIdentities() const = 0; + /** + * @brief authInfo + * @return auth info + */ virtual AuthInfo & authInfo() const = 0; }; + } // namespace eedb diff --git a/src/libs/eedb/mock/CMakeLists.txt b/src/libs/eedb/mock/CMakeLists.txt index f827f75..34d0552 100644 --- a/src/libs/eedb/mock/CMakeLists.txt +++ b/src/libs/eedb/mock/CMakeLists.txt @@ -1,8 +1,30 @@ set(LIB eedb_api-mock) +set(HEADERS + ./include/eedb/mock/db/ParameterMock.hpp + ./include/eedb/mock/db/SignalBaseMock.hpp + ./include/eedb/mock/db/AuthIdentitiesMock.hpp + ./include/eedb/mock/db/ItemsMock.hpp + ./include/eedb/mock/db/ItemQueryFiltersMock.hpp + ./include/eedb/mock/db/UserMock.hpp + ./include/eedb/mock/db/SessionMock.hpp + ./include/eedb/mock/db/AuthTokenMock.hpp + ./include/eedb/mock/db/ParametersRepositoryMock.hpp + ./include/eedb/mock/db/UserNameMock.hpp + ./include/eedb/mock/db/CategoryMock.hpp + ./include/eedb/mock/db/CategoriesMock.hpp + ./include/eedb/mock/db/ItemMock.hpp + ./include/eedb/mock/db/AuthInfoMock.hpp + ./include/eedb/mock/db/AuthTokensMock.hpp + ./include/eedb/mock/db/UsersMock.hpp +) + # create library add_library(${LIB} INTERFACE) +# make ide happy +add_custom_target(${LIB}_ide SOURCES ${HEADERS}) + # link all target_include_directories(${LIB} INTERFACE include diff --git a/src/libs/webapp/mock/include/eedb/mock/CategoryMock.hpp b/src/libs/webapp/mock/include/eedb/mock/CategoryMock.hpp index ae49473..fb655f8 100644 --- a/src/libs/webapp/mock/include/eedb/mock/CategoryMock.hpp +++ b/src/libs/webapp/mock/include/eedb/mock/CategoryMock.hpp @@ -9,7 +9,7 @@ class CategoryMock : public Category { public: // Category interface public: - MOCK_CONST_METHOD0(displayName, string_view()); + MOCK_CONST_METHOD0(displayName, std::string_view()); MOCK_CONST_METHOD0(parent, Category *()); MOCK_METHOD1(doAddChild, Category *( Category * ) ); Category * addChild(std::unique_ptr< Category > && c) { diff --git a/src/libs/webapp/src/DefaultAuthPage.cpp b/src/libs/webapp/src/DefaultAuthPage.cpp index fefd497..5e15cea 100644 --- a/src/libs/webapp/src/DefaultAuthPage.cpp +++ b/src/libs/webapp/src/DefaultAuthPage.cpp @@ -15,7 +15,6 @@ namespace eedb { struct DefaultAuthPage::DefaultAuthPagePriv { - auto dumpEnvironment() const { const auto & env = Wt::WApplication::instance()->environment(); auto getEnvironment = [](const Wt::WEnvironment & env) { @@ -28,6 +27,7 @@ struct DefaultAuthPage::DefaultAuthPagePriv { case Wt::HtmlContentType::HTML5: return "HTML5"; } + return "Unknown"; }; auto getCookies = [](const Wt::WEnvironment & env) {