diff options
author | dcherniev <dcherniev@github.com> | 2017-04-27 20:06:32 +0300 |
---|---|---|
committer | dcherniev <dcherniev@github.com> | 2017-04-28 10:51:34 +0300 |
commit | 43997044c6cdfd469ee73162269496ab95b3f5d3 (patch) | |
tree | 1058bd94d003174fb08aab90002adbb5ec78d43b | |
parent | 8740e21c7c160de2128722ebf48911ada239584d (diff) | |
download | sdl_core-43997044c6cdfd469ee73162269496ab95b3f5d3.tar.gz |
Add unit test into PolicyManagerImpl
Added unit test related to revoked application into PolicyManagerImpl.
-rw-r--r-- | src/components/policy/policy_external/test/policy_manager_impl_ptu_test.cc | 34 |
1 files changed, 34 insertions, 0 deletions
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 |