diff options
author | okozlovlux <okozlov@luxoft.com> | 2017-02-20 19:16:07 +0200 |
---|---|---|
committer | okozlovlux <okozlov@luxoft.com> | 2017-05-17 19:27:11 +0300 |
commit | 6a3c65f64fb7e9e5a770476b3f664d57606af33a (patch) | |
tree | bc618e0ff31525d9157b1df098a5149efe557720 /src/components/policy/policy_external/test | |
parent | 8aadc5d6d51b49c381fb89fd4b1fbfebec732cc3 (diff) | |
download | sdl_core-6a3c65f64fb7e9e5a770476b3f664d57606af33a.tar.gz |
Add functionality for External UCS
- added functionality for External UCS: ON by the User
- added UTs for policices External UCS: ON by the User
- added perstistence for external user consent status received from system
Fix issuies for HTTP and PROPRIETARY mode in mock policy handler
- fixed issues in mock policy handler
- fix coding style
Diffstat (limited to 'src/components/policy/policy_external/test')
9 files changed, 737 insertions, 544 deletions
diff --git a/src/components/policy/policy_external/test/generated_code_test.cc b/src/components/policy/policy_external/test/generated_code_test.cc index f9bee95486..15d14e3e3b 100644 --- a/src/components/policy/policy_external/test/generated_code_test.cc +++ b/src/components/policy/policy_external/test/generated_code_test.cc @@ -193,10 +193,11 @@ TEST(PolicyGeneratedCodeTest, EXPECT_TRUE(consent_records.is_valid()); } -TEST(PolicyGeneratedCodeTest, CCSEntity_ConstructionValidationTest) { +TEST(PolicyGeneratedCodeTest, + ExternalConsentEntity_ConstructionValidationTest) { using namespace rpc::policy_table_interface_base; - CCS_Entity empty_entity; + ExternalConsentEntity empty_entity; EXPECT_FALSE(empty_entity.is_valid()); const std::string corrent_entity_type_field = "entityType"; @@ -206,7 +207,7 @@ TEST(PolicyGeneratedCodeTest, CCSEntity_ConstructionValidationTest) { correct_json_entity[corrent_entity_type_field] = 1; correct_json_entity[correct_entity_id_field] = 2; - ExternalConsent_Entity entity_from_correct_json(&correct_json_entity); + ExternalConsentEntity entity_from_correct_json(&correct_json_entity); EXPECT_TRUE(entity_from_correct_json.is_valid()); const std::string wrong_entity_id_field = "entityId"; @@ -215,14 +216,11 @@ TEST(PolicyGeneratedCodeTest, CCSEntity_ConstructionValidationTest) { wrong_json_entity[corrent_entity_type_field] = 1; wrong_json_entity[wrong_entity_id_field] = 2; - ExternalConsent_Entity entity_from_wrong_json(&wrong_json_entity); + ExternalConsentEntity entity_from_wrong_json(&wrong_json_entity); EXPECT_FALSE(entity_from_wrong_json.is_valid()); - ExternalConsent_Entity entity_from_valid_ints(1, 2); + ExternalConsentEntity entity_from_valid_ints(1, 2); EXPECT_TRUE(entity_from_valid_ints.is_valid()); - - CCS_Entity entity_from_wrong_ints(129, 129); - EXPECT_FALSE(entity_from_wrong_ints.is_valid()); } } // namespace policy_test diff --git a/src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h b/src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h index 09a4a0e391..e753751308 100644 --- a/src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h +++ b/src/components/policy/policy_external/test/include/policy/policy_manager_impl_test_base.h @@ -66,10 +66,12 @@ const std::string kHmiLevelBackground = "BACKGROUND"; const std::string kHmiLevelNone = "None"; const std::string kPtuJson = "json/PTU.json"; +const std::string kPtu2Json = "json/PTU2.json"; const std::string kPtu3Json = "json/PTU3.json"; const std::string kValidSdlPtUpdateJson = "json/valid_sdl_pt_update.json"; const std::string kPtuRequestTypeJson = "json/ptu_requestType.json"; const std::string kPtu2RequestTypeJson = "json/ptu2_requestType.json"; +const std::string kDummyUpdateFileName = "DummyName"; } // namespace struct StringsForUpdate { @@ -84,6 +86,7 @@ void CheckIsParamInList(const ::policy::RPCParams& list, const std::string& parameter); Json::Value createPTforLoad(); void InsertRpcParametersInList(::policy::RPCParams& input_params); +policy_table::AppHmiTypes HmiTypes(const policy_table::AppHMIType hmi_type); template <typename T> void SortAndCheckEquality(std::vector<T> first, std::vector<T> second) { @@ -132,7 +135,7 @@ class PolicyManagerImplTest2 : public ::testing::Test { const std::string device_id_2_; const std::string application_id_; const std::string app_storage_folder_; - const std::string preloadet_pt_filename_; + const std::string preloaded_pt_filename_; const bool in_memory_; PolicyManagerImpl* policy_manager_; @@ -188,6 +191,10 @@ class PolicyManagerImplTest2 : public ::testing::Test { void CheckRpcPermissions(const std::string& rpc_name, const PermitResult& expected_permission); + void CheckRpcPermissions(const std::string& app_id, + const std::string& rpc_name, + const policy::PermitResult& out_expected_permission); + // To avoid duplicate arrange of test void AddSetDeviceData(); @@ -196,12 +203,6 @@ class PolicyManagerImplTest2 : public ::testing::Test { void EmulatePTAppRevoked(const std::string& ptu_name); - void TestSetDeviceUSBConnection( - const policy_table::UserSetting usb_transport_status); - - void TestUpdateUSBConnectionStatus( - const policy_table::UserSetting usb_transport_status); - utils::SharedPtr<policy_table::Table> PreconditionForBasicValidateSnapshot(); template <typename ParentType, typename Value> @@ -233,7 +234,7 @@ class PolicyManagerImplTest_RequestTypes : public ::testing::Test { const std::string kAppId; const std::string kDefaultAppId; const std::string app_storage_folder_; - const std::string preloadet_pt_filename_; + const std::string preloaded_pt_filename_; utils::SharedPtr<PolicyManagerImpl> policy_manager_impl_sptr_; NiceMock<MockPolicyListener> listener_; @@ -267,20 +268,20 @@ class PolicyManagerImplTest_RequestTypes : public ::testing::Test { void TearDown() OVERRIDE; }; -class PolicyManagerImplTest_CCS : public PolicyManagerImplTest2 { +class PolicyManagerImplTest_ExternalConsent : public PolicyManagerImplTest2 { public: - PolicyManagerImplTest_CCS() + PolicyManagerImplTest_ExternalConsent() : PolicyManagerImplTest2() , group_name_1_("Group1") , group_name_2_("Group2") , group_name_3_("Group3") {} protected: - void PreconditionCCSPreparePTWithAppGroupsAndConsents(); + void PreconditionExternalConsentPreparePTWithAppGroupsAndConsents(); - void PreconditionCCSPreparePTWithAppPolicy(); + void PreconditionExternalConsentPreparePTWithAppPolicy(); - policy_table::Table PreparePTWithGroupsHavingCCS(); + policy_table::Table PreparePTWithGroupsHavingExternalConsent(); std::string PreparePTUWithNewGroup(const uint32_t type, const uint32_t id, 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 504467d229..8b40b70d41 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 @@ -38,6 +38,7 @@ #include "gtest/gtest.h" #include "policy/policy_manager_impl_test_base.h" +#include "policy/policy_table/types.h" #include "utils/date_time.h" #include "utils/gen_hash.h" @@ -73,13 +74,26 @@ TEST_F(PolicyManagerImplTest, GetGroupsWithSameEntities(external_consent_status)) .WillOnce(Return(group)); + EXPECT_CALL(*cache_manager_, ResetCalculatedPermissions()); + + EXPECT_CALL(*cache_manager_, GetPermissionsForApp(_, _, _)) + .WillOnce(Return(true)) + .WillOnce(Return(true)); + EXPECT_CALL(*cache_manager_, GetFunctionalGroupNames(_)) + .WillOnce(Return(true)) + .WillOnce(Return(true)); + + EXPECT_CALL(*cache_manager_, SetUserPermissionsForApp(_, _)) + .WillOnce(Return(false)); + EXPECT_CALL(*cache_manager_, SetExternalConsentForApp(_)); EXPECT_CALL(*cache_manager_, IsPredataPolicy(_)).WillOnce(Return(false)); EXPECT_CALL(*cache_manager_, IsApplicationRepresented(_)) .WillOnce(Return(true)); EXPECT_EQ(policy_manager_->GetPolicyTableStatus(), "UP_TO_DATE"); - policy_manager_->AddApplication(kDefaultId); + policy_manager_->AddApplication(kDefaultId, + HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_EQ(policy_manager_->GetPolicyTableStatus(), "UP_TO_DATE"); } @@ -128,16 +142,18 @@ TEST_F(PolicyManagerImplTest2, IsAppRevoked_SetRevokedAppID_ExpectAppRevoked) { // Arrange CreateLocalPT(preloaded_pt_filename_); - AppHmiTypes types; - policy_manager_->AddApplication(app_id_1_, types); + policy_manager_->AddApplication(app_id_1_, + HmiTypes(policy_table::AHT_DEFAULT)); - std::ifstream ifile(preloaded_pt_filename_); + 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(); + if (ifile.is_open()) { + if (reader.parse(ifile, root, true)) { + root["policy_table"]["app_policies"][app_id_1_] = Json::nullValue; + json = root.toStyledString(); + } } ifile.close(); @@ -158,7 +174,8 @@ TEST_F(PolicyManagerImplTest2, AppRevokedOne_AppRegistered) { EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded()); ASSERT_TRUE( (policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth")); - policy_manager_->AddApplication(application_id_, hmi_types_); + policy_manager_->AddApplication(application_id_, + HmiTypes(policy_table::AHT_DEFAULT)); // Registration is allowed CheckRpcPermissions("RegisterAppInterface", ::policy::kRpcAllowed); } @@ -170,7 +187,8 @@ TEST_F(PolicyManagerImplTest2, AppRevokedOne_AppRegistered_HMIDefault) { EmulatePTAppRevoked(kPtu2Json); EXPECT_FALSE(policy_manager_->GetCache()->IsPTPreloaded()); - policy_manager_->AddApplication(application_id_, hmi_types_); + policy_manager_->AddApplication(application_id_, + HmiTypes(policy_table::AHT_DEFAULT)); std::string default_hmi; // Default HMI level is NONE @@ -181,7 +199,7 @@ TEST_F(PolicyManagerImplTest2, AppRevokedOne_AppRegistered_HMIDefault) { TEST_F(PolicyManagerImplTest2, CheckPermissions_SetRevokedAppID_ExpectRPCDisallowed) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); policy::CacheManagerInterfaceSPtr cache = policy_manager_->GetCache(); cache->AddDevice(device_id_1_, "Bluetooth"); cache->SetDeviceData(device_id_1_, @@ -196,7 +214,8 @@ TEST_F(PolicyManagerImplTest2, .WillRepeatedly(Return(device_id_1_)); policy_manager_->SetUserConsentForDevice(device_id_1_, true); // Add app from consented device. App will be assigned with default policies - policy_manager_->AddApplication(app_id_1_); + policy_manager_->AddApplication(app_id_1_, + HmiTypes(policy_table::AHT_DEFAULT)); // Check before action policy_table::RpcParameters rpc_parameters; rpc_parameters.hmi_levels.push_back(policy_table::HL_FULL); @@ -238,7 +257,7 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, CheckPermissions_SetAppIDwithPolicies_ExpectRPCAllowed) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); policy_manager_->AddDevice(device_id_1_, "Bluetooth"); policy::CacheManagerInterfaceSPtr cache = policy_manager_->GetCache(); @@ -254,7 +273,8 @@ TEST_F(PolicyManagerImplTest2, .WillRepeatedly(Return(device_id_1_)); policy_manager_->SetUserConsentForDevice(device_id_1_, true); // Add app from consented device. App will be assigned with default policies - policy_manager_->AddApplication(application_id_); + policy_manager_->AddApplication(application_id_, + HmiTypes(policy_table::AHT_MEDIA)); // Emulate PTU with new policies for app added above std::ifstream ifile(kValidSdlPtUpdateJson); Json::Reader reader; @@ -552,7 +572,7 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, GetUpdateUrl) { // Arrange CreateLocalPT(preloaded_pt_filename_); - GetPTU(preloaded_pt_filename_); + GetPTU(kValidSdlPtUpdateJson); // Check expectations const std::string update_url( "http://policies.telematics.ford.com/api/policies"); @@ -568,8 +588,9 @@ TEST_F(PolicyManagerImplTest2, GetCorrectStatus_PTUSuccessful) { EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); // Adding changes PT status - policy_manager_->AddApplication(application_id_, hmi_types_); - EXPECT_EQ("UPDATE_NEEDED", policy_manager_->GetPolicyTableStatus()); + policy_manager_->AddApplication(application_id_, + HmiTypes(policy_table::AHT_DEFAULT)); + EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); // Before load PT we should send notification about start updating policy_manager_->OnUpdateStarted(); // Update @@ -707,7 +728,8 @@ TEST_F(PolicyManagerImplTest2, "Bluetooth")); // Add app from consented device. App will be assigned with default policies - policy_manager_->AddApplication(application_id_); + policy_manager_->AddApplication(application_id_, + HmiTypes(policy_table::AHT_DEFAULT)); std::ifstream ifile("json/sdl_update_pt_2_groups_no_params_in1.json"); Json::Reader reader; @@ -793,7 +815,8 @@ TEST_F(PolicyManagerImplTest2, "Bluetooth")); // Add app from consented device. App will be assigned with default policies - policy_manager_->AddApplication(application_id_); + policy_manager_->AddApplication(application_id_, + HmiTypes(policy_table::AHT_DEFAULT)); std::ifstream ifile( "json/sdl_update_pt_2_groups_no_params_in1_omitted_in2.json"); @@ -890,12 +913,13 @@ TEST_F( PolicyManagerImplTest2, AddApplication_AddExistingApplicationFromDeviceWithoutConsent_ExpectNoUpdateRequired) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); GetPTU(kValidSdlPtUpdateJson); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); // Try to add existing app - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); // Check no update required EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); } @@ -909,14 +933,15 @@ uint32_t GetCurrentDaysCount() { TEST_F(PolicyManagerImplTest2, PTUpdatedAt_DaysNotExceedLimit_ExpectNoUpdateRequired) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); const uint32_t days = GetCurrentDaysCount(); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); GetPTU(kValidSdlPtUpdateJson); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); ::policy::Counters counter = ::policy::Counters::DAYS_AFTER_EPOCH; // Set PT was updated 10 days ago (limit is 30 days for now) @@ -929,13 +954,14 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, PTUpdatedAt_DaysExceedLimit_ExpectUpdateRequired) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); const uint32_t days = GetCurrentDaysCount(); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); GetPTU(kValidSdlPtUpdateJson); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); ::policy::Counters counter = ::policy::Counters::DAYS_AFTER_EPOCH; // Set PT was updated 50 days ago (limit is 30 days for now) @@ -948,13 +974,14 @@ TEST_F( PolicyManagerImplTest2, OnIgnitionCyclesExceeded_SetExceededIgnitionCycles_ExpectUpdateScheduled) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); const uint32_t days = GetCurrentDaysCount(); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); GetPTU(kValidSdlPtUpdateJson); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); // Try to add existing app - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); ::policy::Counters counter = ::policy::Counters::DAYS_AFTER_EPOCH; // Set PT was updated 10 days ago (limit is 30 days for now) @@ -975,7 +1002,7 @@ TEST_F( TEST_F(PolicyManagerImplTest2, GetUserConsentForApp_SetUserConsentForApp_ExpectReceivedConsentCorrect) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); ASSERT_TRUE( (policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth")); ASSERT_TRUE((policy_manager_->GetCache()) @@ -998,7 +1025,8 @@ TEST_F(PolicyManagerImplTest2, policy_manager_->SetUserConsentForDevice(device_id_2_, true); EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); GetPTU(kValidSdlPtUpdateJson); ::policy::PermissionConsent perm_consent; @@ -1040,8 +1068,9 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, CanAppKeepContext_SetPoliciesForAppUpdated_ExpectAppCanKeepContext) { // Arrange - CreateLocalPT(preloadet_pt_filename_); - policy_manager_->AddApplication(app_id_2_); + CreateLocalPT(preloaded_pt_filename_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); GetPTU(kValidSdlPtUpdateJson); // Check keep context in updated policies for app EXPECT_TRUE(policy_manager_->CanAppKeepContext(app_id_2_)); @@ -1050,8 +1079,9 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, CanAppStealFocus_SetPoliciesForAppUpdated_ExpectAppCanStealFocus) { // Arrange - CreateLocalPT(preloadet_pt_filename_); - policy_manager_->AddApplication(app_id_2_); + CreateLocalPT(preloaded_pt_filename_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); GetPTU(kValidSdlPtUpdateJson); // Check keep context in updated policies for app EXPECT_TRUE(policy_manager_->CanAppKeepContext(app_id_2_)); @@ -1060,7 +1090,7 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, GetVehicleInfo_SetVehicleInfo_ExpectReceivedInfoCorrect) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); GetPTU(kValidSdlPtUpdateJson); utils::SharedPtr<policy_table::Table> pt = (policy_manager_->GetCache())->GetPT(); @@ -1079,7 +1109,7 @@ TEST_F( PolicyManagerImplTest2, GetPermissionsForApp_SetUserConsentForApp_ExpectReceivedPermissionsCorrect) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); ASSERT_TRUE( (policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth")); @@ -1102,7 +1132,8 @@ TEST_F( policy_manager_->SetUserConsentForDevice(device_id_2_, true); EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); GetPTU(kValidSdlPtUpdateJson); ::policy::PermissionConsent perm_consent; @@ -1145,9 +1176,10 @@ TEST_F( PolicyManagerImplTest2, GetAppRequestTypes_AddApp_UpdateAppPolicies_ExpectReceivedRequestTypesCorrect) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); - policy_manager_->AddApplication(app_id_3_); + policy_manager_->AddApplication(app_id_3_, + HmiTypes(policy_table::AHT_DEFAULT)); ::policy::StringArray app_requests = policy_manager_->GetAppRequestTypes(app_id_3_); EXPECT_EQ(1u, app_requests.size()); @@ -1168,7 +1200,7 @@ TEST_F( PolicyManagerImplTest2, HertBeatTimeout_AddApp_UpdateAppPolicies_ExpectReceivedHertBeatTimeoutCorrect) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); utils::SharedPtr<policy_table::Table> pt = (policy_manager_->GetCache())->GetPT(); ::policy_table::PolicyTableType type1 = @@ -1181,7 +1213,8 @@ TEST_F( pt->ReportErrors(&report); } // Add new app - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); uint32_t result = policy_manager_->HeartBeatTimeout(app_id_2_); // By default hertbeat timeout is 0 EXPECT_EQ(0u, result); @@ -1207,7 +1240,7 @@ TEST_F( TEST_F(PolicyManagerImplTest2, RemoveAppConsentForGroup_SetUserConsentForApp_ExpectAppConsentDeleted) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); ASSERT_TRUE( (policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth")); ASSERT_TRUE((policy_manager_->GetCache()) @@ -1229,7 +1262,8 @@ TEST_F(PolicyManagerImplTest2, policy_manager_->SetUserConsentForDevice(device_id_2_, true); EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); GetPTU(kValidSdlPtUpdateJson); ::policy::PermissionConsent perm_consent; @@ -1296,7 +1330,7 @@ TEST_F(PolicyManagerImplTest2, const std::string section_name = app_id_2_; // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); // Setting device consent to 'true' in order to have defult application // permissions, request type etc. @@ -1305,7 +1339,8 @@ TEST_F(PolicyManagerImplTest2, policy_manager_->SetUserConsentForDevice(device_id_1_, true); // Add app - policy_manager_->AddApplication(section_name); + policy_manager_->AddApplication(section_name, + HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_CALL(listener_, OnPendingPermissionChange(section_name)).Times(2); // PTU has single invalid RequestTypes, which must be dropped and replaced @@ -1354,7 +1389,7 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, InitPT_LoadPT_ExpectIncrementedCountOfSamePrompts) { // Initializing policy_table - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); policy_table::FunctionalGroupings functional_groupings; GetFunctionalGroupingsFromManager(functional_groupings); @@ -1387,7 +1422,7 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, LoadPT_UpdatePT_ChangingCountsOfDifferentUserConsentPrompts) { // Initializing policy_table - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); // First update of policy table GetPTU("json/sdl_pt_first_update.json"); @@ -1438,7 +1473,7 @@ TEST_F(PolicyManagerImplTest_RequestTypes, TEST_F(PolicyManagerImplTest_RequestTypes, LoadPT_InvalidRequestTypeBetweenCorectValuesInPTU_EraseInvalidValue) { // Refresh policy table with invalid RequestType in application - RefreshPT(preloadet_pt_filename_, kJsonFiles[1]); + RefreshPT(preloaded_pt_filename_, kJsonFiles[1]); // Correct of Request Types policy_table::RequestTypes correct_types; correct_types.push_back(policy_table::RequestType::RT_HTTP); @@ -1461,7 +1496,7 @@ TEST_F( TEST_F(PolicyManagerImplTest_RequestTypes, LoadPT_RequestTypeArrayHaveNoOneValues_AvalibleAllRequestTypes) { // Refresh policy table with invalid RequestType in application - RefreshPT(preloadet_pt_filename_, kJsonFiles[3]); + RefreshPT(preloaded_pt_filename_, kJsonFiles[3]); // Get <app_id> Request Types policy_table::RequestTypes received_types = @@ -1523,7 +1558,7 @@ TEST_F(PolicyManagerImplTest_RequestTypes, policy_table::RequestTypes correct_types = CreateDefaultAppPTURequestValues(); // Load valid values for RequestType - RefreshPT(preloadet_pt_filename_, kJsonFiles[7]); + RefreshPT(preloaded_pt_filename_, kJsonFiles[7]); // Get Request Types for "<default>" policy_table::RequestTypes received_types = @@ -1540,7 +1575,7 @@ TEST_F( CreateDefaultAppDatabaseRequestValues(); // Load RequestType with invalid values - RefreshPT(preloadet_pt_filename_, kJsonFiles[8]); + RefreshPT(preloaded_pt_filename_, kJsonFiles[8]); // Get Request Types for "<default>" policy_table::RequestTypes received_types = @@ -1552,7 +1587,7 @@ TEST_F( TEST_F(PolicyManagerImplTest_RequestTypes, LoadPT_PTDefaultAppEmptyRequestTypeValues_RequestTypeValueEmpty) { // Load RequestType with empty values - RefreshPT(preloadet_pt_filename_, kJsonFiles[9]); + RefreshPT(preloaded_pt_filename_, kJsonFiles[9]); // Get Request Types for "<default>" policy_table::RequestTypes received_types = @@ -1570,7 +1605,7 @@ TEST_F(PolicyManagerImplTest_RequestTypes, CreateDefaultAppDatabaseRequestValues(); // Load omitted RequestType values - RefreshPT(preloadet_pt_filename_, kJsonFiles[10]); + RefreshPT(preloaded_pt_filename_, kJsonFiles[10]); // Get Request Types for "<default>" policy_table::RequestTypes received_types = @@ -1586,7 +1621,7 @@ TEST_F( policy_table::RequestTypes correct_types = CreateDefaultAppPTURequestValues(); // Load RequestType with one invalid value - RefreshPT(preloadet_pt_filename_, kJsonFiles[11]); + RefreshPT(preloaded_pt_filename_, kJsonFiles[11]); // Get Request Types for "<default>" policy_table::RequestTypes received_types = @@ -1602,7 +1637,7 @@ TEST_F(PolicyManagerImplTest_RequestTypes, CreatePreDataConsentAppPTURequestValues(); // Load valid values for RequestType - RefreshPT(preloadet_pt_filename_, kJsonFiles[12]); + RefreshPT(preloaded_pt_filename_, kJsonFiles[12]); // Get Request Types for "<pre_DataConsent>" policy_table::RequestTypes received_types = @@ -1618,42 +1653,28 @@ TEST_F( policy_table::RequestTypes correct_types; correct_types.push_back(policy_table::RequestType::RT_HTTP); - ON_CALL(listener_, OnCurrentDeviceIdUpdateRequired(_)) - .WillByDefault(Return(device_id)); - - utils::SharedPtr<Table> pt = (policy_manager_->GetCache())->GetPT(); + // Load RequestType with invalid values + RefreshPT(preloaded_pt_filename_, kJsonFiles[13]); // Get Request Types for "<pre_DataConsent>" policy_table::RequestTypes received_types = GetRequestTypesForApplication(policy::kPreDataConsentId); - const DeviceData& device_data = *pt->policy_table.device_data; + CompareRequestTypesContainers(correct_types, received_types); } TEST_F(PolicyManagerImplTest_RequestTypes, LoadPT_PTPreDataConsentAppEmptyRequestTypeValues_RequestTypeValueEmpty) { // Load RequestType with empty values - RefreshPT(preloadet_pt_filename_, kJsonFiles[14]); + RefreshPT(preloaded_pt_filename_, kJsonFiles[14]); - EXPECT_EQ(1u, device_data.size()); - - const DeviceData::const_iterator dev_data_iter = device_data.find(device_id); - EXPECT_TRUE(device_data.end() != dev_data_iter); - - UserConsentRecords::const_iterator it_device_consent = - dev_data_iter->second.user_consent_records->find(device); - - EXPECT_TRUE(dev_data_iter->second.user_consent_records->end() != - it_device_consent); - - const ConsentRecords& parameters = it_device_consent->second; - const Json::Value time_stamp = (parameters.time_stamp).ToJsonValue(); - EXPECT_EQ(device, it_device_consent->first); - - const bool time_stamp_result = CheckPolicyTimeStamp(time_stamp.asString()); + // Get Request Types for "<pre_DataConsent>" + policy_table::RequestTypes received_types = + GetRequestTypesForApplication(policy::kPreDataConsentId); - EXPECT_TRUE(time_stamp_result); - EXPECT_EQ(DeviceConsent::kDeviceAllowed, device_consent); + // Expect + const size_t received_size = received_types.size(); + EXPECT_EQ(0u, received_size); } TEST_F( @@ -1664,7 +1685,7 @@ TEST_F( correct_types.push_back(policy_table::RequestType::RT_HTTP); // Load omitted RequestType values - RefreshPT(preloadet_pt_filename_, kJsonFiles[15]); + RefreshPT(preloaded_pt_filename_, kJsonFiles[15]); // Get Request Types for "<pre_DataConsent>" policy_table::RequestTypes received_types = @@ -1681,7 +1702,7 @@ TEST_F( CreatePreDataConsentAppPTURequestValues(); // Load RequestType with one invalid value - RefreshPT(preloadet_pt_filename_, kJsonFiles[16]); + RefreshPT(preloaded_pt_filename_, kJsonFiles[16]); // Get Request Types for "<pre_DataConsent>" policy_table::RequestTypes received_types = diff --git a/src/components/policy/policy_external/test/policy_manager_impl_snapshot_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_snapshot_test.cc index 050630514c..e666ac82de 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_snapshot_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_snapshot_test.cc @@ -50,9 +50,9 @@ TEST_F(PolicyManagerImplTest2, UpdatedPreloadedPT_ExpectLPT_IsUpdated) { new_data.new_field_name_ = "Notifications-"; CreateNewRandomData(new_data); // Create Initial LocalPT from preloadedPT - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); // Update preloadedPT - std::ifstream ifile(preloadet_pt_filename_); + std::ifstream ifile(preloaded_pt_filename_); Json::Reader reader; Json::Value root(Json::objectValue); @@ -72,7 +72,7 @@ TEST_F(PolicyManagerImplTest2, UpdatedPreloadedPT_ExpectLPT_IsUpdated) { ifile.close(); Json::StyledStreamWriter writer; - std::ofstream ofile(preloadet_pt_filename_); + std::ofstream ofile(preloaded_pt_filename_); writer.write(ofile, root); ofile.flush(); ofile.close(); @@ -80,7 +80,7 @@ TEST_F(PolicyManagerImplTest2, UpdatedPreloadedPT_ExpectLPT_IsUpdated) { // Make PolicyManager to update LocalPT policy::CacheManagerInterfaceSPtr cache = policy_manager_->GetCache(); EXPECT_TRUE( - policy_manager_->InitPT(preloadet_pt_filename_, &policy_settings_)); + policy_manager_->InitPT(preloaded_pt_filename_, &policy_settings_)); EXPECT_TRUE(cache->IsPTPreloaded()); // Arrange @@ -117,7 +117,7 @@ TEST_F(PolicyManagerImplTest2, UpdatedPreloadedPT_ExpectLPT_IsUpdated) { TEST_F(PolicyManagerImplTest2, SetSystemLanguage_ExpectSystemLanguageSetSuccessfully) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); policy_manager_->SetSystemLanguage("it-it"); utils::SharedPtr<policy_table::Table> pt = (policy_manager_->GetCache())->GetPT(); @@ -127,7 +127,7 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, SetVINValue_ExpectVINSetSuccessfully) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); std::string vin_code("1FAPP6242VH100001"); policy_manager_->SetVINValue(vin_code); utils::SharedPtr<policy_table::Table> pt = @@ -138,7 +138,7 @@ TEST_F(PolicyManagerImplTest2, SetVINValue_ExpectVINSetSuccessfully) { TEST_F(PolicyManagerImplTest2, SetSystemInfo_ExpectSystemInfoSetSuccessfully) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); policy_manager_->SetSystemInfo("4.1.3.B_EB355B", "WAEGB", "ru-ru"); policy::CacheManagerInterfaceSPtr cache = policy_manager_->GetCache(); utils::SharedPtr<policy_table::Table> pt = cache->GetPT(); @@ -152,7 +152,7 @@ TEST_F(PolicyManagerImplTest2, SetSystemInfo_ExpectSystemInfoSetSuccessfully) { TEST_F(PolicyManagerImplTest2, CleanUnpairedDevice_ExpectDevicesDeleted) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); // Add first device ::policy::DeviceInfo dev_info1; dev_info1.hardware = "hardware IPX"; @@ -262,9 +262,9 @@ TEST_F( const std::string& app_id = application_id_; // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); // Add app - policy_manager_->AddApplication(app_id, hmi_types_); + policy_manager_->AddApplication(app_id, HmiTypes(policy_table::AHT_DEFAULT)); // Check app gets RequestTypes from pre_DataConsent of app_policies // section pt_request_types_ = policy_manager_->GetAppRequestTypes(app_id); diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_test.cc index d260e16922..3890bcb9e7 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_test.cc @@ -165,7 +165,7 @@ TEST_F(PolicyManagerImplTest, LoadPT_SetPT_PTIsLoaded) { TEST_F(PolicyManagerImplTest2, KmsChanged_SetExceededKms_ExpectCorrectSchedule) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); ::policy::Counters counter = ::policy::Counters::KILOMETERS; policy_manager_->PTUpdatedAt(counter, 50000); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); @@ -179,7 +179,7 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, ForcePTExchange_ExpectUpdateNeeded) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); // Force OT Exchange policy_manager_->ForcePTExchange(); @@ -189,7 +189,7 @@ TEST_F(PolicyManagerImplTest2, ForcePTExchange_ExpectUpdateNeeded) { TEST_F(PolicyManagerImplTest2, OnSystemReady) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); // Check EXPECT_CALL(listener_, OnSystemInfoUpdateRequired()); policy_manager_->OnSystemReady(); @@ -197,7 +197,7 @@ TEST_F(PolicyManagerImplTest2, OnSystemReady) { TEST_F(PolicyManagerImplTest2, ResetRetrySequence) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); policy_manager_->ResetRetrySequence(); EXPECT_EQ("UPDATE_NEEDED", policy_manager_->GetPolicyTableStatus()); policy_manager_->OnUpdateStarted(); @@ -206,7 +206,7 @@ TEST_F(PolicyManagerImplTest2, ResetRetrySequence) { TEST_F(PolicyManagerImplTest2, NextRetryTimeout_ExpectTimeoutsFromPT) { // Arrange - std::ifstream ifile(preloadet_pt_filename_); + std::ifstream ifile(preloaded_pt_filename_); Json::Reader reader; Json::Value root(Json::objectValue); if (ifile.is_open() && reader.parse(ifile, root, true)) { @@ -214,7 +214,7 @@ TEST_F(PolicyManagerImplTest2, NextRetryTimeout_ExpectTimeoutsFromPT) { seconds_between_retries = root["policy_table"]["module_config"]["seconds_between_retries"]; uint32_t size = seconds_between_retries.size(); - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); for (uint32_t i = 0; i < size; ++i) { EXPECT_EQ(seconds_between_retries[i], policy_manager_->NextRetryTimeout()); @@ -224,7 +224,7 @@ TEST_F(PolicyManagerImplTest2, NextRetryTimeout_ExpectTimeoutsFromPT) { TEST_F(PolicyManagerImplTest2, TimeOutExchange) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); // Check value taken from PT EXPECT_EQ(70000u, policy_manager_->TimeoutExchangeMSec()); } @@ -277,7 +277,7 @@ TEST_F(PolicyManagerImplTest, ResetUserConsent_ResetOnlyOnce) { TEST_F(PolicyManagerImplTest2, GetPolicyTableStatus_ExpectUpToDate) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); // Check EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); } @@ -295,7 +295,7 @@ TEST_F(PolicyManagerImplTest, TEST_F(PolicyManagerImplTest2, RetrySequenceDelaysSeconds_Expect_CorrectValues) { // Arrange - std::ifstream ifile(preloadet_pt_filename_); + std::ifstream ifile(preloaded_pt_filename_); Json::Reader reader; Json::Value root(Json::objectValue); if (ifile.is_open() && reader.parse(ifile, root, true)) { @@ -303,7 +303,7 @@ TEST_F(PolicyManagerImplTest2, seconds_between_retries = root["policy_table"]["module_config"]["seconds_between_retries"]; uint32_t size = seconds_between_retries.size(); - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); std::vector<int> delaySecs = policy_manager_->RetrySequenceDelaysSeconds(); // Check ASSERT_EQ(size, delaySecs.size()); @@ -316,7 +316,7 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, OnExceededTimeout_GetPolicyTableStatus_ExpectUpdateNeeded) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); policy_manager_->ForcePTExchange(); policy_manager_->OnExceededTimeout(); // Check @@ -339,21 +339,22 @@ TEST_F(PolicyManagerImplTest, MarkUnpairedDevice) { TEST_F(PolicyManagerImplTest2, GetCurrentDeviceId) { // Arrange - EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)); + EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)).Times(1); EXPECT_EQ("", policy_manager_->GetCurrentDeviceId(app_id_2_)); } -TEST_F(PolicyManagerImplTest_CCS, - CCS_SetCCSStatusWhileAppExists_ExpectUserConsentsUpdateForApp) { +TEST_F( + PolicyManagerImplTest_ExternalConsent, + ExternalConsent_SetExternalConsentStatusWhileAppExists_ExpectUserConsentsUpdateForApp) { using namespace policy_table; using namespace rpc; - PreconditionCCSPreparePTWithAppGroupsAndConsents(); + PreconditionExternalConsentPreparePTWithAppGroupsAndConsents(); utils::SharedPtr<policy_table::Table> pt = policy_manager_->GetCache()->GetPT(); - // Checking groups consents before setting CCS status + // Checking groups consents before setting ExternalConsent status const policy_table::DeviceData::const_iterator device_data = pt->policy_table.device_data->find(device_id_1_); @@ -384,17 +385,17 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_FALSE(updated_consent_records->second.consent_groups->end() != group_3); - // Act - setting new CCS status - CCSStatus status; - status.insert(CCSStatusItem(type_1_, id_1_, kStatusOn)); - status.insert(CCSStatusItem(type_2_, id_2_, kStatusOn)); - status.insert(CCSStatusItem(type_3_, id_3_, kStatusOn)); + // Act - setting new ExternalConsent status + ExternalConsentStatus status; + status.insert(ExternalConsentStatusItem(type_1_, id_1_, kStatusOn)); + status.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOn)); + status.insert(ExternalConsentStatusItem(type_3_, id_3_, kStatusOn)); EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)); - EXPECT_TRUE(policy_manager_->SetCCSStatus(status)); + EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status)); - // Checking groups consent after setting CCS status + // Checking groups consent after setting ExternalConsent status EXPECT_EQ(Boolean(false), group_1->second); EXPECT_EQ(Boolean(true), group_2->second); @@ -406,18 +407,19 @@ TEST_F(PolicyManagerImplTest_CCS, updated_group_3); } -TEST_F(PolicyManagerImplTest_CCS, - CCS_SetCCSStatusWhileAppExists_ExpectCCSConsentsUpdateForApp) { +TEST_F( + PolicyManagerImplTest_ExternalConsent, + ExternalConsent_SetExternalConsentStatusWhileAppExists_ExpectExternalConsentUpdateForApp) { using namespace policy_table; using namespace rpc; - PreconditionCCSPreparePTWithAppGroupsAndConsents(); + PreconditionExternalConsentPreparePTWithAppGroupsAndConsents(); // Act utils::SharedPtr<policy_table::Table> pt = policy_manager_->GetCache()->GetPT(); - // Checking CCS consents before setting new CCS status + // Checking ExternalConsent consents before setting new ExternalConsent status policy_table::DeviceData::const_iterator updated_device_data = pt->policy_table.device_data->find(device_id_1_); @@ -429,21 +431,22 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_TRUE(updated_device_data->second.user_consent_records->end() != updated_consent_records); - EXPECT_TRUE(updated_consent_records->second.ccs_consent_groups->empty()); + EXPECT_TRUE( + updated_consent_records->second.external_consent_status_groups->empty()); - // Act - setting new CCS status - CCSStatus status; - status.insert(CCSStatusItem(type_1_, id_1_, kStatusOn)); - status.insert(CCSStatusItem(type_2_, id_2_, kStatusOn)); - status.insert(CCSStatusItem(type_3_, id_3_, kStatusOn)); + // Act - setting new ExternalConsent status + ExternalConsentStatus status; + status.insert(ExternalConsentStatusItem(type_1_, id_1_, kStatusOn)); + status.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOn)); + status.insert(ExternalConsentStatusItem(type_3_, id_3_, kStatusOn)); EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)); - EXPECT_TRUE(policy_manager_->SetCCSStatus(status)); + EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status)); - // Checking CCS consents after setting new CCS status - const ConsentGroups& ccs_consents = - *updated_consent_records->second.ccs_consent_groups; + // Checking ExternalConsent consents after setting new ExternalConsent status + const ConsentGroups& external_consent_statuss = + *updated_consent_records->second.external_consent_status_groups; const ApplicationPolicies::const_iterator app_parameters = pt->policy_table.app_policies_section.apps.find(app_id_1_); @@ -451,41 +454,43 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_TRUE(pt->policy_table.app_policies_section.apps.end() != app_parameters); - EXPECT_EQ(app_parameters->second.groups.size(), ccs_consents.size()); + EXPECT_EQ(app_parameters->second.groups.size(), + external_consent_statuss.size()); const ConsentGroups::const_iterator updated_group_1 = - ccs_consents.find(group_name_1_); + external_consent_statuss.find(group_name_1_); - EXPECT_TRUE(ccs_consents.end() != updated_group_1); + EXPECT_TRUE(external_consent_statuss.end() != updated_group_1); const ConsentGroups::const_iterator updated_group_2 = - ccs_consents.find(group_name_2_); + external_consent_statuss.find(group_name_2_); - EXPECT_TRUE(ccs_consents.end() != updated_group_2); + EXPECT_TRUE(external_consent_statuss.end() != updated_group_2); EXPECT_EQ(Boolean(false), updated_group_1->second); EXPECT_EQ(Boolean(true), updated_group_2->second); } -TEST_F(PolicyManagerImplTest_CCS, - CCS_SetCCSStatusNewAppAddedAfterward_ExpectCCSConsentsUpdateForApp) { +TEST_F( + PolicyManagerImplTest_ExternalConsent, + ExternalConsent_SetExternalConsentStatusNewAppAddedAfterward_ExpectExternalConsentUpdateForApp) { using namespace policy_table; using namespace rpc; - PreconditionCCSPreparePTWithAppPolicy(); + PreconditionExternalConsentPreparePTWithAppPolicy(); // Act utils::SharedPtr<policy_table::Table> pt = policy_manager_->GetCache()->GetPT(); - CCSStatus status; - status.insert(CCSStatusItem(type_1_, id_1_, kStatusOn)); - status.insert(CCSStatusItem(type_2_, id_2_, kStatusOn)); - status.insert(CCSStatusItem(type_3_, id_3_, kStatusOn)); + ExternalConsentStatus status; + status.insert(ExternalConsentStatusItem(type_1_, id_1_, kStatusOn)); + status.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOn)); + status.insert(ExternalConsentStatusItem(type_3_, id_3_, kStatusOn)); - EXPECT_TRUE(policy_manager_->SetCCSStatus(status)); + EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status)); - // Checking CCS consents after setting new CCS status + // Checking ExternalConsent consents after setting new ExternalConsent status policy_table::DeviceData::const_iterator updated_device_data = pt->policy_table.device_data->find(device_id_1_); @@ -495,9 +500,10 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_)) .WillRepeatedly(Return(device_id_1_)); - policy_manager_->AddApplication(app_id_1_, AppHmiTypes()); + policy_manager_->AddApplication(app_id_1_, + HmiTypes(policy_table::AHT_DEFAULT)); - // Check CCS consents for application + // Check ExternalConsent consents for application updated_device_data = pt->policy_table.device_data->find(device_id_1_); EXPECT_TRUE(pt->policy_table.device_data->end() != updated_device_data); @@ -505,8 +511,8 @@ TEST_F(PolicyManagerImplTest_CCS, UserConsentRecords::const_iterator updated_consent_records = updated_device_data->second.user_consent_records->find(app_id_1_); - const ConsentGroups& ccs_consents = - *updated_consent_records->second.ccs_consent_groups; + const ConsentGroups& external_consent_statuss = + *updated_consent_records->second.external_consent_status_groups; ApplicationPolicies::const_iterator app_parameters = pt->policy_table.app_policies_section.apps.find(app_id_1_); @@ -516,41 +522,43 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_TRUE(pt->policy_table.app_policies_section.apps.end() != app_parameters); - EXPECT_EQ(app_parameters->second.groups.size(), ccs_consents.size()); + EXPECT_EQ(app_parameters->second.groups.size(), + external_consent_statuss.size()); ConsentGroups::const_iterator updated_group_1 = - ccs_consents.find(group_name_1_); + external_consent_statuss.find(group_name_1_); - EXPECT_TRUE(ccs_consents.end() != updated_group_1); + EXPECT_TRUE(external_consent_statuss.end() != updated_group_1); ConsentGroups::const_iterator updated_group_2 = - ccs_consents.find(group_name_2_); + external_consent_statuss.find(group_name_2_); - EXPECT_TRUE(ccs_consents.end() != updated_group_2); + EXPECT_TRUE(external_consent_statuss.end() != updated_group_2); EXPECT_EQ(Boolean(false), updated_group_1->second); EXPECT_EQ(Boolean(true), updated_group_2->second); } -TEST_F(PolicyManagerImplTest_CCS, - CCS_SetCCSStatusNewAppAddedAfterward_ExpectUserConsentsUpdateForApp) { +TEST_F( + PolicyManagerImplTest_ExternalConsent, + ExternalConsent_SetExternalConsentStatusNewAppAddedAfterward_ExpectUserConsentsUpdateForApp) { using namespace policy_table; using namespace rpc; - PreconditionCCSPreparePTWithAppPolicy(); + PreconditionExternalConsentPreparePTWithAppPolicy(); // Act utils::SharedPtr<policy_table::Table> pt = policy_manager_->GetCache()->GetPT(); - CCSStatus status; - status.insert(CCSStatusItem(type_1_, id_1_, kStatusOn)); - status.insert(CCSStatusItem(type_2_, id_2_, kStatusOn)); - status.insert(CCSStatusItem(type_3_, id_3_, kStatusOn)); + ExternalConsentStatus status; + status.insert(ExternalConsentStatusItem(type_1_, id_1_, kStatusOn)); + status.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOn)); + status.insert(ExternalConsentStatusItem(type_3_, id_3_, kStatusOn)); - EXPECT_TRUE(policy_manager_->SetCCSStatus(status)); + EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status)); - // Checking CCS consents after setting new CCS status + // Checking ExternalConsent consents after setting new ExternalConsent status policy_table::DeviceData::const_iterator updated_device_data = pt->policy_table.device_data->find(device_id_1_); @@ -560,9 +568,10 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_)) .WillRepeatedly(Return(device_id_1_)); - policy_manager_->AddApplication(app_id_1_, AppHmiTypes()); + policy_manager_->AddApplication(app_id_1_, + HmiTypes(policy_table::AHT_DEFAULT)); - // Checking CCS consents after setting new CCS status + // Checking ExternalConsent consents after setting new ExternalConsent status ApplicationPolicies::const_iterator app_parameters = pt->policy_table.app_policies_section.apps.find(app_id_1_); @@ -579,56 +588,59 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_TRUE(updated_device_data->second.user_consent_records->end() != updated_consent_records); - const ConsentGroups& ccs_consents = + const ConsentGroups& external_consent_statuss = *updated_consent_records->second.consent_groups; - EXPECT_EQ(app_parameters->second.groups.size(), ccs_consents.size()); + EXPECT_EQ(app_parameters->second.groups.size(), + external_consent_statuss.size()); ConsentGroups::const_iterator updated_group_1 = - ccs_consents.find(group_name_1_); + external_consent_statuss.find(group_name_1_); - EXPECT_TRUE(ccs_consents.end() != updated_group_1); + EXPECT_TRUE(external_consent_statuss.end() != updated_group_1); ConsentGroups::const_iterator updated_group_2 = - ccs_consents.find(group_name_2_); + external_consent_statuss.find(group_name_2_); - EXPECT_TRUE(ccs_consents.end() != updated_group_2); + EXPECT_TRUE(external_consent_statuss.end() != updated_group_2); EXPECT_EQ(Boolean(false), updated_group_1->second); EXPECT_EQ(Boolean(true), updated_group_2->second); } -TEST_F(PolicyManagerImplTest_CCS, - CCS_SetCCSStatusNewAppPromotedAfterward_ExpectUserConsentsUpdateForApp) { +TEST_F( + PolicyManagerImplTest_ExternalConsent, + ExternalConsent_SetExternalConsentStatusNewAppPromotedAfterward_ExpectUserConsentsUpdateForApp) { using namespace policy_table; using namespace rpc; CreateLocalPT(preloaded_pt_filename_); - Table t = PreparePTWithGroupsHavingCCS(); + Table t = PreparePTWithGroupsHavingExternalConsent(); EXPECT_TRUE(policy_manager_->GetCache()->ApplyUpdate(t)); - EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)).Times(AtLeast(2)); + EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)); EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_)) .WillOnce(Return(device_id_1_)) // registered .WillOnce(Return("")) // not registered .WillRepeatedly(Return(device_id_1_)); // again registered // First register w/o app having groups to consent - policy_manager_->AddApplication(app_id_1_, AppHmiTypes()); + policy_manager_->AddApplication(app_id_1_, + HmiTypes(policy_table::AHT_DEFAULT)); // Act utils::SharedPtr<policy_table::Table> pt = policy_manager_->GetCache()->GetPT(); - CCSStatus status; - status.insert(CCSStatusItem(type_1_, id_1_, kStatusOn)); - status.insert(CCSStatusItem(type_2_, id_2_, kStatusOn)); - status.insert(CCSStatusItem(type_3_, id_3_, kStatusOn)); + ExternalConsentStatus status; + status.insert(ExternalConsentStatusItem(type_1_, id_1_, kStatusOn)); + status.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOn)); + status.insert(ExternalConsentStatusItem(type_3_, id_3_, kStatusOn)); - EXPECT_TRUE(policy_manager_->SetCCSStatus(status)); + EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status)); - // Checking CCS consents after setting new CCS status + // Checking ExternalConsent consents after setting new ExternalConsent status policy_table::DeviceData::const_iterator updated_device_data = pt->policy_table.device_data->find(device_id_1_); @@ -646,9 +658,10 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_TRUE(policy_manager_->GetCache()->ApplyUpdate(t)); // Second time register w/ app having groups to consent - policy_manager_->AddApplication(app_id_1_, AppHmiTypes()); + policy_manager_->AddApplication(app_id_1_, + HmiTypes(policy_table::AHT_DEFAULT)); - // Checking CCS consents after setting new CCS status + // Checking ExternalConsent consents after setting new ExternalConsent status ApplicationPolicies::const_iterator app_parameters = pt->policy_table.app_policies_section.apps.find(app_id_1_); @@ -665,56 +678,59 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_TRUE(updated_device_data->second.user_consent_records->end() != updated_consent_records); - const ConsentGroups& ccs_consents = + const ConsentGroups& external_consent_statuss = *updated_consent_records->second.consent_groups; - EXPECT_EQ(app_parameters->second.groups.size(), ccs_consents.size()); + EXPECT_EQ(app_parameters->second.groups.size(), + external_consent_statuss.size()); ConsentGroups::const_iterator updated_group_1 = - ccs_consents.find(group_name_1_); + external_consent_statuss.find(group_name_1_); - EXPECT_TRUE(ccs_consents.end() != updated_group_1); + EXPECT_TRUE(external_consent_statuss.end() != updated_group_1); ConsentGroups::const_iterator updated_group_2 = - ccs_consents.find(group_name_2_); + external_consent_statuss.find(group_name_2_); - EXPECT_TRUE(ccs_consents.end() != updated_group_2); + EXPECT_TRUE(external_consent_statuss.end() != updated_group_2); EXPECT_EQ(Boolean(false), updated_group_1->second); EXPECT_EQ(Boolean(true), updated_group_2->second); } -TEST_F(PolicyManagerImplTest_CCS, - CCS_SetCCSStatusNewAppPromotedAfterward_ExpectCCSConsentsUpdateForApp) { +TEST_F( + PolicyManagerImplTest_ExternalConsent, + ExternalConsent_SetExternalConsentStatusNewAppPromotedAfterward_ExpectExternalConsentUpdateForApp) { using namespace policy_table; using namespace rpc; CreateLocalPT(preloaded_pt_filename_); - Table t = PreparePTWithGroupsHavingCCS(); + Table t = PreparePTWithGroupsHavingExternalConsent(); EXPECT_TRUE(policy_manager_->GetCache()->ApplyUpdate(t)); - EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)).Times(AtLeast(2)); + EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)); EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_)) .WillOnce(Return(device_id_1_)) // registered .WillOnce(Return("")) // not registered .WillRepeatedly(Return(device_id_1_)); // registered again // First register w/o app having groups to consent - policy_manager_->AddApplication(app_id_1_, AppHmiTypes()); + policy_manager_->AddApplication(app_id_1_, + HmiTypes(policy_table::AHT_DEFAULT)); // Act utils::SharedPtr<policy_table::Table> pt = policy_manager_->GetCache()->GetPT(); - CCSStatus status; - status.insert(CCSStatusItem(type_1_, id_1_, kStatusOn)); - status.insert(CCSStatusItem(type_2_, id_2_, kStatusOn)); - status.insert(CCSStatusItem(type_3_, id_3_, kStatusOn)); + ExternalConsentStatus status; + status.insert(ExternalConsentStatusItem(type_1_, id_1_, kStatusOn)); + status.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOn)); + status.insert(ExternalConsentStatusItem(type_3_, id_3_, kStatusOn)); - EXPECT_TRUE(policy_manager_->SetCCSStatus(status)); + EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status)); - // Checking CCS consents after setting new CCS status + // Checking ExternalConsent consents after setting new ExternalConsent status policy_table::DeviceData::const_iterator updated_device_data = pt->policy_table.device_data->find(device_id_1_); @@ -732,9 +748,10 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_TRUE(policy_manager_->GetCache()->ApplyUpdate(t)); // Second time register w/ app having groups to consent - policy_manager_->AddApplication(app_id_1_, AppHmiTypes()); + policy_manager_->AddApplication(app_id_1_, + HmiTypes(policy_table::AHT_DEFAULT)); - // Check CCS consents for application + // Check ExternalConsent consents for application updated_device_data = pt->policy_table.device_data->find(device_id_1_); EXPECT_TRUE(pt->policy_table.device_data->end() != updated_device_data); @@ -742,8 +759,8 @@ TEST_F(PolicyManagerImplTest_CCS, UserConsentRecords::const_iterator updated_consent_records = updated_device_data->second.user_consent_records->find(app_id_1_); - const ConsentGroups& ccs_consents = - *updated_consent_records->second.ccs_consent_groups; + const ConsentGroups& external_consent_statuss = + *updated_consent_records->second.external_consent_status_groups; ApplicationPolicies::const_iterator app_parameters = pt->policy_table.app_policies_section.apps.find(app_id_1_); @@ -753,51 +770,54 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_TRUE(pt->policy_table.app_policies_section.apps.end() != app_parameters); - EXPECT_EQ(app_parameters->second.groups.size(), ccs_consents.size()); + EXPECT_EQ(app_parameters->second.groups.size(), + external_consent_statuss.size()); ConsentGroups::const_iterator updated_group_1 = - ccs_consents.find(group_name_1_); + external_consent_statuss.find(group_name_1_); - EXPECT_TRUE(ccs_consents.end() != updated_group_1); + EXPECT_TRUE(external_consent_statuss.end() != updated_group_1); ConsentGroups::const_iterator updated_group_2 = - ccs_consents.find(group_name_2_); + external_consent_statuss.find(group_name_2_); - EXPECT_TRUE(ccs_consents.end() != updated_group_2); + EXPECT_TRUE(external_consent_statuss.end() != updated_group_2); EXPECT_EQ(Boolean(false), updated_group_1->second); EXPECT_EQ(Boolean(true), updated_group_2->second); } -TEST_F(PolicyManagerImplTest_CCS, - CCS_PTUWithNewGroups_ExpectCCSConsentsUpdateForApp) { +TEST_F(PolicyManagerImplTest_ExternalConsent, + ExternalConsent_PTUWithNewGroups_ExpectExternalConsentUpdateForApp) { using namespace policy_table; using namespace rpc; - PreconditionCCSPreparePTWithAppGroupsAndConsents(); + PreconditionExternalConsentPreparePTWithAppGroupsAndConsents(); const uint32_t type_4 = 6u; const uint32_t id_4 = 7u; const std::string group_name_4 = "NewGroup"; - // CCS status has new group, which is not yet assigned to any application - CCSStatus status; - status.insert(CCSStatusItem(type_1_, id_1_, kStatusOn)); - status.insert(CCSStatusItem(type_2_, id_2_, kStatusOn)); - status.insert(CCSStatusItem(type_4, id_4, kStatusOn)); + // ExternalConsent status has new group, which is not yet assigned to any + // application + ExternalConsentStatus status; + status.insert(ExternalConsentStatusItem(type_1_, id_1_, kStatusOn)); + status.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOn)); + status.insert(ExternalConsentStatusItem(type_4, id_4, kStatusOn)); - EXPECT_TRUE(policy_manager_->SetCCSStatus(status)); + EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status)); - EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)).Times(AtLeast(1)); + EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)).Times(0); EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_)) .WillRepeatedly(Return(device_id_1_)); - policy_manager_->AddApplication(app_id_1_, AppHmiTypes()); + policy_manager_->AddApplication(app_id_1_, + HmiTypes(policy_table::AHT_DEFAULT)); utils::SharedPtr<policy_table::Table> pt = policy_manager_->GetCache()->GetPT(); - // Check CCS consents for application + // Check ExternalConsent consents for application policy_table::DeviceData::const_iterator initial_device_data = pt->policy_table.device_data->find(device_id_1_); @@ -809,20 +829,23 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_TRUE(initial_device_data->second.user_consent_records->end() != initial_consent_records); - const ConsentGroups& ccs_consents = - *initial_consent_records->second.ccs_consent_groups; + const ConsentGroups& external_consent_statuss = + *initial_consent_records->second.external_consent_status_groups; - ConsentGroups::const_iterator group_1 = ccs_consents.find(group_name_1_); + ConsentGroups::const_iterator group_1 = + external_consent_statuss.find(group_name_1_); - EXPECT_TRUE(ccs_consents.end() != group_1); + EXPECT_TRUE(external_consent_statuss.end() != group_1); - ConsentGroups::const_iterator group_2 = ccs_consents.find(group_name_2_); + ConsentGroups::const_iterator group_2 = + external_consent_statuss.find(group_name_2_); - EXPECT_TRUE(ccs_consents.end() != group_2); + EXPECT_TRUE(external_consent_statuss.end() != group_2); - ConsentGroups::const_iterator group_4 = ccs_consents.find(group_name_4); + ConsentGroups::const_iterator group_4 = + external_consent_statuss.find(group_name_4); - EXPECT_FALSE(ccs_consents.end() != group_4); + EXPECT_FALSE(external_consent_statuss.end() != group_4); // Consents for known groups have been done EXPECT_EQ(Boolean(false), group_1->second); @@ -836,15 +859,15 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_TRUE(pt->policy_table.app_policies_section.apps.end() != app_parameters); - EXPECT_EQ(app_parameters->second.groups.size(), ccs_consents.size()); + EXPECT_EQ(app_parameters->second.groups.size(), + external_consent_statuss.size()); const std::string ptu_json = PreparePTUWithNewGroup(type_4, id_4, group_name_4); const BinaryMessage msg(ptu_json.begin(), ptu_json.end()); - ON_CALL(listener_, GetRegisteredLinks()) - .WillByDefault(Return(policy::ApplicationsLinks())); + ON_CALL(listener_, GetRegisteredLinks(_)).WillByDefault(Return()); EXPECT_CALL(listener_, OnCertificateUpdated(_)); @@ -863,20 +886,20 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_TRUE(updated_device_data->second.user_consent_records->end() != updated_consent_records); - const ConsentGroups& updated_ccs_consents = - *updated_consent_records->second.ccs_consent_groups; + const ConsentGroups& updated_external_consent_statuss = + *updated_consent_records->second.external_consent_status_groups; - group_1 = updated_ccs_consents.find(group_name_1_); + group_1 = updated_external_consent_statuss.find(group_name_1_); - EXPECT_TRUE(updated_ccs_consents.end() != group_1); + EXPECT_TRUE(updated_external_consent_statuss.end() != group_1); - group_2 = updated_ccs_consents.find(group_name_2_); + group_2 = updated_external_consent_statuss.find(group_name_2_); - EXPECT_TRUE(updated_ccs_consents.end() != group_2); + EXPECT_TRUE(updated_external_consent_statuss.end() != group_2); - group_4 = updated_ccs_consents.find(group_name_4); + group_4 = updated_external_consent_statuss.find(group_name_4); - EXPECT_TRUE(updated_ccs_consents.end() != group_4); + EXPECT_TRUE(updated_external_consent_statuss.end() != group_4); EXPECT_EQ(Boolean(false), group_1->second); EXPECT_EQ(Boolean(true), group_2->second); @@ -887,37 +910,39 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_TRUE(pt->policy_table.app_policies_section.apps.end() != app_parameters); - EXPECT_EQ(app_parameters->second.groups.size(), ccs_consents.size()); + EXPECT_EQ(app_parameters->second.groups.size(), + external_consent_statuss.size()); } -TEST_F(PolicyManagerImplTest_CCS, - CCS_PTUWithNewGroups_ExpectUserConsentsUpdateForApp) { +TEST_F(PolicyManagerImplTest_ExternalConsent, + ExternalConsent_PTUWithNewGroups_ExpectUserConsentsUpdateForApp) { using namespace policy_table; using namespace rpc; - PreconditionCCSPreparePTWithAppGroupsAndConsents(); + PreconditionExternalConsentPreparePTWithAppGroupsAndConsents(); const uint32_t type_4 = 6u; const uint32_t id_4 = 7u; const std::string group_name_4 = "NewGroup"; - CCSStatus status; - status.insert(CCSStatusItem(type_1_, id_1_, kStatusOn)); - status.insert(CCSStatusItem(type_2_, id_2_, kStatusOn)); - status.insert(CCSStatusItem(type_4, id_4, kStatusOn)); + ExternalConsentStatus status; + status.insert(ExternalConsentStatusItem(type_1_, id_1_, kStatusOn)); + status.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOn)); + status.insert(ExternalConsentStatusItem(type_4, id_4, kStatusOn)); - EXPECT_TRUE(policy_manager_->SetCCSStatus(status)); + EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status)); - EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)).Times(AtLeast(1)); + EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)).Times(0); EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_)) .WillRepeatedly(Return(device_id_1_)); - policy_manager_->AddApplication(app_id_1_, AppHmiTypes()); + policy_manager_->AddApplication(app_id_1_, + HmiTypes(policy_table::AHT_DEFAULT)); utils::SharedPtr<policy_table::Table> pt = policy_manager_->GetCache()->GetPT(); - // Check CCS consents for application + // Check ExternalConsent consents for application policy_table::DeviceData::const_iterator initial_device_data = pt->policy_table.device_data->find(device_id_1_); @@ -962,8 +987,7 @@ TEST_F(PolicyManagerImplTest_CCS, const BinaryMessage msg(ptu_json.begin(), ptu_json.end()); - ON_CALL(listener_, GetRegisteredLinks()) - .WillByDefault(Return(policy::ApplicationsLinks())); + ON_CALL(listener_, GetRegisteredLinks(_)).WillByDefault(Return()); EXPECT_CALL(listener_, OnCertificateUpdated(_)); @@ -1009,18 +1033,19 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_EQ(app_parameters->second.groups.size(), user_consents.size()); } -TEST_F(PolicyManagerImplTest_CCS, - CCS_SetCCSStatusTurnOnThanOff_ExpectCCSConsentsUpdateForApp) { +TEST_F( + PolicyManagerImplTest_ExternalConsent, + ExternalConsent_SetExternalConsentStatusTurnOnThanOff_ExpectExternalConsentUpdateForApp) { using namespace policy_table; using namespace rpc; - PreconditionCCSPreparePTWithAppGroupsAndConsents(); + PreconditionExternalConsentPreparePTWithAppGroupsAndConsents(); // Act utils::SharedPtr<policy_table::Table> pt = policy_manager_->GetCache()->GetPT(); - // Checking CCS consents before setting new CCS status + // Checking ExternalConsent consents before setting new ExternalConsent status policy_table::DeviceData::const_iterator updated_device_data = pt->policy_table.device_data->find(device_id_1_); @@ -1032,21 +1057,22 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_TRUE(updated_device_data->second.user_consent_records->end() != updated_consent_records); - EXPECT_TRUE(updated_consent_records->second.ccs_consent_groups->empty()); + EXPECT_TRUE( + updated_consent_records->second.external_consent_status_groups->empty()); - // Act - setting new CCS status - CCSStatus status_on; - status_on.insert(CCSStatusItem(type_1_, id_1_, kStatusOn)); - status_on.insert(CCSStatusItem(type_2_, id_2_, kStatusOn)); - status_on.insert(CCSStatusItem(type_3_, id_3_, kStatusOn)); + // Act - setting new ExternalConsent status + ExternalConsentStatus status_on; + status_on.insert(ExternalConsentStatusItem(type_1_, id_1_, kStatusOn)); + status_on.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOn)); + status_on.insert(ExternalConsentStatusItem(type_3_, id_3_, kStatusOn)); EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)); - EXPECT_TRUE(policy_manager_->SetCCSStatus(status_on)); + EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status_on)); - // Checking CCS consents after setting new CCS status - const ConsentGroups& ccs_consents = - *updated_consent_records->second.ccs_consent_groups; + // Checking ExternalConsent consents after setting new ExternalConsent status + const ConsentGroups& external_consent_statuss = + *updated_consent_records->second.external_consent_status_groups; ApplicationPolicies::const_iterator app_parameters = pt->policy_table.app_policies_section.apps.find(app_id_1_); @@ -1054,30 +1080,31 @@ TEST_F(PolicyManagerImplTest_CCS, EXPECT_TRUE(pt->policy_table.app_policies_section.apps.end() != app_parameters); - EXPECT_EQ(app_parameters->second.groups.size(), ccs_consents.size()); + EXPECT_EQ(app_parameters->second.groups.size(), + external_consent_statuss.size()); ConsentGroups::const_iterator updated_group_1 = - ccs_consents.find(group_name_1_); + external_consent_statuss.find(group_name_1_); - EXPECT_TRUE(ccs_consents.end() != updated_group_1); + EXPECT_TRUE(external_consent_statuss.end() != updated_group_1); ConsentGroups::const_iterator updated_group_2 = - ccs_consents.find(group_name_2_); + external_consent_statuss.find(group_name_2_); - EXPECT_TRUE(ccs_consents.end() != updated_group_2); + EXPECT_TRUE(external_consent_statuss.end() != updated_group_2); EXPECT_EQ(Boolean(false), updated_group_1->second); EXPECT_EQ(Boolean(true), updated_group_2->second); - // Switching CCS status off - CCSStatus status_off; - status_off.insert(CCSStatusItem(type_1_, id_1_, kStatusOff)); - status_off.insert(CCSStatusItem(type_2_, id_2_, kStatusOff)); - status_off.insert(CCSStatusItem(type_3_, id_3_, kStatusOff)); + // Switching ExternalConsent status off + ExternalConsentStatus status_off; + status_off.insert(ExternalConsentStatusItem(type_1_, id_1_, kStatusOff)); + status_off.insert(ExternalConsentStatusItem(type_2_, id_2_, kStatusOff)); + status_off.insert(ExternalConsentStatusItem(type_3_, id_3_, kStatusOff)); - EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)); + EXPECT_CALL(listener_, OnPermissionsUpdated(app_id_1_, _)).Times(0); - EXPECT_TRUE(policy_manager_->SetCCSStatus(status_on)); + EXPECT_TRUE(policy_manager_->SetExternalConsentStatus(status_on)); EXPECT_EQ(Boolean(true), updated_group_1->second); EXPECT_EQ(Boolean(false), updated_group_2->second); diff --git a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc index a2b2d14cb3..82d958d2d1 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_test_base.cc @@ -192,6 +192,13 @@ void InsertRpcParametersInList(::policy::RPCParams& input_params) { input_params.insert("timeStamp"); input_params.insert("address"); } + +policy_table::AppHmiTypes HmiTypes(const policy_table::AppHMIType hmi_type) { + policy_table::AppHmiTypes hmi_types; + hmi_types.push_back(hmi_type); + return hmi_types; +} + // PolicyManagerImplTest class methods PolicyManagerImplTest::PolicyManagerImplTest() : unpaired_device_id_("08-00-27-CE-76-FE") @@ -201,16 +208,16 @@ PolicyManagerImplTest::PolicyManagerImplTest() void PolicyManagerImplTest::SetUp() { policy_manager_ = new PolicyManagerImpl(); cache_manager_ = new MockCacheManagerInterface(); - manager_->set_cache_manager(cache_manager_); - manager_->set_listener(&listener_); + policy_manager_->set_cache_manager(cache_manager_); + policy_manager_->set_listener(&listener_); - ON_CALL(*cache_manager_, GetCCSStatus()).WillByDefault(Return(CCSStatus())); + ON_CALL(*cache_manager_, GetExternalConsentStatus()) + .WillByDefault(Return(ExternalConsentStatus())); ON_CALL(*cache_manager_, GetGroupsWithSameEntities(_)) - .WillByDefault(Return(GroupsByCCSStatus())); + .WillByDefault(Return(GroupsByExternalConsentStatus())); ON_CALL(*cache_manager_, GetKnownLinksFromPT()) - .WillByDefault(Return(ApplicationsLinks())); - ON_CALL(listener_, GetRegisteredLinks()) - .WillByDefault(Return(policy::ApplicationsLinks())); + .WillByDefault(Return(std::map<std::string, std::string>())); + ON_CALL(listener_, GetRegisteredLinks(_)).WillByDefault(Return()); } void PolicyManagerImplTest::TearDown() { @@ -237,7 +244,7 @@ PolicyManagerImplTest2::PolicyManagerImplTest2() , device_id_2_("08-00-27-CE-76-FE") , application_id_("1234") , app_storage_folder_("storage1") - , preloadet_pt_filename_(kSdlPreloadedPtJson) + , preloaded_pt_filename_(kSdlPreloadedPtJson) , in_memory_(true) , policy_manager_(NULL) , ptu_request_types_size_(0u) @@ -245,8 +252,7 @@ PolicyManagerImplTest2::PolicyManagerImplTest2() , ptu_request_types_(Json::arrayValue) {} void PolicyManagerImplTest2::SetUp() { - ON_CALL(listener_, GetRegisteredLinks()) - .WillByDefault(Return(policy::ApplicationsLinks())); + ON_CALL(listener_, GetRegisteredLinks(_)).WillByDefault(Return()); file_system::CreateDirectory(app_storage_folder_); @@ -299,7 +305,7 @@ void PolicyManagerImplTest2::AddRTtoPT(const std::string& update_file_name, const uint32_t rt_number, const uint32_t invalid_rt_number) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); // Get RequestTypes from section of preloaded_pt app_policies pt_request_types_ = policy_manager_->GetAppRequestTypes(section_name); EXPECT_EQ(rt_number, pt_request_types_.size()); @@ -322,9 +328,10 @@ void PolicyManagerImplTest2::AddRTtoAppSectionPT( const uint32_t rt_number, const uint32_t invalid_rt_number) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); // Add app - policy_manager_->AddApplication(section_name); + policy_manager_->AddApplication(section_name, + HmiTypes(policy_table::AHT_DEFAULT)); // Check app gets RequestTypes from pre_DataConsent of app_policies // section pt_request_types_ = policy_manager_->GetAppRequestTypes(section_name); @@ -443,7 +450,8 @@ void PolicyManagerImplTest2:: "Bluetooth")); // Add app from consented device. App will be assigned with default policies - policy_manager_->AddApplication(application_id_); + policy_manager_->AddApplication(application_id_, + HmiTypes(policy_table::AHT_DEFAULT)); // Expect all parameters are allowed std::ifstream ifile(update_file); @@ -526,6 +534,33 @@ void PolicyManagerImplTest2::CheckRpcPermissions( EXPECT_EQ(expected_permission, output.hmi_level_permitted); } +void PolicyManagerImplTest2::CheckRpcPermissions( + const std::string& app_id, + const std::string& rpc_name, + const policy::PermitResult& out_expected_permission) { + ::policy::RPCParams input_params; + ::policy::CheckPermissionResult output; + policy_manager_->CheckPermissions( + app_id, kHmiLevelFull, rpc_name, input_params, output); + EXPECT_EQ(out_expected_permission, output.hmi_level_permitted); +} + +void PolicyManagerImplTest2::EmulatePTAppRevoked(const std::string& ptu_name) { + std::ifstream ifile(ptu_name); + Json::Reader reader; + std::string json; + Json::Value root(Json::objectValue); + if (ifile.is_open() && reader.parse(ifile, root, true)) { + // Emulate application is revoked + root["policy_table"]["app_policies"]["1234"]["is_revoked"] = 1; + json = root.toStyledString(); + } + ifile.close(); + + ::policy::BinaryMessage msg(json.begin(), json.end()); + ASSERT_TRUE(policy_manager_->LoadPT(kDummyUpdateFileName, msg)); +} + // To avoid duplicate arrange of test void PolicyManagerImplTest2::AddSetDeviceData() { CreateLocalPT("json/sdl_preloaded_pt_send_location.json"); @@ -541,7 +576,8 @@ void PolicyManagerImplTest2::AddSetDeviceData() { "Bluetooth")); // Add app from consented device. App will be assigned with default policies - policy_manager_->AddApplication(application_id_); + policy_manager_->AddApplication(application_id_, + HmiTypes(policy_table::AHT_DEFAULT)); (policy_manager_->GetCache())->AddDevice(device_id_1_, "Bluetooth"); } @@ -596,11 +632,10 @@ PolicyManagerImplTest_RequestTypes::PolicyManagerImplTest_RequestTypes() , kAppId("1766825573") , kDefaultAppId(policy::kDefaultId) , app_storage_folder_("storage3") - , preloadet_pt_filename_(kSdlPreloadedPtJson) {} + , preloaded_pt_filename_(kSdlPreloadedPtJson) {} void PolicyManagerImplTest_RequestTypes::SetUp() { - ON_CALL(listener_, GetRegisteredLinks()) - .WillByDefault(Return(policy::ApplicationsLinks())); + ON_CALL(listener_, GetRegisteredLinks(_)).WillByDefault(Return()); file_system::CreateDirectory(app_storage_folder_); const bool in_memory = true; @@ -663,7 +698,7 @@ PolicyManagerImplTest_RequestTypes::GetRequestTypesForApplication( void PolicyManagerImplTest_RequestTypes::CompareAppRequestTypesWithDefault( const std::string& app_id, const std::string& ptu_file) { // Refresh policy table with invalid RequestType in application - RefreshPT(preloadet_pt_filename_, ptu_file); + RefreshPT(preloaded_pt_filename_, ptu_file); // Get <app_id> RequestType array policy_table::RequestTypes app_request_types = @@ -721,13 +756,13 @@ void PolicyManagerImplTest_RequestTypes::TearDown() { file_system::RemoveDirectory(app_storage_folder_, true); } -void PolicyManagerImplTest_CCS:: - PreconditionCCSPreparePTWithAppGroupsAndConsents() { +void PolicyManagerImplTest_ExternalConsent:: + PreconditionExternalConsentPreparePTWithAppGroupsAndConsents() { using namespace policy_table; using namespace rpc; CreateLocalPT(preloaded_pt_filename_); - Table t = PreparePTWithGroupsHavingCCS(); + Table t = PreparePTWithGroupsHavingExternalConsent(); ApplicationParams app_params; app_params.groups.push_back(group_name_1_); @@ -762,14 +797,16 @@ void PolicyManagerImplTest_CCS:: policy_manager_->SetUserConsentForApp(permissions); } -void PolicyManagerImplTest_CCS::PreconditionCCSPreparePTWithAppPolicy() { +void PolicyManagerImplTest_ExternalConsent:: + PreconditionExternalConsentPreparePTWithAppPolicy() { using namespace policy_table; using namespace rpc; // PT has 3 functional groups with some entities in - // disallowed_by_ccs_entities_on/off. Groups consents can be changed. + // disallowed_by_external_consent_entities_on/off. Groups consents can be + // changed. CreateLocalPT(preloaded_pt_filename_); - Table t = PreparePTWithGroupsHavingCCS(); + Table t = PreparePTWithGroupsHavingExternalConsent(); ApplicationParams app_params; app_params.groups.push_back(group_name_1_); @@ -781,30 +818,31 @@ void PolicyManagerImplTest_CCS::PreconditionCCSPreparePTWithAppPolicy() { EXPECT_TRUE(policy_manager_->GetCache()->ApplyUpdate(t)); } -rpc::policy_table_interface_base::Table -PolicyManagerImplTest_CCS::PreparePTWithGroupsHavingCCS() { +rpc::policy_table_interface_base::Table PolicyManagerImplTest_ExternalConsent:: + PreparePTWithGroupsHavingExternalConsent() { using namespace policy_table; using namespace rpc; // PT has 3 functional groups with some entities in - // disallowed_by_ccs_entities_on/off. Groups consents can be changed. + // disallowed_by_external_consent_entities_on/off. Groups consents can be + // changed. - CCS_Entity entity_1(type_1_, id_1_); - CCS_Entity entity_2(type_2_, id_2_); - CCS_Entity entity_3(type_3_, id_3_); + ExternalConsentEntity entity_1(type_1_, id_1_); + ExternalConsentEntity entity_2(type_2_, id_2_); + ExternalConsentEntity entity_3(type_3_, id_3_); Rpcs rpcs_1; - rpcs_1.disallowed_by_ccs_entities_on->push_back(entity_1); + rpcs_1.disallowed_by_external_consent_entities_on->push_back(entity_1); *rpcs_1.user_consent_prompt = group_name_1_; rpcs_1.rpcs.set_to_null(); Rpcs rpcs_2; - rpcs_2.disallowed_by_ccs_entities_off->push_back(entity_2); + rpcs_2.disallowed_by_external_consent_entities_off->push_back(entity_2); *rpcs_2.user_consent_prompt = group_name_2_; rpcs_2.rpcs.set_to_null(); Rpcs rpcs_3; - rpcs_3.disallowed_by_ccs_entities_on->push_back(entity_3); + rpcs_3.disallowed_by_external_consent_entities_on->push_back(entity_3); *rpcs_3.user_consent_prompt = group_name_3_; rpcs_3.rpcs.set_to_null(); @@ -819,7 +857,7 @@ PolicyManagerImplTest_CCS::PreparePTWithGroupsHavingCCS() { return t; } -std::string PolicyManagerImplTest_CCS::PreparePTUWithNewGroup( +std::string PolicyManagerImplTest_ExternalConsent::PreparePTUWithNewGroup( const uint32_t type, const uint32_t id, const std::string& group_name) { using namespace policy_table; using namespace rpc; @@ -829,12 +867,12 @@ std::string PolicyManagerImplTest_CCS::PreparePTUWithNewGroup( std::string json; Json::Value root(Json::objectValue); if (ifile.is_open() && reader.parse(ifile, root, true)) { - Table t = PreparePTWithGroupsHavingCCS(); + Table t = PreparePTWithGroupsHavingExternalConsent(); - CCS_Entity entity_4(type, id); + ExternalConsentEntity entity_4(type, id); Rpcs rpcs_4; - rpcs_4.disallowed_by_ccs_entities_on->push_back(entity_4); + rpcs_4.disallowed_by_external_consent_entities_on->push_back(entity_4); *rpcs_4.user_consent_prompt = group_name; rpcs_4.rpcs.set_to_null(); @@ -865,6 +903,9 @@ std::string PolicyManagerImplTest_CCS::PreparePTUWithNewGroup( root[policy_table_key][app_policies_key][app_id_1_] = overriden_table[policy_table_key][app_policies_key][app_id_1_]; + root[policy_table_key]["module_config"].removeMember("preloaded_pt"); + root[policy_table_key]["module_config"].removeMember("preloaded_date"); + json = root.toStyledString(); } ifile.close(); diff --git a/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc b/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc index 56a779f350..2f2162494f 100644 --- a/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc +++ b/src/components/policy/policy_external/test/policy_manager_impl_user_consent_test.cc @@ -47,14 +47,15 @@ TEST_F( PolicyManagerImplTest2, AddApplication_AddNewApplicationFromDeviceWithConsent_ExpectUpdateRequired) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_)) - .WillOnce(Return(device_id_1_)); + .WillRepeatedly(Return(device_id_1_)); policy_manager_->SetUserConsentForDevice(device_id_1_, true); - policy_manager_->AddApplication(app_id_1_); + policy_manager_->AddApplication(app_id_1_, + HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_EQ("UPDATE_NEEDED", policy_manager_->GetPolicyTableStatus()); } @@ -63,7 +64,7 @@ TEST_F( PolicyManagerImplTest2, AddApplication_AddNewApplicationFromDeviceWithoutConsent_ExpectUpToDate) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); // To set UP_TO_DATE before registration GetPTU(kValidSdlPtUpdateJson); @@ -76,11 +77,12 @@ TEST_F( policy_manager_->PTUpdatedAt(KILOMETERS, 1000); EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_1_)) - .WillOnce(Return(device_id_1_)); + .WillRepeatedly(Return(device_id_1_)); policy_manager_->SetUserConsentForDevice(device_id_1_, false); - policy_manager_->AddApplication(app_id_1_); + policy_manager_->AddApplication(app_id_1_, + HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_EQ("UP_TO_DATE", policy_manager_->GetPolicyTableStatus()); } @@ -89,8 +91,9 @@ TEST_F( PolicyManagerImplTest2, ReactOnUserDevConsentForApp_AddNewApplicationFromDeviceWithoutConsent_ExpectPreDataConsent) { // Arrange - CreateLocalPT(preloadet_pt_filename_); - policy_manager_->AddApplication(app_id_1_); + CreateLocalPT(preloaded_pt_filename_); + policy_manager_->AddApplication(app_id_1_, + HmiTypes(policy_table::AHT_DEFAULT)); ASSERT_TRUE(policy_manager_->IsPredataPolicy(app_id_1_)); policy_manager_->ReactOnUserDevConsentForApp(app_id_1_, false); EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_1_)); @@ -103,7 +106,8 @@ TEST_F(PolicyManagerImplTest2, CreateLocalPT(kSdlPreloadedPtJson2); ASSERT_TRUE( (policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth")); - policy_manager_->AddApplication(application_id_); + policy_manager_->AddApplication(application_id_, + HmiTypes(policy_table::AHT_DEFAULT)); // Expect RPCs from pre_dataConsent group are allowed // Next checks are equal to BaseBeforeDataConsent_APIs.xml checks from task @@ -150,8 +154,9 @@ TEST_F(PolicyManagerImplTest2, // Related to manual tests APPLINK-18763, APPLINK-18764 TEST_F(PolicyManagerImplTest2, CheckPreDataConsent_GetDefaultHmiLevel_NONE) { // Arrange - CreateLocalPT(preloadet_pt_filename_); - policy_manager_->AddApplication(app_id_2_); + CreateLocalPT(preloaded_pt_filename_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); std::string default_hmi; // Default HMI level is NONE policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi); @@ -168,7 +173,8 @@ TEST_F(PolicyManagerImplTest2, CheckPreDataConsent_GetDefaultHmiLevel_BACKGROUNG) { // Arrange CreateLocalPT(kSdlPreloadedPtJson2); - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); std::string default_hmi; // Default HMI level is BACKGROUND policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi); @@ -185,7 +191,8 @@ TEST_F( // Arrange // RequestTypes for default & preDataConsent are different CreateLocalPT("json/ptu_requestType.json"); - policy_manager_->AddApplication(app_id_1_); + policy_manager_->AddApplication(app_id_1_, + HmiTypes(policy_table::AHT_DEFAULT)); ASSERT_TRUE(policy_manager_->IsPredataPolicy(app_id_1_)); policy_manager_->ReactOnUserDevConsentForApp(app_id_1_, true); EXPECT_FALSE(policy_manager_->IsPredataPolicy(app_id_1_)); @@ -199,7 +206,8 @@ TEST_F( // Arrange // RequestTypes for default & preDataConsent are the same CreateLocalPT(kPtu2RequestTypeJson); - policy_manager_->AddApplication(app_id_1_); + policy_manager_->AddApplication(app_id_1_, + HmiTypes(policy_table::AHT_DEFAULT)); ASSERT_TRUE(policy_manager_->IsPredataPolicy(app_id_1_)); EXPECT_CALL(listener_, OnPendingPermissionChange(app_id_1_)).Times(0); policy_manager_->ReactOnUserDevConsentForApp(app_id_1_, true); @@ -211,7 +219,7 @@ TEST_F( PolicyManagerImplTest2, GetUserConsentForDevice_SetDeviceWithoutConcent_ExpectReceivedConsentCorrect) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); ASSERT_TRUE( (policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth")); ::policy::DeviceConsent consent = @@ -223,7 +231,7 @@ TEST_F( TEST_F(PolicyManagerImplTest2, GetUserConsentForDevice_SetDeviceAllowed_ExpectReceivedConsentCorrect) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); ASSERT_TRUE( (policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth")); @@ -248,7 +256,7 @@ TEST_F( PolicyManagerImplTest2, GetUserConsentForDevice_SetDeviceDisallowed_ExpectReceivedConsentCorrect) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); ASSERT_TRUE( (policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth")); ASSERT_TRUE((policy_manager_->GetCache()) @@ -291,7 +299,8 @@ TEST_F(PolicyManagerImplTest2, EXPECT_EQ(::policy::DeviceConsent::kDeviceDisallowed, consent); EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); std::string default_hmi; policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi); EXPECT_EQ("NONE", default_hmi); @@ -301,7 +310,8 @@ TEST_F(PolicyManagerImplTest2, GetDefaultHmi_SetDeviceAllowed_ExpectReceivedHmiCorrect) { // Arrange CreateLocalPT(kPtu2RequestTypeJson); - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); // Check if app has preData policy EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_)); std::string default_hmi1; @@ -325,7 +335,8 @@ TEST_F(PolicyManagerImplTest2, EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent); EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_2_)); std::string default_hmi2; policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi2); @@ -336,7 +347,8 @@ TEST_F(PolicyManagerImplTest2, GetDefaultPriority_SetDeviceAllowed_ExpectReceivedPriorityCorrect) { // Arrange CreateLocalPT(kPtu2RequestTypeJson); - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); // Check if app has preData policy EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_)); std::string priority1; @@ -360,7 +372,8 @@ TEST_F(PolicyManagerImplTest2, EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent); EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_2_)); std::string priority2; EXPECT_TRUE(policy_manager_->GetPriority(app_id_2_, &priority2)); @@ -370,7 +383,7 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, GetUserFirendlyMessages_ExpectReceivedCorrectMessages) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); ::policy::StringArray message_code; message_code.push_back("SettingEnableUpdates"); message_code.push_back("AppPermissions"); @@ -476,12 +489,13 @@ TEST_F(PolicyManagerImplTest2, SetDeviceInfo_ExpectDevInfoAddedToPT) { TEST_F(PolicyManagerImplTest2, GetInitialAppData_ExpectReceivedConsentCorrect) { // Arrange - CreateLocalPT(preloadet_pt_filename_); - policy_manager_->AddApplication(app_id_2_); + CreateLocalPT(preloaded_pt_filename_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); ::policy::StringArray app_nicknames; ::policy::StringArray app_hmi_types; policy_manager_->GetInitialAppData(app_id_2_, &app_nicknames, &app_hmi_types); - // Expect Empty nicknames and AppHMITypes + // Expect Empty nicknames and AppHmiTypes EXPECT_EQ(0u, app_nicknames.size()); EXPECT_EQ(0u, app_hmi_types.size()); @@ -509,7 +523,7 @@ TEST_F(PolicyManagerImplTest2, GetInitialAppData_ExpectReceivedConsentCorrect) { for (uint32_t i = 0; i < nick_names_size; ++i) { EXPECT_EQ(app_nicknames1[i], appNicknames[i].asString()); } - // Check AppHMITypes match + // Check AppHmiTypes match for (uint32_t i = 0; i < app_hmi_types_size; ++i) { EXPECT_EQ(app_hmi_types1[i], appHmiTypes[i].asString()); } @@ -519,8 +533,9 @@ TEST_F( PolicyManagerImplTest2, CanAppKeepContext_AddAppFromUnconsentedDevice_ExpectAppCannotKeepContext) { // Arrange - CreateLocalPT(preloadet_pt_filename_); - policy_manager_->AddApplication(app_id_2_); + CreateLocalPT(preloaded_pt_filename_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); // Check if app has preData policy EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_)); // Check keep context in preData policy @@ -530,10 +545,11 @@ TEST_F( TEST_F(PolicyManagerImplTest2, CanAppKeepContext_AddAppFromConsentedDevice_ExpectAppCannotKeepContext) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); ASSERT_TRUE( (policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth")); - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); ASSERT_TRUE((policy_manager_->GetCache()) ->SetDeviceData(device_id_2_, "hardware IPX", @@ -549,7 +565,8 @@ TEST_F(PolicyManagerImplTest2, EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent); EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_2_)); // Check keep context in default policy EXPECT_FALSE(policy_manager_->CanAppKeepContext(app_id_2_)); @@ -558,8 +575,9 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, CanAppStealFocus_AddAppFromUnconsentedDevice_ExpectAppCannotStealFocus) { // Arrange - CreateLocalPT(preloadet_pt_filename_); - policy_manager_->AddApplication(app_id_2_); + CreateLocalPT(preloaded_pt_filename_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); // Check if app has preData policy EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_)); // Check keep context in preData policy @@ -569,10 +587,11 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, CanAppStealFocus_AddAppFromConsentedDevice_ExpectAppCannotStealFocus) { // Arrange - CreateLocalPT(preloadet_pt_filename_); + CreateLocalPT(preloaded_pt_filename_); ASSERT_TRUE( (policy_manager_->GetCache())->AddDevice(device_id_2_, "Bluetooth")); - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); ASSERT_TRUE((policy_manager_->GetCache()) ->SetDeviceData(device_id_2_, "hardware IPX", @@ -588,7 +607,8 @@ TEST_F(PolicyManagerImplTest2, EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent); EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_2_)); // Check keep context in default policy EXPECT_FALSE(policy_manager_->CanAppStealFocus(app_id_2_)); @@ -597,8 +617,9 @@ TEST_F(PolicyManagerImplTest2, TEST_F(PolicyManagerImplTest2, IsPredataPolicy_SetAppWIthPredataPolicy_ExpectPredataPolicy) { // Arrange - CreateLocalPT(preloadet_pt_filename_); - policy_manager_->AddApplication(app_id_2_); + CreateLocalPT(preloaded_pt_filename_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); // Check if app has preData policy EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_)); } @@ -608,7 +629,8 @@ TEST_F( SendNotificationOnPermissionsUpdated_SetDeviceAllowed_ExpectNotificationSent) { // Arrange CreateLocalPT(kPtu2RequestTypeJson); - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); // Check if app has preData policy EXPECT_TRUE(policy_manager_->IsPredataPolicy(app_id_2_)); std::string default_hmi1; @@ -638,7 +660,8 @@ TEST_F( EXPECT_EQ(::policy::DeviceConsent::kDeviceAllowed, consent); EXPECT_CALL(listener_, OnCurrentDeviceIdUpdateRequired(app_id_2_)) .WillRepeatedly(Return(device_id_2_)); - policy_manager_->AddApplication(app_id_2_); + policy_manager_->AddApplication(app_id_2_, + HmiTypes(policy_table::AHT_DEFAULT)); EXPECT_TRUE((policy_manager_->GetCache())->IsDefaultPolicy(app_id_2_)); std::string default_hmi2; policy_manager_->GetDefaultHmi(app_id_2_, &default_hmi2); diff --git a/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc b/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc index 8d5c980ccd..92525c646d 100644 --- a/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc +++ b/src/components/policy/policy_external/test/sql_pt_ext_representation_test.cc @@ -64,10 +64,10 @@ class SQLPTExtRepresentationTest : public ::testing::Test { // Collection of pairs of group alias and corresponding group name typedef vector<pair<string, string> > GroupsAliasNameCollection; - SQLPTExtRepresentationTest() : reps(0) {} + SQLPTExtRepresentationTest() : reps_(NULL) {} protected: - SQLPTExtRepresentation* reps; + SQLPTExtRepresentation* reps_; policy_handler_test::MockPolicySettings policy_settings_; static const string kDatabaseName; PermissionConsent perm_consent; @@ -75,24 +75,24 @@ class SQLPTExtRepresentationTest : public ::testing::Test { FunctionalGroupPermission group2_perm; utils::dbms::SQLQuery* query_wrapper_; static const bool in_memory_; - const std::string kAppStorageFolder = "storage1"; + const std::string kAppStorageFolder = "storage_SQLPTExtRepresentationTest"; void SetUp() OVERRIDE { file_system::DeleteFile(kDatabaseName); - reps = new SQLPTExtRepresentation(in_memory_); - ASSERT_TRUE(reps != NULL); + reps_ = new SQLPTExtRepresentation(in_memory_); + ASSERT_TRUE(reps_ != NULL); ON_CALL(policy_settings_, app_storage_folder()) .WillByDefault(ReturnRef(kAppStorageFolder)); - ASSERT_EQ(SUCCESS, reps->Init(&policy_settings_)); - query_wrapper_ = new utils::dbms::SQLQuery(reps->db()); + ASSERT_EQ(SUCCESS, reps_->Init(&policy_settings_)); + query_wrapper_ = new utils::dbms::SQLQuery(reps_->db()); ASSERT_TRUE(query_wrapper_ != NULL); } void TearDown() OVERRIDE { delete query_wrapper_; - EXPECT_TRUE(reps->Drop()); - EXPECT_TRUE(reps->Close()); - delete reps; + EXPECT_TRUE(reps_->Drop()); + EXPECT_TRUE(reps_->Close()); + delete reps_; } void FillGroupPermission( @@ -193,8 +193,76 @@ class SQLPTExtRepresentationTest : public ::testing::Test { } return result; } + // Attempt of simplifying policy table checks, hides internal stuff, add + // basic checks for data existence before getting of data + // For usage example see SaveUserConsentRecords_ExpectedSaved, + // SaveFunctionalGroupings_ExpectedSaved tests + template <typename ParentType, typename KeyType> + bool IsExist(const ParentType& parent) const; + + template <typename ParentType, typename Value> + bool IsKeyExist(const ParentType& parent, const Value& value) const { + return parent.end() != std::find(parent.begin(), parent.end(), value); + } + + template <typename ParentType> + bool IsKeyExist(const ParentType& parent, const std::string& value) const { + return parent.end() != parent.find(value); + } + + template <typename ParentType, typename KeyType> + const KeyType& GetData(const ParentType& parent) const { + EXPECT_TRUE((IsExist<ParentType, KeyType>(parent))); + return GetDataInternal<ParentType, KeyType>(parent); + } + + template <typename ParentType, typename KeyType> + const KeyType& GetKeyData(const ParentType& parent, + const std::string& key_name) const { + EXPECT_TRUE((IsKeyExist<ParentType>(parent, key_name))); + return GetKeyDataInternal<ParentType, KeyType>(parent, key_name); + } + + private: + template <typename ParentType, typename KeyType> + const KeyType& GetDataInternal(const ParentType& parent) const; + + template <typename ParentType, typename KeyType> + const KeyType& GetKeyDataInternal(const ParentType& parent, + const std::string& key_name) const { + return parent.find(key_name)->second; + } }; +// Specializations for 'policy_table' section + +template <> +bool SQLPTExtRepresentationTest::IsExist<policy_table::Table, + policy_table::DeviceData>( + const policy_table::Table& table) const { + return table.policy_table.device_data.is_initialized(); +} + +template <> +bool SQLPTExtRepresentationTest::IsExist<policy_table::Table, + policy_table::FunctionalGroupings>( + const policy_table::Table& table) const { + return table.policy_table.functional_groupings.is_initialized(); +} + +template <> +const policy_table::DeviceData& SQLPTExtRepresentationTest::GetDataInternal( + const policy_table::Table& table) const { + return *table.policy_table.device_data; +} + +template <> +const policy_table::FunctionalGroupings& +SQLPTExtRepresentationTest::GetDataInternal( + const policy_table::Table& table) const { + return table.policy_table.functional_groupings; +} + const string SQLPTExtRepresentationTest::kDatabaseName = ":memory:"; const bool SQLPTExtRepresentationTest::in_memory_ = true; @@ -322,10 +390,10 @@ TEST_F(SQLPTExtRepresentationTest, // Assert ASSERT_TRUE(IsValid(update)); - ASSERT_TRUE(reps->Save(update)); + ASSERT_TRUE(reps_->Save(update)); // Act - utils::SharedPtr<policy_table::Table> snapshot = reps->GenerateSnapshot(); + utils::SharedPtr<policy_table::Table> snapshot = reps_->GenerateSnapshot(); snapshot->SetPolicyTableType(rpc::policy_table_interface_base::PT_SNAPSHOT); policy_table["module_meta"] = Json::Value(Json::objectValue); @@ -368,8 +436,8 @@ TEST_F( // Assert ASSERT_TRUE(query_wrapper_->Exec(query_insert_12345)); - EXPECT_FALSE(reps->CanAppKeepContext("0")); - EXPECT_TRUE(reps->CanAppKeepContext("12345")); + EXPECT_FALSE(reps_->CanAppKeepContext("0")); + EXPECT_TRUE(reps_->CanAppKeepContext("12345")); // Act const std::string query_insert_123 = "INSERT INTO `application` (`id`, `memory_kb`," @@ -377,7 +445,7 @@ TEST_F( // Assert ASSERT_TRUE(query_wrapper_->Exec(query_insert_123)); - EXPECT_FALSE(reps->CanAppKeepContext("123")); + EXPECT_FALSE(reps_->CanAppKeepContext("123")); } TEST_F(SQLPTExtRepresentationTest, @@ -393,8 +461,8 @@ TEST_F(SQLPTExtRepresentationTest, // Assert ASSERT_TRUE(query_wrapper_->Exec(query_insert_12345)); - EXPECT_TRUE(reps->CanAppStealFocus("12345")); - EXPECT_FALSE(reps->CanAppStealFocus("0")); + EXPECT_TRUE(reps_->CanAppStealFocus("12345")); + EXPECT_FALSE(reps_->CanAppStealFocus("0")); // Act const std::string query_insert_123 = "INSERT INTO `application` (`id`, `memory_kb`," @@ -402,7 +470,7 @@ TEST_F(SQLPTExtRepresentationTest, // Assert ASSERT_TRUE(query_wrapper_->Exec(query_insert_123)); - EXPECT_FALSE(reps->CanAppStealFocus("123")); + EXPECT_FALSE(reps_->CanAppStealFocus("123")); } TEST_F(SQLPTExtRepresentationTest, @@ -419,7 +487,7 @@ TEST_F(SQLPTExtRepresentationTest, std::string result; // Assert ASSERT_TRUE(query_wrapper_->Exec(query_insert_12345)); - EXPECT_TRUE(reps->GetDefaultHMI("12345", &result)); + EXPECT_TRUE(reps_->GetDefaultHMI("12345", &result)); EXPECT_EQ("NONE", result); const std::string query_insert_123 = "INSERT INTO `application` (`id`, `memory_kb`," @@ -428,7 +496,7 @@ TEST_F(SQLPTExtRepresentationTest, // Assert ASSERT_TRUE(query_wrapper_->Exec(query_insert_123)); - EXPECT_TRUE(reps->GetDefaultHMI("123", &result)); + EXPECT_TRUE(reps_->GetDefaultHMI("123", &result)); EXPECT_EQ("LIMITED", result); } @@ -437,7 +505,7 @@ TEST_F(SQLPTExtRepresentationTest, // Arrange StringArray allowed_groups; StringArray disallowed_groups; - EXPECT_TRUE(reps->GetUserPermissionsForDevice( + EXPECT_TRUE(reps_->GetUserPermissionsForDevice( "XXX12345ZZZ", &allowed_groups, &disallowed_groups)); EXPECT_EQ(0u, allowed_groups.size()); EXPECT_EQ(0u, disallowed_groups.size()); @@ -457,7 +525,7 @@ TEST_F(SQLPTExtRepresentationTest, "('XXX12345ZZZ', 'Navigation-1', 0,'GUI', '2015-01-01T00:00:52Z')"; // Assert ASSERT_TRUE(query_wrapper_->Exec(query_insert_Navigation)); - EXPECT_TRUE(reps->GetUserPermissionsForDevice( + EXPECT_TRUE(reps_->GetUserPermissionsForDevice( "XXX12345ZZZ", &allowed_groups, &disallowed_groups)); EXPECT_EQ(1u, allowed_groups.size()); EXPECT_EQ(1u, disallowed_groups.size()); @@ -468,19 +536,19 @@ TEST_F(SQLPTExtRepresentationTest, // Arrange StringArray allowed_groups; StringArray disallowed_groups; - EXPECT_TRUE(reps->GetUserPermissionsForDevice( + EXPECT_TRUE(reps_->GetUserPermissionsForDevice( "XXX12345ZZZ", &allowed_groups, &disallowed_groups)); EXPECT_EQ(0u, allowed_groups.size()); EXPECT_EQ(0u, disallowed_groups.size()); allowed_groups.push_back("DataConsent-2"); disallowed_groups.push_back("Navigation-1"); - EXPECT_TRUE(reps->SetUserPermissionsForDevice( + EXPECT_TRUE(reps_->SetUserPermissionsForDevice( "XXX12345ZZZ", allowed_groups, disallowed_groups)); allowed_groups.clear(); disallowed_groups.clear(); // Act - EXPECT_TRUE(reps->GetUserPermissionsForDevice( + EXPECT_TRUE(reps_->GetUserPermissionsForDevice( "XXX12345ZZZ", &allowed_groups, &disallowed_groups)); // Checks EXPECT_EQ(1u, allowed_groups.size()); @@ -498,19 +566,19 @@ TEST_F(SQLPTExtRepresentationTest, // Arrange StringArray allowed_groups; StringArray disallowed_groups; - EXPECT_TRUE(reps->GetUserPermissionsForDevice( + EXPECT_TRUE(reps_->GetUserPermissionsForDevice( "XXX12345ZZZ", &allowed_groups, &disallowed_groups)); EXPECT_EQ(0u, allowed_groups.size()); EXPECT_EQ(0u, disallowed_groups.size()); allowed_groups.push_back("DataConsent-2"); disallowed_groups.push_back("Navigation-1"); - EXPECT_TRUE(reps->SetUserPermissionsForDevice( + EXPECT_TRUE(reps_->SetUserPermissionsForDevice( "XXX12345ZZZ", allowed_groups, disallowed_groups)); allowed_groups.clear(); disallowed_groups.clear(); // Act - EXPECT_TRUE(reps->GetUserPermissionsForDevice( + EXPECT_TRUE(reps_->GetUserPermissionsForDevice( "XXX12345ZZZ", &allowed_groups, &disallowed_groups)); // Checks EXPECT_EQ(1u, allowed_groups.size()); @@ -524,8 +592,8 @@ TEST_F(SQLPTExtRepresentationTest, allowed_groups.clear(); disallowed_groups.clear(); // Act - reps->ResetDeviceConsents(); - EXPECT_TRUE(reps->GetUserPermissionsForDevice( + reps_->ResetDeviceConsents(); + EXPECT_TRUE(reps_->GetUserPermissionsForDevice( "XXX12345ZZZ", &allowed_groups, &disallowed_groups)); // Checks EXPECT_EQ(0u, allowed_groups.size()); @@ -557,7 +625,8 @@ TEST_F(SQLPTExtRepresentationTest, disallowed_groups.push_back(std::make_pair("", "Base-4")); FillPermissionStruct("", "", "", allowed_groups, disallowed_groups); FunctionalIdType group_types; - ASSERT_TRUE(reps->GetPermissionsForApp("XXX12345ZZZ", "12345", &group_types)); + ASSERT_TRUE( + reps_->GetPermissionsForApp("XXX12345ZZZ", "12345", &group_types)); EXPECT_TRUE( CheckGroupTypesExist(group_types, allowed_groups, disallowed_groups)); } @@ -572,10 +641,11 @@ TEST_F(SQLPTExtRepresentationTest, disallowed_groups.push_back(std::make_pair("DataConsent", "DataConsent-2")); FillPermissionStruct( "XXX12345ZZZ", "12345", "VR", allowed_groups, disallowed_groups); - EXPECT_TRUE(reps->SetUserPermissionsForApp(perm_consent)); + EXPECT_TRUE(reps_->SetUserPermissionsForApp(perm_consent)); FunctionalIdType group_types; - ASSERT_TRUE(reps->GetPermissionsForApp("XXX12345ZZZ", "12345", &group_types)); + ASSERT_TRUE( + reps_->GetPermissionsForApp("XXX12345ZZZ", "12345", &group_types)); EXPECT_TRUE( CheckGroupTypesExist(group_types, allowed_groups, disallowed_groups)); } @@ -590,15 +660,17 @@ TEST_F(SQLPTExtRepresentationTest, disallowed_groups.push_back(std::make_pair("DataConsent", "DataConsent-2")); FillPermissionStruct( "XXX12345ZZZ", "12345", "VR", allowed_groups, disallowed_groups); - EXPECT_TRUE(reps->SetUserPermissionsForApp(perm_consent)); + EXPECT_TRUE(reps_->SetUserPermissionsForApp(perm_consent)); FunctionalIdType group_types; - ASSERT_TRUE(reps->GetPermissionsForApp("XXX12345ZZZ", "12345", &group_types)); + ASSERT_TRUE( + reps_->GetPermissionsForApp("XXX12345ZZZ", "12345", &group_types)); EXPECT_TRUE( CheckGroupTypesExist(group_types, allowed_groups, disallowed_groups)); - reps->ResetAppConsents(); - ASSERT_TRUE(reps->GetPermissionsForApp("XXX12345ZZZ", "12345", &group_types)); + reps_->ResetAppConsents(); + ASSERT_TRUE( + reps_->GetPermissionsForApp("XXX12345ZZZ", "12345", &group_types)); EXPECT_FALSE( CheckGroupTypesExist(group_types, allowed_groups, disallowed_groups)); } @@ -619,10 +691,11 @@ TEST_F(SQLPTExtRepresentationTest, perm_allowed_groups, perm_disallowed_groups); // Set permissions for app - EXPECT_TRUE(reps->SetUserPermissionsForApp(perm_consent)); + EXPECT_TRUE(reps_->SetUserPermissionsForApp(perm_consent)); FunctionalIdType group_types; - ASSERT_TRUE(reps->GetPermissionsForApp("XXX12345ZZZ", "12345", &group_types)); + ASSERT_TRUE( + reps_->GetPermissionsForApp("XXX12345ZZZ", "12345", &group_types)); EXPECT_TRUE(CheckGroupTypesExist( group_types, perm_allowed_groups, perm_disallowed_groups)); @@ -631,19 +704,20 @@ TEST_F(SQLPTExtRepresentationTest, allowed_groups.push_back("DataConsent-2"); disallowed_groups.push_back("Navigation-1"); // Set permissions for device - EXPECT_TRUE(reps->SetUserPermissionsForDevice( + EXPECT_TRUE(reps_->SetUserPermissionsForDevice( "XXX12345ZZZ", allowed_groups, disallowed_groups)); allowed_groups.clear(); disallowed_groups.clear(); // Act - reps->ResetUserConsent(); - EXPECT_TRUE(reps->GetUserPermissionsForDevice( + reps_->ResetUserConsent(); + EXPECT_TRUE(reps_->GetUserPermissionsForDevice( "XXX12345ZZZ", &allowed_groups, &disallowed_groups)); // Checks EXPECT_EQ(0u, allowed_groups.size()); EXPECT_EQ(0u, disallowed_groups.size()); - EXPECT_TRUE(reps->GetPermissionsForApp("XXX12345ZZZ", "12345", &group_types)); + EXPECT_TRUE( + reps_->GetPermissionsForApp("XXX12345ZZZ", "12345", &group_types)); EXPECT_FALSE(CheckGroupTypesExist( group_types, perm_allowed_groups, perm_disallowed_groups)); } @@ -686,7 +760,8 @@ TEST_F(SQLPTExtRepresentationTest, policy_table::Strings groups; policy_table::Strings preconsented_groups; - EXPECT_TRUE(reps->GetDeviceGroupsFromPolicies(&groups, &preconsented_groups)); + EXPECT_TRUE( + reps_->GetDeviceGroupsFromPolicies(&groups, &preconsented_groups)); EXPECT_EQ(2u, groups.size()); EXPECT_EQ(1u, preconsented_groups.size()); @@ -707,15 +782,15 @@ TEST_F(SQLPTExtRepresentationTest, TEST_F(SQLPTExtRepresentationTest, SetDeviceData_SetDeviceData_ExpectValuesThatSetInParams) { // Arrange - utils::dbms::SQLQuery query(reps->db()); - reps->SetDeviceData("08-00-27-CE-76-FE", - "hardware IPX", - "v.8.0.1", - "Android", - "4.4.2", - "Life", - 2, - "Bluetooth"); + utils::dbms::SQLQuery query(reps_->db()); + reps_->SetDeviceData("08-00-27-CE-76-FE", + "hardware IPX", + "v.8.0.1", + "Android", + "4.4.2", + "Life", + 2, + "Bluetooth"); const std::string query_select_hardware = "SELECT `hardware` FROM `device` WHERE `id` = '08-00-27-CE-76-FE'"; const std::string query_select_firmware_rev = @@ -805,9 +880,9 @@ TEST_F( // Assert ASSERT_TRUE(query_wrapper_->Exec(query_insert_application)); - EXPECT_TRUE(reps->IsPredataPolicy("1234")); - reps->ReactOnUserDevConsentForApp("1234", true); - EXPECT_TRUE(reps->IsDefaultPolicy("1234")); + EXPECT_TRUE(reps_->IsPredataPolicy("1234")); + reps_->ReactOnUserDevConsentForApp("1234", true); + EXPECT_TRUE(reps_->IsDefaultPolicy("1234")); } TEST_F( @@ -873,9 +948,9 @@ TEST_F( // Assert ASSERT_TRUE(query_wrapper_->Exec(query_insert_application)); FunctionalIdType group_types; - ASSERT_TRUE(reps->GetPermissionsForApp("XXX12345ZZZ", "1234", &group_types)); - EXPECT_FALSE(reps->IsPredataPolicy("1234")); - EXPECT_FALSE(reps->IsDefaultPolicy("1234")); + ASSERT_TRUE(reps_->GetPermissionsForApp("XXX12345ZZZ", "1234", &group_types)); + EXPECT_FALSE(reps_->IsPredataPolicy("1234")); + EXPECT_FALSE(reps_->IsDefaultPolicy("1234")); std::map<GroupType, FunctionalGroupIDs>::iterator it1 = group_types.find(GroupType::kTypeAllowed); EXPECT_TRUE(group_types.end() != it1); @@ -885,13 +960,13 @@ TEST_F( ASSERT_TRUE(it2 != it1->second.end()); it2 = std::find(it1->second.begin(), it1->second.end(), 1809526495); ASSERT_TRUE(it2 != it1->second.end()); - reps->SetIsPredata("1234", true); - EXPECT_TRUE(reps->IsPredataPolicy("1234")); - reps->ReactOnUserDevConsentForApp("1234", true); + reps_->SetIsPredata("1234", true); + EXPECT_TRUE(reps_->IsPredataPolicy("1234")); + reps_->ReactOnUserDevConsentForApp("1234", true); group_types.clear(); - ASSERT_TRUE(reps->GetPermissionsForApp("XXX12345ZZZ", "1234", &group_types)); - EXPECT_FALSE(reps->IsPredataPolicy("1234")); - EXPECT_FALSE(reps->IsDefaultPolicy("1234")); + ASSERT_TRUE(reps_->GetPermissionsForApp("XXX12345ZZZ", "1234", &group_types)); + EXPECT_FALSE(reps_->IsPredataPolicy("1234")); + EXPECT_FALSE(reps_->IsDefaultPolicy("1234")); it1 = group_types.find(GroupType::kTypeAllowed); EXPECT_TRUE(group_types.end() != it1); EXPECT_EQ(2u, it1->second.size()); @@ -916,7 +991,7 @@ TEST_F(SQLPTExtRepresentationTest, msg_code.push_back("AppPermissions"); // Act std::vector<UserFriendlyMessage> result = - reps->GetUserFriendlyMsg(msg_code, string("en-en")); + reps_->GetUserFriendlyMsg(msg_code, string("en-en")); // Checks ASSERT_EQ(1u, result.size()); EXPECT_EQ(result[0].message_code, "AppPermissions"); @@ -930,7 +1005,7 @@ TEST_F(SQLPTExtRepresentationTest, TEST_F(SQLPTExtRepresentationTest, IncrementGlobalCounter_IncrementThreeTimes_ExpectCountEqual3) { // Arrange - utils::dbms::SQLQuery query(reps->db()); + utils::dbms::SQLQuery query(reps_->db()); const std::string query_update = "UPDATE `usage_and_error_count` SET" " `count_of_sync_reboots` = 0"; @@ -939,9 +1014,9 @@ TEST_F(SQLPTExtRepresentationTest, ASSERT_TRUE(query_wrapper_->Exec(query_update)); // Act - reps->Increment("count_of_sync_reboots"); - reps->Increment("count_of_sync_reboots"); - reps->Increment("count_of_sync_reboots"); + reps_->Increment("count_of_sync_reboots"); + reps_->Increment("count_of_sync_reboots"); + reps_->Increment("count_of_sync_reboots"); const std::string query_select = "SELECT `count_of_sync_reboots` FROM `usage_and_error_count`"; @@ -955,7 +1030,7 @@ TEST_F( SQLPTExtRepresentationTest, IncrementAppCounter_IncrementCountOfUserSelections3Times_ExpectCountEqual3) { // Arrange - utils::dbms::SQLQuery query(reps->db()); + utils::dbms::SQLQuery query(reps_->db()); const std::string query_delete = "DELETE FROM `app_level` WHERE `application_id` = '12345'"; @@ -963,9 +1038,9 @@ TEST_F( ASSERT_TRUE(query_wrapper_->Exec(query_delete)); // Act - reps->Increment("12345", "count_of_user_selections"); - reps->Increment("12345", "count_of_user_selections"); - reps->Increment("12345", "count_of_user_selections"); + reps_->Increment("12345", "count_of_user_selections"); + reps_->Increment("12345", "count_of_user_selections"); + reps_->Increment("12345", "count_of_user_selections"); const std::string query_select = "SELECT `count_of_user_selections` FROM `app_level`" @@ -980,15 +1055,15 @@ TEST_F( TEST_F(SQLPTExtRepresentationTest, AppInfo_SetLanguageRuInGUIAndEnInVUI_ExpectRuInGUIAndEnInVUI) { // Arrange - utils::dbms::SQLQuery query(reps->db()); + utils::dbms::SQLQuery query(reps_->db()); const std::string query_delete = "DELETE FROM `app_level` WHERE `application_id` = '12345'"; // Assert ASSERT_TRUE(query_wrapper_->Exec(query_delete)); // Act - reps->Set("12345", "app_registration_language_gui", "ru-ru"); - reps->Set("12345", "app_registration_language_vui", "en-en"); + reps_->Set("12345", "app_registration_language_gui", "ru-ru"); + reps_->Set("12345", "app_registration_language_vui", "en-en"); const std::string query_select_gui = "SELECT `app_registration_language_gui`" @@ -1011,14 +1086,14 @@ TEST_F(SQLPTExtRepresentationTest, TEST_F(SQLPTExtRepresentationTest, AddAppStopwatch_Set10And60MinutesForStopwatch_Expect70Minutes) { // Arrange - utils::dbms::SQLQuery query(reps->db()); + utils::dbms::SQLQuery query(reps_->db()); const std::string query_delete = "DELETE FROM `app_level` WHERE `application_id` = '12345'"; // Assert ASSERT_TRUE(query_wrapper_->Exec(query_delete)); // Act - reps->Add("12345", "minutes_in_hmi_full", 10); - reps->Add("12345", "minutes_in_hmi_full", 60); + reps_->Add("12345", "minutes_in_hmi_full", 10); + reps_->Add("12345", "minutes_in_hmi_full", 60); const std::string query_select = "SELECT `minutes_in_hmi_full` FROM `app_level`" @@ -1034,7 +1109,7 @@ TEST_F( SQLPTExtRepresentationTest, SetUnpairedDevice_SetUnpairedDeviceId12345_ExpectUnpairedDeviceIdEquals12345) { // Arrange - utils::dbms::SQLQuery query(reps->db()); + utils::dbms::SQLQuery query(reps_->db()); const std::string query_delete = "DELETE FROM `device`"; // Assert ASSERT_TRUE(query_wrapper_->Exec(query_delete)); @@ -1043,7 +1118,7 @@ TEST_F( "INSERT INTO `device` (`id`) VALUES('12345')"; // Assert ASSERT_TRUE(query_wrapper_->Exec(query_insert)); - ASSERT_TRUE(reps->SetUnpairedDevice("12345", true)); + ASSERT_TRUE(reps_->SetUnpairedDevice("12345", true)); // Act const std::string query_select = "SELECT `id` FROM `device` WHERE `unpaired` = 1"; @@ -1074,7 +1149,7 @@ TEST_F( // Act std::vector<std::string> output; // Assert - ASSERT_TRUE(reps->UnpairedDevicesList(&output)); + ASSERT_TRUE(reps_->UnpairedDevicesList(&output)); ASSERT_EQ(2u, output.size()); EXPECT_NE(output.end(), std::find(output.begin(), output.end(), "12345")); EXPECT_NE(output.end(), std::find(output.begin(), output.end(), "54321")); @@ -1083,8 +1158,8 @@ TEST_F( TEST_F(SQLPTExtRepresentationTest, SetMetaInfo_SetMetaInfo_ExpectValuesSetInParams) { // Arrange - ASSERT_TRUE(reps->SetMetaInfo("4.1.3.B_EB355B", "WAEGB", "ru-ru")); - utils::dbms::SQLQuery query(reps->db()); + ASSERT_TRUE(reps_->SetMetaInfo("4.1.3.B_EB355B", "WAEGB", "ru-ru")); + utils::dbms::SQLQuery query(reps_->db()); const std::string query_select_ccpu = "SELECT `ccpu_version` FROM `module_meta`"; const std::string query_select_wers_country_code = @@ -1111,14 +1186,14 @@ TEST_F(SQLPTExtRepresentationTest, "UPDATE `module_meta` SET `ccpu_version` = '4.1.3.B_EB355B', " "`wers_country_code` = 'WAEGB', `language` = 'ru-ru' "; ASSERT_TRUE(query_wrapper_->Exec(query_insert_meta_info)); - EXPECT_TRUE(reps->IsMetaInfoPresent()); + EXPECT_TRUE(reps_->IsMetaInfoPresent()); } TEST_F(SQLPTExtRepresentationTest, SetSystemLanguage_SetSystemLanguage_ExpectValueSetInParams) { // Arrange - utils::dbms::SQLQuery query(reps->db()); - ASSERT_TRUE(reps->SetSystemLanguage("ru-ru")); + utils::dbms::SQLQuery query(reps_->db()); + ASSERT_TRUE(reps_->SetSystemLanguage("ru-ru")); const std::string query_select_language = "SELECT `language` FROM `module_meta`"; // Assert @@ -1148,7 +1223,7 @@ TEST_F( std::map<uint32_t, std::pair<std::string, std::string> > FunctionalGroupNames; std::map<uint32_t, std::pair<std::string, std::string> >::iterator it; - reps->GetFunctionalGroupNames(FunctionalGroupNames); + reps_->GetFunctionalGroupNames(FunctionalGroupNames); EXPECT_EQ(3u, FunctionalGroupNames.size()); ASSERT_TRUE(FunctionalGroupNames.end() != (it = FunctionalGroupNames.find(129372391))); @@ -1208,12 +1283,12 @@ TEST_F( FillPermissionStruct( "XXX12345ZZZ", "1234", "VR", allowed_groups, disallowed_groups); FunctionalIdType group_types; - ASSERT_TRUE(reps->GetPermissionsForApp("XXX12345ZZZ", "1234", &group_types)); + ASSERT_TRUE(reps_->GetPermissionsForApp("XXX12345ZZZ", "1234", &group_types)); EXPECT_TRUE( CheckGroupTypesExist(group_types, allowed_groups, disallowed_groups)); group_types.clear(); - reps->RemoveAppConsentForGroup("1234", "Notifications"); - ASSERT_TRUE(reps->GetPermissionsForApp("XXX12345ZZZ", "1234", &group_types)); + reps_->RemoveAppConsentForGroup("1234", "Notifications"); + ASSERT_TRUE(reps_->GetPermissionsForApp("XXX12345ZZZ", "1234", &group_types)); allowed_groups.pop_back(); EXPECT_TRUE( CheckGroupTypesExist(group_types, allowed_groups, disallowed_groups)); @@ -1222,25 +1297,25 @@ TEST_F( TEST_F(SQLPTExtRepresentationTest, CleanUnpaireDevices_SetDevicesThenCleanup_ExpectDevicesDeleted) { // Arrange - utils::dbms::SQLQuery query(reps->db()); - reps->SetDeviceData("XXX12345ZZZ", - "hardware IPX", - "v.8.0.1", - "Android", - "4.4.2", - "Life", - 2, - "Bluetooth"); + utils::dbms::SQLQuery query(reps_->db()); + reps_->SetDeviceData("XXX12345ZZZ", + "hardware IPX", + "v.8.0.1", + "Android", + "4.4.2", + "Life", + 2, + "Bluetooth"); StringArray allowed_groups; StringArray disallowed_groups; - EXPECT_TRUE(reps->GetUserPermissionsForDevice( + EXPECT_TRUE(reps_->GetUserPermissionsForDevice( "XXX12345ZZZ", &allowed_groups, &disallowed_groups)); EXPECT_EQ(0u, allowed_groups.size()); EXPECT_EQ(0u, disallowed_groups.size()); allowed_groups.push_back("DataConsent-2"); disallowed_groups.push_back("Navigation-1"); - EXPECT_TRUE(reps->SetUserPermissionsForDevice( + EXPECT_TRUE(reps_->SetUserPermissionsForDevice( "XXX12345ZZZ", allowed_groups, disallowed_groups)); GroupsAliasNameCollection perm_allowed_groups; @@ -1255,7 +1330,7 @@ TEST_F(SQLPTExtRepresentationTest, perm_allowed_groups, perm_disallowed_groups); - EXPECT_TRUE(reps->SetUserPermissionsForApp(perm_consent)); + EXPECT_TRUE(reps_->SetUserPermissionsForApp(perm_consent)); const std::string query_select_device = "SELECT COUNT(*) FROM `device` WHERE `id` = 'XXX12345ZZZ'"; @@ -1277,11 +1352,11 @@ TEST_F(SQLPTExtRepresentationTest, query.Next(); EXPECT_EQ(2, query.GetInteger(0)); - EXPECT_TRUE(reps->SetUnpairedDevice("XXX12345ZZZ", true)); + EXPECT_TRUE(reps_->SetUnpairedDevice("XXX12345ZZZ", true)); std::vector<std::string> DeviceIds; DeviceIds.push_back("XXX12345ZZZ"); - EXPECT_TRUE(reps->CleanupUnpairedDevices(DeviceIds)); + EXPECT_TRUE(reps_->CleanupUnpairedDevices(DeviceIds)); // Assert query.Prepare(query_select_device); @@ -1317,15 +1392,15 @@ TEST_F( disallowed_groups.push_back(std::make_pair("DataConsent", "DataConsent-2")); FillPermissionStruct( "XXX12345ZZZ", "12345", "VR", allowed_groups, disallowed_groups); - EXPECT_TRUE(reps->SetUserPermissionsForApp(perm_consent)); + EXPECT_TRUE(reps_->SetUserPermissionsForApp(perm_consent)); // Act - ASSERT_TRUE(reps->SetIsPredata("12345", true)); + ASSERT_TRUE(reps_->SetIsPredata("12345", true)); // Check - EXPECT_TRUE(reps->IsPredataPolicy("12345")); + EXPECT_TRUE(reps_->IsPredataPolicy("12345")); // Act - EXPECT_TRUE(reps->SetDefaultPolicy("12345")); + EXPECT_TRUE(reps_->SetDefaultPolicy("12345")); // Check - EXPECT_TRUE(reps->IsDefaultPolicy("12345")); + EXPECT_TRUE(reps_->IsDefaultPolicy("12345")); } TEST_F(SQLPTExtRepresentationTest, @@ -1347,16 +1422,16 @@ TEST_F(SQLPTExtRepresentationTest, disallowed_groups.push_back(std::make_pair("DataConsent", "DataConsent-2")); FillPermissionStruct( "XXX12345ZZZ", "12345", "VR", allowed_groups, disallowed_groups); - EXPECT_TRUE(reps->SetUserPermissionsForApp(perm_consent)); - EXPECT_FALSE(reps->IsPredataPolicy("12345")); + EXPECT_TRUE(reps_->SetUserPermissionsForApp(perm_consent)); + EXPECT_FALSE(reps_->IsPredataPolicy("12345")); // Act - ASSERT_TRUE(reps->SetIsPredata("12345", false)); + ASSERT_TRUE(reps_->SetIsPredata("12345", false)); // Check - EXPECT_FALSE(reps->IsPredataPolicy("12345")); + EXPECT_FALSE(reps_->IsPredataPolicy("12345")); // Act - ASSERT_TRUE(reps->SetIsPredata("12345", true)); + ASSERT_TRUE(reps_->SetIsPredata("12345", true)); // Check - EXPECT_TRUE(reps->IsPredataPolicy("12345")); + EXPECT_TRUE(reps_->IsPredataPolicy("12345")); } TEST_F( @@ -1379,12 +1454,12 @@ TEST_F( disallowed_groups.push_back(std::make_pair("DataConsent", "DataConsent-2")); FillPermissionStruct( "XXX12345ZZZ", "12345", "VR", allowed_groups, disallowed_groups); - EXPECT_TRUE(reps->SetUserPermissionsForApp(perm_consent)); - EXPECT_FALSE(reps->IsPredataPolicy("12345")); + EXPECT_TRUE(reps_->SetUserPermissionsForApp(perm_consent)); + EXPECT_FALSE(reps_->IsPredataPolicy("12345")); // Act - ASSERT_TRUE(reps->SetPredataPolicy("12345")); + ASSERT_TRUE(reps_->SetPredataPolicy("12345")); // Check - EXPECT_TRUE(reps->IsPredataPolicy("12345")); + EXPECT_TRUE(reps_->IsPredataPolicy("12345")); } TEST_F(SQLPTExtRepresentationTest, @@ -1408,7 +1483,7 @@ TEST_F(SQLPTExtRepresentationTest, SaveUserConsentRecords_ExpectedSaved) { const std::string device_id = "test_device_id"; const std::string app_id = "test_app_id"; - const std::string ccs_group = "CCSGroup"; + const std::string external_consent_group = "ExternalConsentGroup"; const std::string consent_group = "ConsentGroup"; const std::string time_stamp = "2016-08-29T17:12:07Z"; const Input input = Input::I_GUI; @@ -1420,8 +1495,8 @@ TEST_F(SQLPTExtRepresentationTest, SaveUserConsentRecords_ExpectedSaved) { UserConsentRecords::mapped_type& app_records = user_consent_records[app_id]; - app_records.ccs_consent_groups->insert( - std::make_pair(ccs_group, Boolean(true))); + app_records.external_consent_status_groups->insert( + std::make_pair(external_consent_group, Boolean(true))); app_records.consent_groups->insert( std::make_pair(consent_group, Boolean(true))); @@ -1446,8 +1521,8 @@ TEST_F(SQLPTExtRepresentationTest, SaveUserConsentRecords_ExpectedSaved) { EXPECT_TRUE( (IsKeyExist<ConsentGroups>(*consents.consent_groups, consent_group))); - EXPECT_TRUE( - (IsKeyExist<ConsentGroups>(*consents.ccs_consent_groups, ccs_group))); + EXPECT_TRUE((IsKeyExist<ConsentGroups>( + *consents.external_consent_status_groups, external_consent_group))); EXPECT_EQ((String<1, 255>(time_stamp)), *consents.time_stamp); EXPECT_EQ(input, *consents.input); } @@ -1461,10 +1536,10 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) { const std::string rpc_name = "RpcName"; const std::string user_consent_prompt = "TestConsentPrompt"; const std::string another_user_consent_prompt = "AnotherTestConsentPrompt"; - CCS_Entity off_entity_1(0, 0); - CCS_Entity off_entity_2(0, 1); - CCS_Entity on_entity_1(1, 0); - CCS_Entity on_entity_2(1, 1); + ExternalConsentEntity off_entity_1(0, 0); + ExternalConsentEntity off_entity_2(0, 1); + ExternalConsentEntity on_entity_1(1, 0); + ExternalConsentEntity on_entity_2(1, 1); const HmiLevel test_level_1 = HL_FULL; const HmiLevel test_level_2 = HL_LIMITED; @@ -1473,11 +1548,11 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) { Rpcs rpcs; - rpcs.disallowed_by_ccs_entities_off->push_back(off_entity_1); - rpcs.disallowed_by_ccs_entities_off->push_back(off_entity_2); + rpcs.disallowed_by_external_consent_entities_off->push_back(off_entity_1); + rpcs.disallowed_by_external_consent_entities_off->push_back(off_entity_2); - rpcs.disallowed_by_ccs_entities_on->push_back(on_entity_1); - rpcs.disallowed_by_ccs_entities_on->push_back(on_entity_2); + rpcs.disallowed_by_external_consent_entities_on->push_back(on_entity_1); + rpcs.disallowed_by_external_consent_entities_on->push_back(on_entity_2); *rpcs.user_consent_prompt = user_consent_prompt; @@ -1493,13 +1568,15 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) { original_table.policy_table.functional_groupings; groupings.insert(std::make_pair(group_name, rpcs)); - CCS_Entity off_entity_3(3, 4); - CCS_Entity on_entity_3(5, 6); + ExternalConsentEntity off_entity_3(3, 4); + ExternalConsentEntity on_entity_3(5, 6); Rpcs another_rpcs; - another_rpcs.disallowed_by_ccs_entities_off->push_back(off_entity_3); - another_rpcs.disallowed_by_ccs_entities_on->push_back(on_entity_3); + another_rpcs.disallowed_by_external_consent_entities_off->push_back( + off_entity_3); + another_rpcs.disallowed_by_external_consent_entities_on->push_back( + on_entity_3); *another_rpcs.user_consent_prompt = another_user_consent_prompt; const HmiLevel test_level_3 = HL_BACKGROUND; @@ -1522,15 +1599,15 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) { Rpcs loaded_rpcs = GetKeyData<FunctionalGroupings, Rpcs>(loaded_groupings, group_name); - EXPECT_TRUE((IsKeyExist<DisallowedByCCSEntities>( - *loaded_rpcs.disallowed_by_ccs_entities_off, off_entity_1))); - EXPECT_TRUE((IsKeyExist<DisallowedByCCSEntities>( - *loaded_rpcs.disallowed_by_ccs_entities_off, off_entity_2))); + EXPECT_TRUE((IsKeyExist<DisallowedByExternalConsentEntities>( + *loaded_rpcs.disallowed_by_external_consent_entities_off, off_entity_1))); + EXPECT_TRUE((IsKeyExist<DisallowedByExternalConsentEntities>( + *loaded_rpcs.disallowed_by_external_consent_entities_off, off_entity_2))); - EXPECT_TRUE((IsKeyExist<DisallowedByCCSEntities>( - *loaded_rpcs.disallowed_by_ccs_entities_on, on_entity_1))); - EXPECT_TRUE((IsKeyExist<DisallowedByCCSEntities>( - *loaded_rpcs.disallowed_by_ccs_entities_on, on_entity_2))); + EXPECT_TRUE((IsKeyExist<DisallowedByExternalConsentEntities>( + *loaded_rpcs.disallowed_by_external_consent_entities_on, on_entity_1))); + EXPECT_TRUE((IsKeyExist<DisallowedByExternalConsentEntities>( + *loaded_rpcs.disallowed_by_external_consent_entities_on, on_entity_2))); RpcParameters loaded_parameters = GetKeyData<Rpc, RpcParameters>(loaded_rpcs.rpcs, rpc_name); @@ -1548,11 +1625,13 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) { Rpcs another_loaded_rpcs = GetKeyData<FunctionalGroupings, Rpcs>( loaded_groupings, another_group_name); - EXPECT_TRUE((IsKeyExist<DisallowedByCCSEntities>( - *another_loaded_rpcs.disallowed_by_ccs_entities_off, off_entity_3))); + EXPECT_TRUE((IsKeyExist<DisallowedByExternalConsentEntities>( + *another_loaded_rpcs.disallowed_by_external_consent_entities_off, + off_entity_3))); - EXPECT_TRUE((IsKeyExist<DisallowedByCCSEntities>( - *another_loaded_rpcs.disallowed_by_ccs_entities_on, on_entity_3))); + EXPECT_TRUE((IsKeyExist<DisallowedByExternalConsentEntities>( + *another_loaded_rpcs.disallowed_by_external_consent_entities_on, + on_entity_3))); RpcParameters another_loaded_parameters = GetKeyData<Rpc, RpcParameters>(another_loaded_rpcs.rpcs, rpc_name); @@ -1564,7 +1643,7 @@ TEST_F(SQLPTExtRepresentationTest, SaveFunctionalGroupings_ExpectedSaved) { test_parameter_3))); } -TEST_F(SQLPTExtRepresentationTest, JsonContentsCCS_ExpectParsed) { +TEST_F(SQLPTExtRepresentationTest, JsonContentsExternalConsent_ExpectParsed) { using namespace policy_table; using namespace rpc; @@ -1588,14 +1667,15 @@ TEST_F(SQLPTExtRepresentationTest, JsonContentsCCS_ExpectParsed) { entity_on["entityType"] = entity_on_type; entity_on["entityID"] = entity_on_id; - functional_groupings[group_name]["disallowed_by_ccs_entities_on"][0] = - entity_on; + functional_groupings[group_name]["disallowed_by_external_consent_entities_on"] + [0] = entity_on; Json::Value entity_off = Json::Value(Json::objectValue); entity_off["entityType"] = entity_off_type; entity_off["entityID"] = entity_off_id; - functional_groupings[group_name]["disallowed_by_ccs_entities_off"][0] = - entity_off; + functional_groupings[group_name] + ["disallowed_by_external_consent_entities_off"][0] = + entity_off; policy_table::Table parsed_table(&json_table); @@ -1605,26 +1685,26 @@ TEST_F(SQLPTExtRepresentationTest, JsonContentsCCS_ExpectParsed) { Rpcs loaded_rpcs = GetKeyData<FunctionalGroupings, Rpcs>(loaded_groupings, group_name); - CCS_Entity off_entity_1(entity_off_type, entity_off_id); - CCS_Entity on_entity_1(entity_on_type, entity_on_id); + ExternalConsentEntity off_entity_1(entity_off_type, entity_off_id); + ExternalConsentEntity on_entity_1(entity_on_type, entity_on_id); - EXPECT_TRUE((IsKeyExist<DisallowedByCCSEntities>( - *loaded_rpcs.disallowed_by_ccs_entities_off, off_entity_1))); + EXPECT_TRUE((IsKeyExist<DisallowedByExternalConsentEntities>( + *loaded_rpcs.disallowed_by_external_consent_entities_off, off_entity_1))); - EXPECT_TRUE((IsKeyExist<DisallowedByCCSEntities>( - *loaded_rpcs.disallowed_by_ccs_entities_on, on_entity_1))); + EXPECT_TRUE((IsKeyExist<DisallowedByExternalConsentEntities>( + *loaded_rpcs.disallowed_by_external_consent_entities_on, on_entity_1))); } -TEST_F(SQLPTExtRepresentationTest, SaveCCSStatus_ExpectSaved) { - CCSStatusItem item_1(0, 0, kStatusOn); - CCSStatusItem item_2(1, 1, kStatusOff); - CCSStatus in_status; +TEST_F(SQLPTExtRepresentationTest, SaveExternalConsentStatus_ExpectSaved) { + ExternalConsentStatusItem item_1(0, 0, kStatusOn); + ExternalConsentStatusItem item_2(1, 1, kStatusOff); + ExternalConsentStatus in_status; in_status.insert(item_1); in_status.insert(item_2); - EXPECT_TRUE(reps_->SaveCCSStatus(in_status)); + EXPECT_TRUE(reps_->SaveExternalConsentStatus(in_status)); - CCSStatus out_status = reps_->GetCCSStatus(); + ExternalConsentStatus out_status = reps_->GetExternalConsentStatus(); EXPECT_TRUE(in_status.size() == out_status.size()); EXPECT_TRUE(out_status.end() != diff --git a/src/components/policy/policy_external/test/sql_pt_representation_test.cc b/src/components/policy/policy_external/test/sql_pt_representation_test.cc index 61c769bd61..a0a544deeb 100644 --- a/src/components/policy/policy_external/test/sql_pt_representation_test.cc +++ b/src/components/policy/policy_external/test/sql_pt_representation_test.cc @@ -406,7 +406,9 @@ TEST_F(SQLPTRepresentationTest, // Check PT structure destroyed and tables number is 0 query.Prepare(query_select); query.Next(); - ASSERT_EQ(kPolicyTablesNumber, query.GetInteger(0)); + + const int policy_tables_number = 35; + ASSERT_EQ(policy_tables_number, query.GetInteger(0)); const std::string query_select_count_of_iap_buffer_full = "SELECT `count_of_iap_buffer_full` FROM `usage_and_error_count`"; |