diff --git a/ddspipe_core/include/ddspipe_core/configuration/CommandlineArgs.hpp b/ddspipe_core/include/ddspipe_core/configuration/CommandlineArgs.hpp index 721e6c3b..f9e12bfd 100644 --- a/ddspipe_core/include/ddspipe_core/configuration/CommandlineArgs.hpp +++ b/ddspipe_core/include/ddspipe_core/configuration/CommandlineArgs.hpp @@ -15,6 +15,7 @@ #pragma once #include +#include #include #include #include diff --git a/ddspipe_core/src/cpp/configuration/CommandlineArgs.cpp b/ddspipe_core/src/cpp/configuration/CommandlineArgs.cpp index c936f38f..2f9bb186 100644 --- a/ddspipe_core/src/cpp/configuration/CommandlineArgs.cpp +++ b/ddspipe_core/src/cpp/configuration/CommandlineArgs.cpp @@ -28,9 +28,9 @@ namespace core { CommandlineArgs::CommandlineArgs() { - log_filter[utils::VerbosityKind::Info].set_value("DDSPIPE", utils::FuzzyLevelValues::fuzzy_level_default); - log_filter[utils::VerbosityKind::Warning].set_value("DDSPIPE", utils::FuzzyLevelValues::fuzzy_level_default); - log_filter[utils::VerbosityKind::Error].set_value("", utils::FuzzyLevelValues::fuzzy_level_default); + log_filter.info.set_value("DDSPIPE", utils::FuzzyLevelValues::fuzzy_level_default); + log_filter.warning.set_value("DDSPIPE", utils::FuzzyLevelValues::fuzzy_level_default); + log_filter.error.set_value("", utils::FuzzyLevelValues::fuzzy_level_default); } bool CommandlineArgs::is_valid( diff --git a/ddspipe_core/test/unittest/logging/dds_consumer/DdsLogConsumerTest.cpp b/ddspipe_core/test/unittest/logging/dds_consumer/DdsLogConsumerTest.cpp index 86c794a4..58bd506e 100644 --- a/ddspipe_core/test/unittest/logging/dds_consumer/DdsLogConsumerTest.cpp +++ b/ddspipe_core/test/unittest/logging/dds_consumer/DdsLogConsumerTest.cpp @@ -111,9 +111,9 @@ TEST_F(DdsLogConsumerTest, publish_logs) // Filter out every log except ours log_configuration.verbosity = utils::VerbosityKind::Info; - log_configuration.filter[utils::VerbosityKind::Info].set_value("DDSPIPE_TEST"); - log_configuration.filter[utils::VerbosityKind::Warning].set_value("DDSPIPE_TEST"); - log_configuration.filter[utils::VerbosityKind::Error].set_value("DDSPIPE_TEST"); + log_configuration.filter.info.set_value("DDSPIPE_TEST"); + log_configuration.filter.warning.set_value("DDSPIPE_TEST"); + log_configuration.filter.error.set_value("DDSPIPE_TEST"); utils::Log::ClearConsumers(); utils::Log::SetVerbosity(log_configuration.verbosity); @@ -205,9 +205,9 @@ TEST_F(DdsLogConsumerTest, dont_publish_logs) // Filter out every log except ours log_configuration.verbosity = utils::VerbosityKind::Info; - log_configuration.filter[utils::VerbosityKind::Info].set_value("DDSPIPE_TEST"); - log_configuration.filter[utils::VerbosityKind::Warning].set_value("DDSPIPE_TEST"); - log_configuration.filter[utils::VerbosityKind::Error].set_value("DDSPIPE_TEST"); + log_configuration.filter.info.set_value("DDSPIPE_TEST"); + log_configuration.filter.warning.set_value("DDSPIPE_TEST"); + log_configuration.filter.error.set_value("DDSPIPE_TEST"); utils::Log::ClearConsumers(); utils::Log::SetVerbosity(log_configuration.verbosity); diff --git a/ddspipe_core/test/unittest/logging/std_consumer/StdLogConsumerTest.cpp b/ddspipe_core/test/unittest/logging/std_consumer/StdLogConsumerTest.cpp index 2f37df93..900cce0f 100644 --- a/ddspipe_core/test/unittest/logging/std_consumer/StdLogConsumerTest.cpp +++ b/ddspipe_core/test/unittest/logging/std_consumer/StdLogConsumerTest.cpp @@ -42,9 +42,9 @@ TEST(StdLogConsumerTest, print_logs) // Filter out every log except ours log_configuration.verbosity = utils::VerbosityKind::Info; - log_configuration.filter[utils::VerbosityKind::Info].set_value("DDSPIPE_TEST"); - log_configuration.filter[utils::VerbosityKind::Warning].set_value("DDSPIPE_TEST"); - log_configuration.filter[utils::VerbosityKind::Error].set_value("DDSPIPE_TEST"); + log_configuration.filter.info.set_value("DDSPIPE_TEST"); + log_configuration.filter.warning.set_value("DDSPIPE_TEST"); + log_configuration.filter.error.set_value("DDSPIPE_TEST"); utils::Log::ClearConsumers(); utils::Log::SetVerbosity(log_configuration.verbosity); @@ -102,9 +102,9 @@ TEST(StdLogConsumerTest, dont_print_logs) // Filter out every log except ours log_configuration.verbosity = utils::VerbosityKind::Info; - log_configuration.filter[utils::VerbosityKind::Info].set_value("DDSPIPE_TEST"); - log_configuration.filter[utils::VerbosityKind::Warning].set_value("DDSPIPE_TEST"); - log_configuration.filter[utils::VerbosityKind::Error].set_value("DDSPIPE_TEST"); + log_configuration.filter.info.set_value("DDSPIPE_TEST"); + log_configuration.filter.warning.set_value("DDSPIPE_TEST"); + log_configuration.filter.error.set_value("DDSPIPE_TEST"); utils::Log::ClearConsumers(); utils::Log::SetVerbosity(log_configuration.verbosity); diff --git a/ddspipe_core/test/unittest/monitoring/status/logging/LogMonitorStatusTest.cpp b/ddspipe_core/test/unittest/monitoring/status/logging/LogMonitorStatusTest.cpp index 2cf9df6b..01688dc9 100644 --- a/ddspipe_core/test/unittest/monitoring/status/logging/LogMonitorStatusTest.cpp +++ b/ddspipe_core/test/unittest/monitoring/status/logging/LogMonitorStatusTest.cpp @@ -43,7 +43,7 @@ class LogMonitorStatusTest : public testing::Test utils::BaseLogConfiguration log_conf; log_conf.verbosity = utils::VerbosityKind::Info; - log_conf.filter[utils::VerbosityKind::Info].set_value("MONITOR_DATA"); + log_conf.filter.info.set_value("MONITOR_DATA"); utils::Log::SetVerbosity(log_conf.verbosity); diff --git a/ddspipe_core/test/unittest/monitoring/topics/logging/LogMonitorTopicsTest.cpp b/ddspipe_core/test/unittest/monitoring/topics/logging/LogMonitorTopicsTest.cpp index e05d8d7e..c94a88d1 100644 --- a/ddspipe_core/test/unittest/monitoring/topics/logging/LogMonitorTopicsTest.cpp +++ b/ddspipe_core/test/unittest/monitoring/topics/logging/LogMonitorTopicsTest.cpp @@ -45,7 +45,7 @@ class LogMonitorTopicsTest : public testing::Test utils::BaseLogConfiguration log_conf; log_conf.verbosity = utils::VerbosityKind::Info; - log_conf.filter[utils::VerbosityKind::Info].set_value("MONITOR_DATA"); + log_conf.filter.info.set_value("MONITOR_DATA"); utils::Log::SetVerbosity(log_conf.verbosity); diff --git a/ddspipe_participants/src/cpp/xml/XmlHandlerConfiguration.cpp b/ddspipe_participants/src/cpp/xml/XmlHandlerConfiguration.cpp index a7892574..b2fa1684 100644 --- a/ddspipe_participants/src/cpp/xml/XmlHandlerConfiguration.cpp +++ b/ddspipe_participants/src/cpp/xml/XmlHandlerConfiguration.cpp @@ -30,7 +30,7 @@ bool XmlHandlerConfiguration::is_valid( { if (!utils::is_file_accessible(file.c_str(), utils::FileAccessMode::read)) { - error_msg << "File " << file << " has not exist or does not have read access. "; + error_msg << "File " << file << " does not exist or does not have read access. "; return false; } } diff --git a/ddspipe_yaml/include/ddspipe_yaml/YamlReader.hpp b/ddspipe_yaml/include/ddspipe_yaml/YamlReader.hpp index a1c65dec..8f7289c8 100644 --- a/ddspipe_yaml/include/ddspipe_yaml/YamlReader.hpp +++ b/ddspipe_yaml/include/ddspipe_yaml/YamlReader.hpp @@ -14,8 +14,10 @@ #pragma once -#include +#include + #include +#include #include #include @@ -167,13 +169,31 @@ class const Yaml& yml, const TagType& tag); - //! TODO comment + /** + * @brief Validate \c yml and build the object \c T + * + * This method calls \c get with the default validation function. + * + * @tparam T type of the object to build + * @param yml base yaml + * @param version configuration version + */ template static T get( const Yaml& yml, const YamlReaderVersion version); - //! Get element inside \c tag + /** + * @brief Extracts the sub-yaml from the \c tag and then builds the object \c T + * + * This method calls \c get_value_in_tag to extract the sub-yaml from the \c tag and then it calls \c get to build + * and validate the object \c T. + * + * @tparam T type of the object to build + * @param yml base yaml + * @param tag key to yaml containing the object + * @param version configuration version + */ template static T get( const Yaml& yml, diff --git a/ddspipe_yaml/include/ddspipe_yaml/YamlValidator.hpp b/ddspipe_yaml/include/ddspipe_yaml/YamlValidator.hpp new file mode 100644 index 00000000..eb04080f --- /dev/null +++ b/ddspipe_yaml/include/ddspipe_yaml/YamlValidator.hpp @@ -0,0 +1,78 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include + +#include +#include +#include + +namespace eprosima { +namespace ddspipe { +namespace yaml { + +/** + * @brief Yaml Validator + * + * This class is used to validate Yaml objects. + */ +class YamlValidator +{ +public: + + /** + * @brief Validate a Yaml object against a specific version. + * + * For each type, the function should call \c validate_tags with the maximum set of tags \c yml may contain. + * + * @tparam T Type of the object to validate. + * @param yml Yaml object to validate. + * @param version Version to validate against. + */ + DDSPIPE_YAML_DllAPI + template + static bool validate( + const Yaml& yml, + const YamlReaderVersion& version = YamlReaderVersion::LATEST); + + /** + * @brief Ensure that all the tags in \c yml are unique and inside \c tags. + * + * @param yml Yaml object to validate. + * @param tags Set of tags to validate against. + */ + DDSPIPE_YAML_DllAPI + static bool validate_tags( + const Yaml& yml, + const std::set& valid_tags); + +protected: + + /** + * @brief Get the position of the yaml node in the yaml file + * + * If the position is not available, it will return "unknown position" + * + * @param yml base yaml + * @return "line X, column Y" + */ + static std::string get_position_( + const Yaml& yml); +}; + +} /* namespace yaml */ +} /* namespace ddspipe */ +} /* namespace eprosima */ diff --git a/ddspipe_yaml/src/cpp/YamlReader_features.cpp b/ddspipe_yaml/src/cpp/YamlReader_features.cpp index 28b09d8e..7447c6d9 100644 --- a/ddspipe_yaml/src/cpp/YamlReader_features.cpp +++ b/ddspipe_yaml/src/cpp/YamlReader_features.cpp @@ -12,7 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#include + #include #include @@ -30,6 +31,7 @@ #include #include +#include #include namespace eprosima { @@ -60,12 +62,27 @@ void YamlReader::fill( } } +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + XML_RAW_TAG, + XML_FILES_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI participants::XmlHandlerConfiguration YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { + YamlValidator::validate(yml, version); + participants::XmlHandlerConfiguration object; fill(object, yml, version); return object; @@ -75,6 +92,19 @@ participants::XmlHandlerConfiguration YamlReader::get( * Routes Configuration * ************************/ +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + ROUTES_SRC_TAG, + ROUTES_DST_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI void YamlReader::fill( @@ -93,6 +123,9 @@ void YamlReader::fill( for (const auto& route_yml : yml) { + // The validation has to be done here since the yml object is a list with the route + YamlValidator::validate(route_yml, version); + core::types::ParticipantId src; std::set dst; @@ -100,11 +133,12 @@ void YamlReader::fill( if (is_tag_present(route_yml, ROUTES_SRC_TAG)) { src = get(route_yml, ROUTES_SRC_TAG, version); + if (object.routes.count(src) != 0) { throw eprosima::utils::ConfigurationException( - utils::Formatter() << - "Multiple routes defined for participant " << src << " : only one allowed."); + utils::Formatter() << + "Multiple routes defined for participant " << src << " : only one allowed."); } } else @@ -136,6 +170,8 @@ core::RoutesConfiguration YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { + // NOTE: The validation has to be done inside the fill method since the yml object is a list with the routes + core::RoutesConfiguration object; fill(object, yml, version); return object; @@ -145,6 +181,20 @@ core::RoutesConfiguration YamlReader::get( * Topic Routes Configuration * ******************************/ +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + TOPIC_NAME_TAG, + TOPIC_TYPE_NAME_TAG, + ROUTES_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI void YamlReader::fill( @@ -163,7 +213,8 @@ void YamlReader::fill( for (const auto& topic_routes_yml : yml) { - // utils::Heritable topic; + YamlValidator::validate(topic_routes_yml, version); + auto topic = utils::Heritable::make_heritable(); core::RoutesConfiguration routes; @@ -173,17 +224,18 @@ void YamlReader::fill( { throw eprosima::utils::ConfigurationException( utils::Formatter() << - "Topic routes require topic and type names to be defined under tags " << TOPIC_NAME_TAG << " and " << TOPIC_TYPE_NAME_TAG << - ", respectively."); + "Topic routes require topic and type names to be defined under tags " << TOPIC_NAME_TAG << + " and " << TOPIC_TYPE_NAME_TAG << ", respectively."); } else { topic = get>(topic_routes_yml, version); + if (object.topic_routes.count(topic) != 0) { throw eprosima::utils::ConfigurationException( - utils::Formatter() << - "Multiple routes defined for topic " << topic << " : only one allowed."); + utils::Formatter() << + "Multiple routes defined for topic " << topic << " : only one allowed."); } } @@ -210,14 +262,62 @@ core::TopicRoutesConfiguration YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { + // NOTE: The validation has to be done inside the fill method since the yml object is a list with the topic routes + core::TopicRoutesConfiguration object; fill(object, yml, version); return object; } /************************* - * Monitor Configuration * - **************************/ +* Monitor Configuration * +**************************/ + +template <> +DDSPIPE_YAML_DllAPI +void YamlReader::fill( + core::MonitorProducerConfiguration& object, + const Yaml& yml, + const YamlReaderVersion version) +{ + // Optional enable + if (is_tag_present(yml, MONITOR_ENABLE_TAG)) + { + object.enabled = get(yml, MONITOR_ENABLE_TAG, version); + } + + // Optional period + if (is_tag_present(yml, MONITOR_PERIOD_TAG)) + { + object.period = get_positive_double(yml, MONITOR_PERIOD_TAG); + } +} + +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + MONITOR_ENABLE_TAG, + MONITOR_PERIOD_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + +template <> +DDSPIPE_YAML_DllAPI +core::MonitorProducerConfiguration YamlReader::get( + const Yaml& yml, + const YamlReaderVersion version) +{ + YamlValidator::validate(yml, version); + + core::MonitorProducerConfiguration object; + fill(object, yml, version); + return object; +} template <> DDSPIPE_YAML_DllAPI @@ -234,70 +334,70 @@ void YamlReader::fill( domain = get(yml, MONITOR_DOMAIN_TAG, version); } + static const std::set tags{ + MONITOR_ENABLE_TAG, + MONITOR_PERIOD_TAG, + DDS_PUBLISHING_ENABLE_TAG, + DDS_PUBLISHING_DOMAIN_TAG, + DDS_PUBLISHING_TOPIC_NAME_TAG}; + ///// // Get optional monitor status tag - if (YamlReader::is_tag_present(yml, MONITOR_STATUS_TAG)) + if (is_tag_present(yml, MONITOR_STATUS_TAG)) { - object.producers[core::STATUS_MONITOR_PRODUCER_ID] = YamlReader::get(yml, - MONITOR_STATUS_TAG, - version); + YamlValidator::validate_tags(yml[MONITOR_STATUS_TAG], tags); + + // NOTE: Use fill instead of get to avoid throwing exceptions if tags are not present + fill(object.producers[core::STATUS_MONITOR_PRODUCER_ID], + get_value_in_tag(yml, MONITOR_STATUS_TAG), version); + + // NOTE: Set the generic domain first so it can be overwritten by the specific domain if present object.consumers[core::STATUS_MONITOR_PRODUCER_ID].domain = domain; - YamlReader::fill(object.consumers[core::STATUS_MONITOR_PRODUCER_ID], + fill(object.consumers[core::STATUS_MONITOR_PRODUCER_ID], get_value_in_tag(yml, MONITOR_STATUS_TAG), version); } ///// // Get optional monitor topics tag - if (YamlReader::is_tag_present(yml, MONITOR_TOPICS_TAG)) + if (is_tag_present(yml, MONITOR_TOPICS_TAG)) { - object.producers[core::TOPICS_MONITOR_PRODUCER_ID] = YamlReader::get(yml, - MONITOR_TOPICS_TAG, - version); + YamlValidator::validate_tags(yml[MONITOR_TOPICS_TAG], tags); + + // NOTE: Use fill instead of get to avoid throwing exceptions if tags are not present + fill(object.producers[core::TOPICS_MONITOR_PRODUCER_ID], + get_value_in_tag(yml, MONITOR_TOPICS_TAG), version); + + // NOTE: Set the generic domain first so it can be overwritten by the specific domain if present object.consumers[core::TOPICS_MONITOR_PRODUCER_ID].domain = domain; - YamlReader::fill(object.consumers[core::TOPICS_MONITOR_PRODUCER_ID], + fill(object.consumers[core::TOPICS_MONITOR_PRODUCER_ID], get_value_in_tag(yml, MONITOR_TOPICS_TAG), version); } } template <> DDSPIPE_YAML_DllAPI -core::MonitorConfiguration YamlReader::get( +bool YamlValidator::validate( const Yaml& yml, - const YamlReaderVersion version) + const YamlReaderVersion& /* version */) { - core::MonitorConfiguration object; - fill(object, yml, version); - return object; -} - -template <> -DDSPIPE_YAML_DllAPI -void YamlReader::fill( - core::MonitorProducerConfiguration& object, - const Yaml& yml, - const YamlReaderVersion version) -{ - // Optional enable - if (is_tag_present(yml, MONITOR_ENABLE_TAG)) - { - object.enabled = get(yml, MONITOR_ENABLE_TAG, version); - } + static const std::set tags{ + MONITOR_DOMAIN_TAG, + MONITOR_STATUS_TAG, + MONITOR_TOPICS_TAG}; - // Optional period - if (is_tag_present(yml, MONITOR_PERIOD_TAG)) - { - object.period = get_positive_double(yml, MONITOR_PERIOD_TAG); - } + return YamlValidator::validate_tags(yml, tags); } template <> DDSPIPE_YAML_DllAPI -core::MonitorProducerConfiguration YamlReader::get( +core::MonitorConfiguration YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { - core::MonitorProducerConfiguration object; - fill(object, yml, version); + YamlValidator::validate(yml, version); + + core::MonitorConfiguration object; + fill(object, yml, version); return object; } diff --git a/ddspipe_yaml/src/cpp/YamlReader_generic.cpp b/ddspipe_yaml/src/cpp/YamlReader_generic.cpp index eabc3d4b..500140d2 100644 --- a/ddspipe_yaml/src/cpp/YamlReader_generic.cpp +++ b/ddspipe_yaml/src/cpp/YamlReader_generic.cpp @@ -14,30 +14,23 @@ /** * @file YamlReader.cpp - * */ -#include +#include + #include #include #include #include #include -#include -#include #include #include -#include -#include -#include -#include -#include - #include #include +#include #include namespace eprosima { @@ -292,11 +285,11 @@ std::string YamlReader::get( template <> DDSPIPE_YAML_DllAPI -utils::Timestamp YamlReader::get( +void YamlReader::fill( + utils::Timestamp& object, const Yaml& yml, - const YamlReaderVersion version /* version */) + const YamlReaderVersion version) { - utils::Timestamp ret_timestamp; std::string datetime_str; std::string datetime_format("%Y-%m-%d_%H-%M-%S"); bool local = true; @@ -322,7 +315,7 @@ utils::Timestamp YamlReader::get( datetime_str = get(yml, TIMESTAMP_DATETIME_TAG, version); try { - ret_timestamp = utils::string_to_timestamp(datetime_str, datetime_format, local); + object = utils::string_to_timestamp(datetime_str, datetime_format, local); } catch (const std::exception& e) { @@ -355,7 +348,37 @@ utils::Timestamp YamlReader::get( ns = std::chrono::nanoseconds(get_nonnegative_int(yml, TIMESTAMP_NANOSECONDS_TAG)); } - return std::chrono::time_point_cast(ret_timestamp + ms + us + ns); + object = std::chrono::time_point_cast(object + ms + us + ns); +} + +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + TIMESTAMP_DATETIME_FORMAT_TAG, + TIMESTAMP_LOCAL_TAG, + TIMESTAMP_DATETIME_TAG, + TIMESTAMP_MILLISECONDS_TAG, + TIMESTAMP_MICROSECONDS_TAG, + TIMESTAMP_NANOSECONDS_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + +template <> +DDSPIPE_YAML_DllAPI +utils::Timestamp YamlReader::get( + const Yaml& yml, + const YamlReaderVersion version /* version */) +{ + YamlValidator::validate(yml, version); + + utils::Timestamp object; + fill(object, yml, version); + return object; } } /* namespace yaml */ diff --git a/ddspipe_yaml/src/cpp/YamlReader_participants.cpp b/ddspipe_yaml/src/cpp/YamlReader_participants.cpp index 6c52ed31..87deed0f 100644 --- a/ddspipe_yaml/src/cpp/YamlReader_participants.cpp +++ b/ddspipe_yaml/src/cpp/YamlReader_participants.cpp @@ -14,28 +14,28 @@ /** * @file YamlReader.cpp - * */ -#include +#include + #include #include #include #include -#include -#include - #include +#include #include -#include #include -#include #include +#include +#include +#include #include #include +#include #include namespace eprosima { @@ -45,7 +45,7 @@ namespace yaml { using namespace eprosima::ddspipe::core::types; using namespace eprosima::ddspipe::participants::types; -/************************ +/*********************** * PARTICIPANTS * ************************/ @@ -62,12 +62,27 @@ void YamlReader::fill( object.id = get(yml, PARTICIPANT_NAME_TAG, version); } +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + PARTICIPANT_NAME_TAG, + PARTICIPANT_KIND_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI participants::ParticipantConfiguration YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { + YamlValidator::validate(yml, version); + participants::ParticipantConfiguration object; fill(object, yml, version); return object; @@ -104,12 +119,30 @@ void YamlReader::fill( } } +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + PARTICIPANT_NAME_TAG, + PARTICIPANT_KIND_TAG, + ECHO_DATA_TAG, + ECHO_DISCOVERY_TAG, + ECHO_VERBOSE_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI participants::EchoParticipantConfiguration YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { + YamlValidator::validate(yml, version); + participants::EchoParticipantConfiguration object; fill(object, yml, version); return object; @@ -164,16 +197,36 @@ void YamlReader::fill( // Optional Praticipant Topic QoS if (YamlReader::is_tag_present(yml, PARTICIPANT_QOS_TAG)) { - fill(object.topic_qos, get_value_in_tag(yml, PARTICIPANT_QOS_TAG), version); + object.topic_qos = get(yml, PARTICIPANT_QOS_TAG, version); } } +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + PARTICIPANT_NAME_TAG, + PARTICIPANT_KIND_TAG, + PARTICIPANT_QOS_TAG, + DOMAIN_ID_TAG, + WHITELIST_INTERFACES_TAG, + TRANSPORT_DESCRIPTORS_TRANSPORT_TAG, + IGNORE_PARTICIPANT_FLAGS_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI participants::SimpleParticipantConfiguration YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { + YamlValidator::validate(yml, version); + participants::SimpleParticipantConfiguration object; fill(object, yml, version); return object; @@ -216,10 +269,7 @@ void YamlReader::fill( // Optional TLS if (YamlReader::is_tag_present(yml, TLS_TAG)) { - YamlReader::fill( - object.tls_configuration, - YamlReader::get_value_in_tag(yml, TLS_TAG), - version); + object.tls_configuration = YamlReader::get(yml, TLS_TAG, version); } // NOTE: The only field that change regarding the version is the GuidPrefix. @@ -249,12 +299,35 @@ void YamlReader::fill( } } +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + PARTICIPANT_NAME_TAG, + PARTICIPANT_KIND_TAG, + PARTICIPANT_QOS_TAG, + WHITELIST_INTERFACES_TAG, + TRANSPORT_DESCRIPTORS_TRANSPORT_TAG, + IGNORE_PARTICIPANT_FLAGS_TAG, + LISTENING_ADDRESSES_TAG, + CONNECTION_ADDRESSES_TAG, + TLS_TAG, + DISCOVERY_SERVER_GUID_PREFIX_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI participants::DiscoveryServerParticipantConfiguration YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { + YamlValidator::validate(yml, version); + participants::DiscoveryServerParticipantConfiguration object; fill(object, yml, version); return object; @@ -297,10 +370,7 @@ void YamlReader::fill( // Optional TLS if (YamlReader::is_tag_present(yml, TLS_TAG)) { - YamlReader::fill( - object.tls_configuration, - YamlReader::get_value_in_tag(yml, TLS_TAG), - version); + object.tls_configuration = YamlReader::get(yml, TLS_TAG, version); } // Optional Repeater @@ -310,12 +380,35 @@ void YamlReader::fill( } } +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + PARTICIPANT_NAME_TAG, + PARTICIPANT_KIND_TAG, + PARTICIPANT_QOS_TAG, + WHITELIST_INTERFACES_TAG, + TRANSPORT_DESCRIPTORS_TRANSPORT_TAG, + IGNORE_PARTICIPANT_FLAGS_TAG, + LISTENING_ADDRESSES_TAG, + CONNECTION_ADDRESSES_TAG, + TLS_TAG, + IS_REPEATER_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI participants::InitialPeersParticipantConfiguration YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { + YamlValidator::validate(yml, version); + participants::InitialPeersParticipantConfiguration object; fill(object, yml, version); return object; @@ -337,12 +430,29 @@ void YamlReader::fill( object.participant_profile = YamlReader::get(yml, XML_PARTICIPANT_PROFILE_TAG, version); } +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + PARTICIPANT_NAME_TAG, + PARTICIPANT_KIND_TAG, + PARTICIPANT_QOS_TAG, + XML_PARTICIPANT_PROFILE_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI participants::XmlParticipantConfiguration YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { + YamlValidator::validate(yml, version); + participants::XmlParticipantConfiguration object; fill(object, yml, version); return object; diff --git a/ddspipe_yaml/src/cpp/YamlReader_types.cpp b/ddspipe_yaml/src/cpp/YamlReader_types.cpp index 1d54c607..f9add13e 100644 --- a/ddspipe_yaml/src/cpp/YamlReader_types.cpp +++ b/ddspipe_yaml/src/cpp/YamlReader_types.cpp @@ -17,6 +17,8 @@ * */ +#include + #include #include #include @@ -41,6 +43,7 @@ #include #include +#include #include namespace eprosima { @@ -151,12 +154,28 @@ DomainId YamlReader::get( return domain; } +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + DISCOVERY_SERVER_GUID_TAG, + DISCOVERY_SERVER_ID_TAG, + DISCOVERY_SERVER_ID_ROS_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI GuidPrefix YamlReader::get( const Yaml& yml, const YamlReaderVersion /* version */) { + YamlValidator::validate(yml); + // If guid exists, use it. Non mandatory. if (is_tag_present(yml, DISCOVERY_SERVER_GUID_TAG)) { @@ -191,12 +210,31 @@ GuidPrefix YamlReader::get( } } +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate
( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + ADDRESS_IP_VERSION_TAG, + ADDRESS_IP_TAG, + ADDRESS_DNS_TAG, + ADDRESS_PORT_TAG, + ADDRESS_EXTERNAL_PORT_TAG, + ADDRESS_TRANSPORT_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI Address YamlReader::get
( const Yaml& yml, const YamlReaderVersion version) { + YamlValidator::validate
(yml, version); + // Optional get IP version IpVersion ip_version; bool ip_version_set = is_tag_present(yml, ADDRESS_IP_VERSION_TAG); @@ -227,7 +265,7 @@ Address YamlReader::get
( // If neither set, get default if (ip_set && domain_name_set) { - EPROSIMA_LOG_WARNING(ddspipe_YAML, + EPROSIMA_LOG_WARNING(DDSPIPE_YAML, "Tag <" << ADDRESS_DNS_TAG << "> will not be used as <" << ADDRESS_IP_TAG << "> is set."); domain_name_set = false; } @@ -325,12 +363,28 @@ void YamlReader::fill( } } +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + DDS_PUBLISHING_ENABLE_TAG, + DDS_PUBLISHING_DOMAIN_TAG, + DDS_PUBLISHING_TOPIC_NAME_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI core::DdsPublishingConfiguration YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { + YamlValidator::validate(yml, version); + core::DdsPublishingConfiguration object; fill(object, yml, version); return object; @@ -378,8 +432,7 @@ void YamlReader::fill( { if (get(yml, QOS_OWNERSHIP_TAG, version)) { - object.ownership_qos.set_value( - ddspipe::core::types::OwnershipQosPolicyKind::EXCLUSIVE_OWNERSHIP_QOS); + object.ownership_qos.set_value(ddspipe::core::types::OwnershipQosPolicyKind::EXCLUSIVE_OWNERSHIP_QOS); } else { @@ -424,39 +477,88 @@ void YamlReader::fill( } } +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + QOS_TRANSIENT_TAG, + QOS_RELIABLE_TAG, + QOS_OWNERSHIP_TAG, + QOS_PARTITION_TAG, + QOS_HISTORY_DEPTH_TAG, + QOS_KEYED_TAG, + QOS_MAX_TX_RATE_TAG, + QOS_MAX_RX_RATE_TAG, + QOS_DOWNSAMPLING_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + +template <> +DDSPIPE_YAML_DllAPI +TopicQoS YamlReader::get( + const Yaml& yml, + const YamlReaderVersion version) +{ + YamlValidator::validate(yml, version); + + TopicQoS object; + fill(object, yml, version); + return object; +} + /************************ * LOGGING CONFIGURATION * ************************/ template <> DDSPIPE_YAML_DllAPI -void YamlReader::fill( +void YamlReader::fill( utils::LogFilter& object, const Yaml& yml, const YamlReaderVersion version) { if (is_tag_present(yml, LOG_FILTER_ERROR_TAG)) { - object[utils::VerbosityKind::Error] = get(yml, LOG_FILTER_ERROR_TAG, version); + object.error = get(yml, LOG_FILTER_ERROR_TAG, version); } if (is_tag_present(yml, LOG_FILTER_WARNING_TAG)) { - object[utils::VerbosityKind::Warning] = get(yml, LOG_FILTER_WARNING_TAG, version); + object.warning = get(yml, LOG_FILTER_WARNING_TAG, version); } if (is_tag_present(yml, LOG_FILTER_INFO_TAG)) { - object[utils::VerbosityKind::Info] = get(yml, LOG_FILTER_INFO_TAG, version); + object.info = get(yml, LOG_FILTER_INFO_TAG, version); } } +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + LOG_FILTER_ERROR_TAG, + LOG_FILTER_WARNING_TAG, + LOG_FILTER_INFO_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI utils::LogFilter YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { + YamlValidator::validate(yml, version); + utils::LogFilter object; fill(object, yml, version); return object; @@ -497,16 +599,33 @@ void YamlReader::fill( // Filter optional if (is_tag_present(yml, LOG_FILTER_TAG)) { - fill(object.filter, get_value_in_tag(yml, LOG_FILTER_TAG), version); + object.filter = get(yml, LOG_FILTER_TAG, version); } } +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + LOG_PUBLISH_TAG, + LOG_STDOUT_TAG, + LOG_VERBOSITY_TAG, + LOG_FILTER_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI core::DdsPipeLogConfiguration YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { + YamlValidator::validate(yml, version); + core::DdsPipeLogConfiguration object; fill(object, yml, version); return object; @@ -530,12 +649,27 @@ void YamlReader::fill( object.type_name = get(yml, TOPIC_TYPE_NAME_TAG, version); } +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + TOPIC_NAME_TAG, + TOPIC_TYPE_NAME_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI DdsTopic YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { + YamlValidator::validate(yml, version); + DdsTopic object; fill(object, yml, version); return object; @@ -560,16 +694,32 @@ void YamlReader::fill( // Optional QoS if (is_tag_present(yml, TOPIC_QOS_TAG)) { - fill(object.topic_qos, get_value_in_tag(yml, TOPIC_QOS_TAG), version); + object.topic_qos = get(yml, TOPIC_QOS_TAG, version); } } +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + TOPIC_NAME_TAG, + TOPIC_TYPE_NAME_TAG, + TOPIC_QOS_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI WildcardDdsFilterTopic YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { + YamlValidator::validate(yml, version); + WildcardDdsFilterTopic object; fill(object, yml, version); return object; @@ -582,7 +732,10 @@ void YamlReader::fill( const Yaml& yml, const YamlReaderVersion version) { - auto manual_topic = YamlReader::get(yml, version); + // Avoid calling YamlReader::get to avoid validation at a lower level + WildcardDdsFilterTopic manual_topic; + fill(manual_topic, yml, version); + object.first = utils::Heritable::make_heritable(manual_topic); // Optional participants tag @@ -592,12 +745,29 @@ void YamlReader::fill( } } +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + TOPIC_NAME_TAG, + TOPIC_TYPE_NAME_TAG, + TOPIC_QOS_TAG, + TOPIC_PARTICIPANTS_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI ManualTopic YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { + YamlValidator::validate(yml, version); + auto topic = utils::Heritable::make_heritable(); std::set participants; ManualTopic object = std::make_pair(topic, participants); @@ -612,6 +782,8 @@ utils::Heritable YamlReader::get( const YamlReaderVersion version) { // TODO: do not assume it is a Dds Topic + YamlValidator::validate(yml, version); + auto topic = utils::Heritable::make_heritable(); fill(topic.get_reference(), yml, version); return topic; @@ -624,6 +796,8 @@ utils::Heritable YamlReader::get( const YamlReaderVersion version) { // TODO: do not assume it is a Wildcard Topic + YamlValidator::validate(yml, version); + auto topic = utils::Heritable::make_heritable(); fill(topic.get_reference(), yml, version); return topic; @@ -709,12 +883,32 @@ void YamlReader::fill( } } +template <> +DDSPIPE_YAML_DllAPI +bool YamlValidator::validate( + const Yaml& yml, + const YamlReaderVersion& /* version */) +{ + static const std::set tags{ + TLS_PRIVATE_KEY_TAG, + TLS_PASSWORD_TAG, + TLS_CA_TAG, + TLS_CERT_TAG, + TLS_SNI_HOST_TAG, + TLS_DHPARAMS_TAG, + TLS_PEER_VERIFICATION_TAG}; + + return YamlValidator::validate_tags(yml, tags); +} + template <> DDSPIPE_YAML_DllAPI TlsConfiguration YamlReader::get( const Yaml& yml, const YamlReaderVersion version) { + YamlValidator::validate(yml, version); + TlsConfiguration object; fill(object, yml, version); return object; diff --git a/ddspipe_yaml/src/cpp/YamlValidator.cpp b/ddspipe_yaml/src/cpp/YamlValidator.cpp new file mode 100644 index 00000000..a307fbdb --- /dev/null +++ b/ddspipe_yaml/src/cpp/YamlValidator.cpp @@ -0,0 +1,94 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file YamlValidator.cpp + */ + +#include + +#include + +namespace eprosima { +namespace ddspipe { +namespace yaml { + +bool YamlValidator::validate_tags( + const Yaml& yml, + const std::set& valid_tags) +{ + if (!yml.IsMap() && !yml.IsNull()) + { + throw eprosima::utils::ConfigurationException( + utils::Formatter() << "The yml: <" << yml << "> is not a yaml object map."); + } + + // Check if there are repeated tags or extra tags that are not in valid_tags + std::map tags_count; + bool is_valid = true; + + for (const auto& tag_it : yml) + { + const auto& tag = tag_it.first; + const auto& tag_name = tag.as(); + + // Check if the tag is valid + if (!valid_tags.count(tag_name)) + { + EPROSIMA_LOG_WARNING(DDSPIPE_YAML, "Tag <" << tag_name << "> is not a valid tag (" << get_position_(tag) << ")."); + is_valid = false; + } + + // Check if the tag is repeated + tags_count[tag_name]++; + + if (tags_count[tag_name] > 1) + { + EPROSIMA_LOG_WARNING(DDSPIPE_YAML, "Tag <" << tag_name << "> is repeated (" << get_position_(tag) << ")."); + is_valid = false; + } + } + + return is_valid; +} + +std::string YamlValidator::get_position_( + const Yaml& yml) +{ + int line; + int column; + + try + { + const auto& mark = yml.Mark(); + + if (mark.is_null()) + { + return "unknown position"; + } + + line = mark.line + 1; + column = mark.column + 1; + } + catch (const std::exception& e) + { + return "unknown position"; + } + + return "line " + std::to_string(line) + ", column " + std::to_string(column); +} + +} /* namespace yaml */ +} /* namespace ddspipe */ +} /* namespace eprosima */ diff --git a/ddspipe_yaml/test/unittest/entities/address/CMakeLists.txt b/ddspipe_yaml/test/unittest/entities/address/CMakeLists.txt index 30f991d6..7c501325 100644 --- a/ddspipe_yaml/test/unittest/entities/address/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/entities/address/CMakeLists.txt @@ -22,6 +22,7 @@ set(TEST_SOURCES ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_generic.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_participants.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_types.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/YamlValidator.cpp YamlGetEntityAddressTest.cpp ) diff --git a/ddspipe_yaml/test/unittest/entities/guid/CMakeLists.txt b/ddspipe_yaml/test/unittest/entities/guid/CMakeLists.txt index 605db8fc..9960d596 100644 --- a/ddspipe_yaml/test/unittest/entities/guid/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/entities/guid/CMakeLists.txt @@ -24,6 +24,7 @@ set(TEST_SOURCES ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_participants.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_types.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlManager.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/YamlValidator.cpp ) diff --git a/ddspipe_yaml/test/unittest/entities/topic/CMakeLists.txt b/ddspipe_yaml/test/unittest/entities/topic/CMakeLists.txt index 373cdba5..86da44c0 100644 --- a/ddspipe_yaml/test/unittest/entities/topic/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/entities/topic/CMakeLists.txt @@ -24,6 +24,7 @@ set(TEST_SOURCES ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_participants.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_types.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlManager.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/YamlValidator.cpp ) diff --git a/ddspipe_yaml/test/unittest/entities/transport/CMakeLists.txt b/ddspipe_yaml/test/unittest/entities/transport/CMakeLists.txt index a54dc70c..9779672d 100644 --- a/ddspipe_yaml/test/unittest/entities/transport/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/entities/transport/CMakeLists.txt @@ -24,6 +24,7 @@ set(TEST_SOURCES ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_participants.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_types.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlManager.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/YamlValidator.cpp ) @@ -60,6 +61,7 @@ set(TEST_SOURCES ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_participants.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_types.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlManager.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/YamlValidator.cpp ) diff --git a/ddspipe_yaml/test/unittest/yaml_reader/forwarding_routes/routes/CMakeLists.txt b/ddspipe_yaml/test/unittest/yaml_reader/forwarding_routes/routes/CMakeLists.txt index fd12f1f5..81971b78 100644 --- a/ddspipe_yaml/test/unittest/yaml_reader/forwarding_routes/routes/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/yaml_reader/forwarding_routes/routes/CMakeLists.txt @@ -23,6 +23,7 @@ set(TEST_SOURCES ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_generic.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_participants.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_types.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/YamlValidator.cpp YamlReaderRoutesTest.cpp ) diff --git a/ddspipe_yaml/test/unittest/yaml_reader/forwarding_routes/topic_routes/CMakeLists.txt b/ddspipe_yaml/test/unittest/yaml_reader/forwarding_routes/topic_routes/CMakeLists.txt index 6f1733e7..d536d0f6 100644 --- a/ddspipe_yaml/test/unittest/yaml_reader/forwarding_routes/topic_routes/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/yaml_reader/forwarding_routes/topic_routes/CMakeLists.txt @@ -23,6 +23,7 @@ set(TEST_SOURCES ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_generic.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_participants.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_types.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/YamlValidator.cpp YamlReaderTopicRoutesTest.cpp ) diff --git a/ddspipe_yaml/test/unittest/yaml_reader/log_configuration/YamlReaderLogConfiguration.cpp b/ddspipe_yaml/test/unittest/yaml_reader/log_configuration/YamlReaderLogConfiguration.cpp index ce172c5f..7932fef6 100644 --- a/ddspipe_yaml/test/unittest/yaml_reader/log_configuration/YamlReaderLogConfiguration.cpp +++ b/ddspipe_yaml/test/unittest/yaml_reader/log_configuration/YamlReaderLogConfiguration.cpp @@ -62,9 +62,9 @@ TEST(YamlReaderLogConfiguration, parse_correct_LogConfiguration_yaml) // Verify that the verbosity and filters are correct ASSERT_EQ(conf.verbosity.get_value(), utils::VerbosityKind::Info); - ASSERT_EQ(conf.filter.at(utils::VerbosityKind::Error).get_value(), "DDSPIPE"); - ASSERT_EQ(conf.filter.at(utils::VerbosityKind::Warning).get_value(), ""); - ASSERT_EQ(conf.filter.at(utils::VerbosityKind::Info).get_value(), "DEBUG"); + ASSERT_EQ(conf.filter.error.get_value(), "DDSPIPE"); + ASSERT_EQ(conf.filter.warning.get_value(), ""); + ASSERT_EQ(conf.filter.info.get_value(), "DEBUG"); } /** @@ -93,9 +93,9 @@ TEST(YamlReaderLogConfiguration, parse_correct_LogConfiguration_yaml_and_default ASSERT_TRUE(conf.is_valid(error_msg)); ASSERT_EQ(conf.verbosity.get_value(), utils::VerbosityKind::Warning); - ASSERT_EQ(conf.filter.at(utils::VerbosityKind::Error).get_value(), ""); - ASSERT_EQ(conf.filter.at(utils::VerbosityKind::Warning).get_value(), ""); - ASSERT_EQ(conf.filter.at(utils::VerbosityKind::Info).get_value(), "DEBUG"); + ASSERT_EQ(conf.filter.error.get_value(), ""); + ASSERT_EQ(conf.filter.warning.get_value(), ""); + ASSERT_EQ(conf.filter.info.get_value(), "DEBUG"); } /** diff --git a/ddspipe_yaml/test/unittest/yaml_reader/monitoring/CMakeLists.txt b/ddspipe_yaml/test/unittest/yaml_reader/monitoring/CMakeLists.txt index e38c635c..683e7f14 100644 --- a/ddspipe_yaml/test/unittest/yaml_reader/monitoring/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/yaml_reader/monitoring/CMakeLists.txt @@ -23,6 +23,7 @@ set(TEST_SOURCES ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_generic.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_participants.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_types.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/YamlValidator.cpp YamlReaderMonitorTest.cpp ) diff --git a/ddspipe_yaml/test/unittest/yaml_reader/scalar/CMakeLists.txt b/ddspipe_yaml/test/unittest/yaml_reader/scalar/CMakeLists.txt index 31c9731c..1fbfc973 100644 --- a/ddspipe_yaml/test/unittest/yaml_reader/scalar/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/yaml_reader/scalar/CMakeLists.txt @@ -22,6 +22,7 @@ set(TEST_SOURCES ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_generic.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_participants.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_types.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/YamlValidator.cpp YamlReaderScalarTest.cpp ) diff --git a/ddspipe_yaml/test/unittest/yaml_writer/CMakeLists.txt b/ddspipe_yaml/test/unittest/yaml_writer/CMakeLists.txt index b245030b..ea07c24b 100644 --- a/ddspipe_yaml/test/unittest/yaml_writer/CMakeLists.txt +++ b/ddspipe_yaml/test/unittest/yaml_writer/CMakeLists.txt @@ -20,6 +20,7 @@ set(TEST_NAME YamlWriterTest) set(TEST_SOURCES ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_generic.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/YamlValidator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlWriter.cpp YamlWriterTest.cpp ) @@ -61,6 +62,7 @@ set(TEST_NAME YamlWriter_collections_test) set(TEST_SOURCES ${PROJECT_SOURCE_DIR}/src/cpp/YamlReader_generic.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/YamlValidator.cpp ${PROJECT_SOURCE_DIR}/src/cpp/YamlWriter.cpp YamlWriter_collections_test.cpp )