diff options
author | Kozoriz <kozorizandriy@gmail.com> | 2016-12-27 17:24:48 +0200 |
---|---|---|
committer | Kozoriz <kozorizandriy@gmail.com> | 2016-12-29 09:42:05 +0200 |
commit | 85bba21e1839f3a5f79b64b88578e7dbbe134c3c (patch) | |
tree | e28a32b9a359132371f0deed122c7cba57a24c25 /src | |
parent | 5f1e86cee34511417b9137740ae6fcb557dc9042 (diff) | |
download | sdl_core-85bba21e1839f3a5f79b64b88578e7dbbe134c3c.tar.gz |
Add validation preloaded_pt field in PT_UPDATE type of table
Fixed defect : APPLINK-30866
Diffstat (limited to 'src')
7 files changed, 75 insertions, 47 deletions
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 5f0f876f13..fe7596d2a0 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1123,7 +1123,7 @@ void PolicyHandler::OnActivateApp(uint32_t connection_key, permissions.isSDLAllowed = kDeviceAllowed == consent; // According to the SDLAQ-CRS-2794, p.9 - // 'priority' should be ommited in case when device + // 'priority' should be omitted in case when device // is not allowed. if (!permissions.isSDLAllowed) { permissions.priority.clear(); diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index 4451131e3d..9247c62d8f 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -704,22 +704,40 @@ void ModuleConfig::ReportErrors(rpc::ValidationReport* report__) const { if (!vehicle_year.is_valid()) { vehicle_year.ReportErrors(&report__->ReportSubobject("vehicle_year")); } - if (PT_PRELOADED == GetPolicyTableType()) { - std::string validation_info = - ommited_validation_info + PolicyTableTypeToString(GetPolicyTableType()); - rpc::ValidationReport* ommited_field_report; - if (vehicle_make.is_initialized()) { - ommited_field_report = &report__->ReportSubobject("vehicle_make"); - ommited_field_report->set_validation_info(validation_info); - } - if (vehicle_year.is_initialized()) { - ommited_field_report = &report__->ReportSubobject("vehicle_year"); - ommited_field_report->set_validation_info(validation_info); + + const std::string validation_info = + omitted_validation_info + PolicyTableTypeToString(GetPolicyTableType()); + + switch (GetPolicyTableType()) { + case PT_PRELOADED: { + if (vehicle_make.is_initialized()) { + rpc::ValidationReport& vehicle_make_omitted_field_report = + report__->ReportSubobject("vehicle_make"); + vehicle_make_omitted_field_report.set_validation_info(validation_info); + } + if (vehicle_year.is_initialized()) { + rpc::ValidationReport& vehicle_year_omitted_field_report = + report__->ReportSubobject("vehicle_year"); + vehicle_year_omitted_field_report.set_validation_info(validation_info); + } + if (vehicle_model.is_initialized()) { + rpc::ValidationReport& vehicle_model_omitted_field_report = + report__->ReportSubobject("vehicle_model"); + vehicle_model_omitted_field_report.set_validation_info(validation_info); + } + + break; } - if (vehicle_model.is_initialized()) { - ommited_field_report = &report__->ReportSubobject("vehicle_model"); - ommited_field_report->set_validation_info(validation_info); + case PT_UPDATE: { + if (preloaded_pt.is_initialized()) { + rpc::ValidationReport& preloaded_pt_omitted_field_report = + report__->ReportSubobject("preloaded_pt"); + preloaded_pt_omitted_field_report.set_validation_info(validation_info); + } + break; } + default: + break; } } @@ -888,7 +906,7 @@ void MessageLanguages::ReportErrors(rpc::ValidationReport* report__) const { if (PT_SNAPSHOT == GetPolicyTableType()) { if (languages.is_initialized()) { std::string validation_info = - ommited_validation_info + + omitted_validation_info + PolicyTableTypeToString(GetPolicyTableType()); report__->ReportSubobject("languages") .set_validation_info(validation_info); @@ -963,7 +981,7 @@ void ConsumerFriendlyMessages::ReportErrors( if (PT_SNAPSHOT == GetPolicyTableType()) { if (messages.is_initialized()) { std::string validation_info = - ommited_validation_info + + omitted_validation_info + PolicyTableTypeToString(GetPolicyTableType()); report__->ReportSubobject("messages") .set_validation_info(validation_info); @@ -1110,7 +1128,7 @@ void ModuleMeta::ReportErrors(rpc::ValidationReport* report__) const { if (GetPolicyTableType() == PT_UPDATE || GetPolicyTableType() == PT_PRELOADED) { std::string validation_info = - ommited_validation_info + PolicyTableTypeToString(GetPolicyTableType()); + omitted_validation_info + PolicyTableTypeToString(GetPolicyTableType()); report__->set_validation_info(validation_info.c_str()); } } @@ -1407,7 +1425,7 @@ void AppLevel::ReportErrors(rpc::ValidationReport* report__) const { if (PT_PRELOADED == GetPolicyTableType() || PT_UPDATE == GetPolicyTableType()) { std::string validation_info = - ommited_validation_info + PolicyTableTypeToString(GetPolicyTableType()); + omitted_validation_info + PolicyTableTypeToString(GetPolicyTableType()); report__->set_validation_info(validation_info); } } @@ -1504,7 +1522,7 @@ void UsageAndErrorCounts::ReportErrors(rpc::ValidationReport* report__) const { if (PT_PRELOADED == GetPolicyTableType() || PT_UPDATE == GetPolicyTableType()) { std::string validation_info = - ommited_validation_info + PolicyTableTypeToString(GetPolicyTableType()); + omitted_validation_info + PolicyTableTypeToString(GetPolicyTableType()); report__->set_validation_info(validation_info); } if (!count_of_iap_buffer_full.is_valid()) { @@ -1855,7 +1873,7 @@ void PolicyTable::ReportErrors(rpc::ValidationReport* report__) const { if (PT_PRELOADED == GetPolicyTableType() || PT_UPDATE == GetPolicyTableType()) { std::string validation_info = - ommited_validation_info + PolicyTableTypeToString(GetPolicyTableType()); + omitted_validation_info + PolicyTableTypeToString(GetPolicyTableType()); if (device_data.is_initialized()) { report__->ReportSubobject("device_data") diff --git a/src/components/policy/policy_external/src/policy_table/validation.cc b/src/components/policy/policy_external/src/policy_table/validation.cc index 83c959dbb4..eea35fc786 100644 --- a/src/components/policy/policy_external/src/policy_table/validation.cc +++ b/src/components/policy/policy_external/src/policy_table/validation.cc @@ -2,6 +2,7 @@ #include <algorithm> #include "policy/policy_table/types.h" #include "utils/logger.h" +#include "utils/helpers.h" namespace { bool IsPredefinedApplication(const std::string& app_id) { @@ -148,16 +149,25 @@ bool Rpcs::Validate() const { return true; } bool ModuleConfig::Validate() const { - if (PT_PRELOADED == GetPolicyTableType()) { - if (vehicle_make.is_initialized()) { - return false; - } - if (vehicle_year.is_initialized()) { - return false; + switch (GetPolicyTableType()) { + case PT_PRELOADED: { + if (helpers::Compare<bool, helpers::EQ, helpers::ONE>( + true, + vehicle_make.is_initialized(), + vehicle_year.is_initialized(), + vehicle_model.is_initialized())) { + return false; + } + break; } - if (vehicle_model.is_initialized()) { - return false; + case PT_UPDATE: { + if (preloaded_pt->is_initialized()) { + return false; + } + break; } + default: + break; } return true; } diff --git a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc index cbd3db7bb7..16c5587541 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc @@ -712,7 +712,7 @@ TEST_F(PolicyManagerImplTest2, // Load Json to cache // File have 2 functional groups: SendLocation and SendLocationOnly. // They have different parameters. One has dissalowed all params, other - - // ommited. + // omitted. // Arrange CreateLocalPT("json/sdl_preloaded_pt_send_location.json"); diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc index 2c604d2e10..7928973919 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -611,19 +611,19 @@ void ModuleConfig::ReportErrors(rpc::ValidationReport* report__) const { } if (PT_PRELOADED == GetPolicyTableType()) { std::string validation_info = - ommited_validation_info + PolicyTableTypeToString(GetPolicyTableType()); - rpc::ValidationReport* ommited_field_report; + omitted_validation_info + PolicyTableTypeToString(GetPolicyTableType()); + rpc::ValidationReport* omitted_field_report; if (vehicle_make.is_initialized()) { - ommited_field_report = &report__->ReportSubobject("vehicle_make"); - ommited_field_report->set_validation_info(validation_info); + omitted_field_report = &report__->ReportSubobject("vehicle_make"); + omitted_field_report->set_validation_info(validation_info); } if (vehicle_year.is_initialized()) { - ommited_field_report = &report__->ReportSubobject("vehicle_year"); - ommited_field_report->set_validation_info(validation_info); + omitted_field_report = &report__->ReportSubobject("vehicle_year"); + omitted_field_report->set_validation_info(validation_info); } if (vehicle_model.is_initialized()) { - ommited_field_report = &report__->ReportSubobject("vehicle_model"); - ommited_field_report->set_validation_info(validation_info); + omitted_field_report = &report__->ReportSubobject("vehicle_model"); + omitted_field_report->set_validation_info(validation_info); } } } @@ -772,7 +772,7 @@ void MessageLanguages::ReportErrors(rpc::ValidationReport* report__) const { if (PT_SNAPSHOT == GetPolicyTableType()) { if (languages.is_initialized()) { std::string validation_info = - ommited_validation_info + + omitted_validation_info + PolicyTableTypeToString(GetPolicyTableType()); report__->ReportSubobject("languages") .set_validation_info(validation_info); @@ -837,7 +837,7 @@ void ConsumerFriendlyMessages::ReportErrors( if (PT_SNAPSHOT == GetPolicyTableType()) { if (messages.is_initialized()) { std::string validation_info = - ommited_validation_info + + omitted_validation_info + PolicyTableTypeToString(GetPolicyTableType()); report__->ReportSubobject("messages") .set_validation_info(validation_info); @@ -1118,7 +1118,7 @@ void AppLevel::ReportErrors(rpc::ValidationReport* report__) const { if (PT_PRELOADED == GetPolicyTableType() || PT_UPDATE == GetPolicyTableType()) { std::string validation_info = - ommited_validation_info + PolicyTableTypeToString(GetPolicyTableType()); + omitted_validation_info + PolicyTableTypeToString(GetPolicyTableType()); report__->set_validation_info(validation_info); } } @@ -1160,7 +1160,7 @@ void UsageAndErrorCounts::ReportErrors(rpc::ValidationReport* report__) const { if (PT_PRELOADED == GetPolicyTableType() || PT_UPDATE == GetPolicyTableType()) { std::string validation_info = - ommited_validation_info + PolicyTableTypeToString(GetPolicyTableType()); + omitted_validation_info + PolicyTableTypeToString(GetPolicyTableType()); report__->set_validation_info(validation_info); } if (!app_level.is_valid()) { @@ -1298,7 +1298,7 @@ void PolicyTable::ReportErrors(rpc::ValidationReport* report__) const { if (PT_PRELOADED == GetPolicyTableType() || PT_UPDATE == GetPolicyTableType()) { std::string validation_info = - ommited_validation_info + PolicyTableTypeToString(GetPolicyTableType()); + omitted_validation_info + PolicyTableTypeToString(GetPolicyTableType()); if (device_data.is_initialized()) { report__->ReportSubobject("device_data") diff --git a/src/components/policy/policy_regular/src/policy_table/validation.cc b/src/components/policy/policy_regular/src/policy_table/validation.cc index b9bcbfa7ab..e7a981e559 100644 --- a/src/components/policy/policy_regular/src/policy_table/validation.cc +++ b/src/components/policy/policy_regular/src/policy_table/validation.cc @@ -66,7 +66,7 @@ bool ApplicationPoliciesSection::Validate() const { while (iter != end_iter) { ApplicationParams& app_params = (*iter).second; - bool is_request_type_ommited = !app_params.RequestType.is_initialized(); + bool is_request_type_omitted = !app_params.RequestType.is_initialized(); bool is_request_type_valid = app_params.RequestType.is_valid(); bool is_request_type_empty = app_params.RequestType->empty(); @@ -83,9 +83,9 @@ bool ApplicationPoliciesSection::Validate() const { } } } else { - if (is_request_type_ommited) { + if (is_request_type_omitted) { LOG4CXX_WARN(logger_, - "App policy RequestTypes ommited." + "App policy RequestTypes omitted." " Will be replaced with default."); app_params.RequestType = apps[kDefaultApp].RequestType; ++iter; diff --git a/src/components/rpc_base/include/rpc_base/rpc_base.h b/src/components/rpc_base/include/rpc_base/rpc_base.h index 4b9b432d9a..cf5656176c 100644 --- a/src/components/rpc_base/include/rpc_base/rpc_base.h +++ b/src/components/rpc_base/include/rpc_base/rpc_base.h @@ -58,7 +58,7 @@ enum PolicyTableType { PT_UPDATE, PT_SNAPSHOT }; -const std::string ommited_validation_info = "should be ommited in "; +const std::string omitted_validation_info = "should be omitted in "; const std::string required_validation_info = "is required in "; std::string PolicyTableTypeToString(const PolicyTableType pt_type); |