summaryrefslogtreecommitdiff
path: root/src/components/policy/policy_external
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2018-08-23 09:58:04 -0400
committerJackLivio <jack@livio.io>2018-08-23 09:58:04 -0400
commitfb890127f47c300d80c76e0464ea0f041783deb2 (patch)
tree8b7785aa9dca98776a29fbe9acee90cc6df3493d /src/components/policy/policy_external
parent997674798fbe6a6ed2dd579d0703aa8e22d8a643 (diff)
parent73e4f50de1b77e1c938f31226f180f3c63a566fc (diff)
downloadsdl_core-fb890127f47c300d80c76e0464ea0f041783deb2.tar.gz
Merge remote-tracking branch 'origin/develop' into feature/full_app_idfeature/full_app_id
# Conflicts: # src/components/interfaces/MOBILE_API.xml
Diffstat (limited to 'src/components/policy/policy_external')
-rw-r--r--src/components/policy/policy_external/include/policy/policy_helper.h22
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/enums.h9
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml3
-rw-r--r--src/components/policy/policy_external/src/policy_helper.cc38
-rw-r--r--src/components/policy/policy_external/src/policy_table/enums.cc21
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc36
6 files changed, 98 insertions, 31 deletions
diff --git a/src/components/policy/policy_external/include/policy/policy_helper.h b/src/components/policy/policy_external/include/policy/policy_helper.h
index e446c0b2e3..6f916b7cd0 100644
--- a/src/components/policy/policy_external/include/policy/policy_helper.h
+++ b/src/components/policy/policy_external/include/policy/policy_helper.h
@@ -255,8 +255,26 @@ struct FillNotificationData {
const std::set<Parameter>& target);
void InitRpcKeys(const std::string& rpc_name);
bool RpcParametersEmpty(RpcPermissions& rpc);
- bool IsSectionEmpty(ParameterPermissions& permissions,
- const std::string& section);
+
+ /**
+ * @brief Checks if specific section in specified permissions is empty
+ * @param permissions reference to the permissions structure
+ * @param section reference to the section name
+ * @return true if specified section in permissions is empty otherwise returns
+ * false
+ */
+ bool IsSectionEmpty(const ParameterPermissions& permissions,
+ const std::string& section) const;
+
+ /**
+ * @brief Checks if at least one parameter is allowed for the specified
+ * permissions
+ * @param permissions reference to the permissions structure
+ * @return true if at least one parameter is allowed for the specified
+ * permissions otherwise returns false
+ */
+ bool IsSomeParameterAllowed(const ParameterPermissions& permissions) const;
+
std::string current_key_;
Permissions& data_;
const bool does_require_user_consent_;
diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h
index d13c545a94..5fc43603d8 100644
--- a/src/components/policy/policy_external/include/policy/policy_table/enums.h
+++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h
@@ -167,7 +167,14 @@ bool IsValidEnum(Input val);
const char* EnumToJsonString(Input val);
bool EnumFromJsonString(const std::string& literal, Input* result);
-enum ModuleType { MT_CLIMATE, MT_RADIO, MT_SEAT };
+enum ModuleType {
+ MT_CLIMATE,
+ MT_RADIO,
+ MT_SEAT,
+ MT_AUDIO,
+ MT_LIGHT,
+ MT_HMI_SETTINGS
+};
bool IsValidEnum(ModuleType val);
const char* EnumToJsonString(ModuleType val);
bool EnumFromJsonString(const std::string& literal, ModuleType* result);
diff --git a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml
index 7246bec800..26af165506 100644
--- a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml
+++ b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml
@@ -98,8 +98,7 @@
<typedef name="HmiLevels" type="HmiLevel" array="true"
maxsize="4" />
- <typedef name="Parameters" type="Parameter" array="true"
- maxsize="24" />
+ <typedef name="Parameters" type="Parameter" array="true"/>
<struct name="RpcParameters">
<!-- maxsizes are equal to number of currently known elements of
diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc
index ed12cdde3a..2358c54bef 100644
--- a/src/components/policy/policy_external/src/policy_helper.cc
+++ b/src/components/policy/policy_external/src/policy_helper.cc
@@ -620,7 +620,16 @@ void FillNotificationData::UpdateParameters(
ParametersConstItr it_parameters = in_parameters.begin();
ParametersConstItr it_parameters_end = in_parameters.end();
- // Due to APPLINK-24201 SDL must consider cases when 'parameters' section is
+ // To determine consent for a particular RPC in a particular HMI level with
+ // particular parameters (if applicable), the system shall find all of the
+ // functional groups the RPC is included in. If user consent is needed as
+ // listed within the functional group in the policy table, the system shall
+ // use a logical AND: backend permissions AND User permissions. If the RPC is
+ // listed under more than one group, the system shall perform a logical OR
+ // amongst all of the possible allowed permissions scenarios for the RPC (and
+ // parameter/or HMI level) defined by each of the functional groups.
+
+ // Due to requirements SDL must consider cases when 'parameters' section is
// not present for RPC or present, but is empty.
// If 'parameters' section is like: 'parameters' : []
@@ -635,10 +644,8 @@ void FillNotificationData::UpdateParameters(
// If 'parameters' section is omitted
if (!in_parameters.is_initialized()) {
- if (!does_require_user_consent_) {
- out_parameter.any_parameter_allowed = true;
- }
- if (does_require_user_consent_ && kAllowedKey == current_key_) {
+ if (!does_require_user_consent_ ||
+ (does_require_user_consent_ && kAllowedKey == current_key_)) {
out_parameter.any_parameter_allowed = true;
}
}
@@ -647,6 +654,13 @@ void FillNotificationData::UpdateParameters(
out_parameter[current_key_].insert(
policy_table::EnumToJsonString(*it_parameters));
}
+
+ // We should reset ALL DISALLOWED flags if at least one parameter is allowed
+ // due to a logical OR permissions check
+ if (IsSomeParameterAllowed(out_parameter)) {
+ out_parameter.any_parameter_disallowed_by_policy = false;
+ out_parameter.any_parameter_disallowed_by_user = false;
+ }
}
void FillNotificationData::ExcludeSame(RpcPermissions& rpc) {
@@ -769,16 +783,24 @@ bool FillNotificationData::RpcParametersEmpty(RpcPermissions& rpc) {
no_user_disallowed_parameters;
}
-bool FillNotificationData::IsSectionEmpty(ParameterPermissions& permissions,
- const std::string& section) {
+bool FillNotificationData::IsSectionEmpty(
+ const ParameterPermissions& permissions, const std::string& section) const {
ParameterPermissions::const_iterator it_section = permissions.find(section);
ParameterPermissions::const_iterator end = permissions.end();
if (end != it_section) {
- return permissions[section].empty();
+ return it_section->second.empty();
}
return true;
}
+bool FillNotificationData::IsSomeParameterAllowed(
+ const ParameterPermissions& permissions) const {
+ const bool are_any_consented_parameters_allowed =
+ kAllowedKey == current_key_ && !IsSectionEmpty(permissions, current_key_);
+ return permissions.any_parameter_allowed ||
+ are_any_consented_parameters_allowed;
+}
+
ProcessFunctionalGroup::ProcessFunctionalGroup(
const policy_table::FunctionalGroupings& fg,
const std::vector<FunctionalGroupPermission>& group_permissions,
diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc
index 58bae43000..c2b304df67 100644
--- a/src/components/policy/policy_external/src/policy_table/enums.cc
+++ b/src/components/policy/policy_external/src/policy_table/enums.cc
@@ -771,6 +771,12 @@ bool IsValidEnum(ModuleType val) {
return true;
case MT_RADIO:
return true;
+ case MT_AUDIO:
+ return true;
+ case MT_LIGHT:
+ return true;
+ case MT_HMI_SETTINGS:
+ return true;
case MT_SEAT:
return true;
default:
@@ -783,6 +789,12 @@ const char* EnumToJsonString(ModuleType val) {
return "CLIMATE";
case MT_RADIO:
return "RADIO";
+ case MT_AUDIO:
+ return "AUDIO";
+ case MT_LIGHT:
+ return "LIGHT";
+ case MT_HMI_SETTINGS:
+ return "HMI_SETTINGS";
case MT_SEAT:
return "SEAT";
default:
@@ -800,6 +812,15 @@ bool EnumFromJsonString(const std::string& literal, ModuleType* result) {
} else if ("SEAT" == literal) {
*result = MT_SEAT;
return true;
+ } else if ("AUDIO" == literal) {
+ *result = MT_AUDIO;
+ return true;
+ } else if ("LIGHT" == literal) {
+ *result = MT_LIGHT;
+ return true;
+ } else if ("HMI_SETTINGS" == literal) {
+ *result = MT_HMI_SETTINGS;
+ return true;
} else {
return false;
}
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 537e40e170..4ef6ed3e10 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
@@ -757,18 +757,18 @@ TEST_F(PolicyManagerImplTest2,
policy_manager_->CheckPermissions(
application_id_, kHmiLevelFull, "SendLocation", input_params, output);
- EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
- EXPECT_TRUE(output.list_of_allowed_params.empty());
- EXPECT_EQ(10u, output.list_of_undefined_params.size());
+ EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
+ EXPECT_TRUE(output.list_of_undefined_params.empty());
+ EXPECT_EQ(10u, output.list_of_allowed_params.size());
ResetOutputList(output);
// Rpc in LIMITED level
policy_manager_->CheckPermissions(
application_id_, kHmiLevelLimited, "SendLocation", input_params, output);
- EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
- EXPECT_TRUE(output.list_of_allowed_params.empty());
- EXPECT_EQ(10u, output.list_of_undefined_params.size());
+ EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
+ EXPECT_TRUE(output.list_of_undefined_params.empty());
+ EXPECT_EQ(10u, output.list_of_allowed_params.size());
ResetOutputList(output);
// Rpc in BACKGROUND level
@@ -778,9 +778,9 @@ TEST_F(PolicyManagerImplTest2,
input_params,
output);
- EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
- EXPECT_TRUE(output.list_of_allowed_params.empty());
- EXPECT_EQ(10u, output.list_of_undefined_params.size());
+ EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
+ EXPECT_TRUE(output.list_of_undefined_params.empty());
+ EXPECT_EQ(10u, output.list_of_allowed_params.size());
// Reset output
ResetOutputList(output);
@@ -845,17 +845,17 @@ TEST_F(PolicyManagerImplTest2,
policy_manager_->CheckPermissions(
application_id_, kHmiLevelFull, "SendLocation", input_params, output);
- EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
- EXPECT_TRUE(output.list_of_allowed_params.empty());
- EXPECT_EQ(10u, output.list_of_undefined_params.size());
+ EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
+ EXPECT_TRUE(output.list_of_undefined_params.empty());
+ EXPECT_EQ(10u, output.list_of_allowed_params.size());
ResetOutputList(output);
// Rpc in LIMITED level
policy_manager_->CheckPermissions(
application_id_, kHmiLevelLimited, "SendLocation", input_params, output);
- EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
- EXPECT_TRUE(output.list_of_allowed_params.empty());
- EXPECT_EQ(10u, output.list_of_undefined_params.size());
+ EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
+ EXPECT_TRUE(output.list_of_undefined_params.empty());
+ EXPECT_EQ(10u, output.list_of_allowed_params.size());
ResetOutputList(output);
// Rpc in BACKGROUND level
@@ -864,9 +864,9 @@ TEST_F(PolicyManagerImplTest2,
"SendLocation",
input_params,
output);
- EXPECT_EQ(::policy::kRpcDisallowed, output.hmi_level_permitted);
- EXPECT_TRUE(output.list_of_allowed_params.empty());
- EXPECT_EQ(10u, output.list_of_undefined_params.size());
+ EXPECT_EQ(::policy::kRpcAllowed, output.hmi_level_permitted);
+ EXPECT_TRUE(output.list_of_undefined_params.empty());
+ EXPECT_EQ(10u, output.list_of_allowed_params.size());
// Reset output
ResetOutputList(output);