summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2017-05-12 09:17:11 -0400
committerGitHub <noreply@github.com>2017-05-12 09:17:11 -0400
commit4f96d7d87aa1c1b2ec772571c373a489f4a3c74d (patch)
tree25cab349d7dee4843772009c48b7cc2d870064e4
parentfc781b520fe1a2a4680b97d3d02646681df8c0d1 (diff)
parent43997044c6cdfd469ee73162269496ab95b3f5d3 (diff)
downloadsdl_core-4f96d7d87aa1c1b2ec772571c373a489f4a3c74d.tar.gz
Merge pull request #1513 from dcherniev/fix/allow_on_hmi_status_notification_for_revoked_application
Allow OnHMIStatus notification for revoked application
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc22
-rw-r--r--src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc34
2 files changed, 45 insertions, 11 deletions
diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc
index 88d810ecc2..68602db712 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -359,6 +359,17 @@ void PolicyManagerImpl::CheckPermissions(const PTString& app_id,
<< " returns true");
}
+ if (cache_->IsApplicationRevoked(app_id)) {
+ // SDL must be able to notify mobile side with its status after app has
+ // been revoked by backend
+ if ("OnHMIStatus" == rpc && "NONE" == hmi_level) {
+ result.hmi_level_permitted = kRpcAllowed;
+ } else {
+ result.hmi_level_permitted = kRpcDisallowed;
+ }
+ return;
+ }
+
const bool known_rpc = rpc_permissions.end() != rpc_permissions.find(rpc);
LOG4CXX_INFO(logger_, "Is known rpc " << known_rpc);
if (!known_rpc) {
@@ -460,17 +471,6 @@ void PolicyManagerImpl::CheckPermissions(const PTString& app_id,
LOG4CXX_DEBUG(logger_, "There are no parameters allowed.");
result.hmi_level_permitted = kRpcDisallowed;
}
-
- if (cache_->IsApplicationRevoked(app_id)) {
- // SDL must be able to notify mobile side with its status after app has
- // been revoked by backend
- if ("OnHMIStatus" == rpc && "NONE" == hmi_level) {
- result.hmi_level_permitted = kRpcAllowed;
- } else {
- result.hmi_level_permitted = kRpcDisallowed;
- }
- return;
- }
}
bool PolicyManagerImpl::ResetUserConsent() {
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 cec844fb85..aa5245825b 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
@@ -141,6 +141,40 @@ TEST_F(PolicyManagerImplTest2, IsAppRevoked_SetRevokedAppID_ExpectAppRevoked) {
EXPECT_TRUE(manager_->IsApplicationRevoked(app_id_1_));
}
+TEST_F(
+ PolicyManagerImplTest2,
+ IsAppRevoked_ReregisterRevokedApp_OnHmiNotificationIsSentWithProperValues) {
+ // Arrange
+ CreateLocalPT(preloadet_pt_filename_);
+
+ manager_->AddApplication(app_id_1_);
+
+ // Check RPC is allowed and OnHMIStatus is sent
+ CheckRpcPermissions("OnHMIStatus", ::policy::kRpcAllowed);
+
+ std::ifstream ifile(kValidSdlPtUpdateJson);
+ Json::Reader reader;
+ std::string json;
+ Json::Value root(Json::objectValue);
+ if (ifile.is_open() && reader.parse(ifile, root, true)) {
+ root["policy_table"]["app_policies"][app_id_1_] = Json::nullValue;
+ json = root.toStyledString();
+ }
+ ifile.close();
+
+ ::policy::BinaryMessage msg(json.begin(), json.end());
+ ASSERT_TRUE(manager_->LoadPT(kFilePtUpdateJson, msg));
+ EXPECT_TRUE(manager_->IsApplicationRevoked(app_id_1_));
+
+ // Re-register application
+ manager_->AddApplication(app_id_1_);
+ EXPECT_NE(typeid(utils::CallNothing),
+ typeid(manager_->AddApplication(app_id_1_)));
+
+ // Check RPC is disallowed and OnHMIStatus is sent
+ CheckRpcPermissions("OnHMIStatus", ::policy::kRpcDisallowed);
+}
+
TEST_F(PolicyManagerImplTest2,
CheckPermissions_SetRevokedAppID_ExpectRPCDisallowed) {
// Arrange