diff options
author | Andrey Oleynik <aoleynik@luxoft.com> | 2017-08-21 15:01:37 +0300 |
---|---|---|
committer | Andrey Oleynik <aoleynik@luxoft.com> | 2017-08-21 16:02:16 +0300 |
commit | 029cc20b415269b002fe1905c1b692301c7226ec (patch) | |
tree | d024dd168026783a487bc1e9c63d98527975bf9a /src/components | |
parent | 08789ae20c7105cbac527c4b044fb2fff9284d07 (diff) | |
download | sdl_core-029cc20b415269b002fe1905c1b692301c7226ec.tar.gz |
Replace CheckAccess with CheckModule for BaseCommandRequest
Removed unused code after that
Diffstat (limited to 'src/components')
29 files changed, 16 insertions, 318 deletions
diff --git a/src/components/application_manager/include/application_manager/core_service.h b/src/components/application_manager/include/application_manager/core_service.h index 56d135efcb..e4512b1080 100644 --- a/src/components/application_manager/include/application_manager/core_service.h +++ b/src/components/application_manager/include/application_manager/core_service.h @@ -71,15 +71,6 @@ class CoreService : public Service { mobile_apis::Result::eType CheckPolicyPermissions(MessagePtr msg) FINAL; /** - * Checks access to requested module of vehicle - * @param app_id id of application - * @param module type - * @return return allowed if module is allowed, otherwise - disallowed - */ - TypeAccess CheckAccess(const ApplicationId& app_id, - const std::string& module) FINAL; - - /** * Checks if module for application is present in policy table * @param app_id id of application * @param module type diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h index f451c19813..4c7f6d6adc 100644 --- a/src/components/application_manager/include/application_manager/policies/policy_handler.h +++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h @@ -144,17 +144,6 @@ class PolicyHandler : public PolicyHandlerInterface, const std::string& hmi_level) OVERRIDE; /** - * Checks access to module of vehicle for application - * @param device_id unique identifier of device - * @param app_id policy id application - * @param module module name - * @return Allowed if module is allowed, otherwise disallowed - */ - application_manager::TypeAccess CheckAccess(const PTString& device_id, - const PTString& app_id, - const PTString& module) OVERRIDE; - - /** * Checks if module for application is present in policy table * @param app_id id of application * @param module type diff --git a/src/components/application_manager/include/application_manager/service.h b/src/components/application_manager/include/application_manager/service.h index be2570db3e..1c34b06209 100644 --- a/src/components/application_manager/include/application_manager/service.h +++ b/src/components/application_manager/include/application_manager/service.h @@ -42,7 +42,7 @@ namespace application_manager { -enum TypeAccess { kNone, kDisallowed, kAllowed }; +enum TypeAccess { kDisallowed, kAllowed }; enum MessageValidationResult { SUCCESS = 0, @@ -70,16 +70,6 @@ class Service { virtual mobile_apis::Result::eType CheckPolicyPermissions(MessagePtr msg) = 0; /** - * Checks access to module of vehicle for application - * @param device_id unique identifier of device - * @param app_id policy id application - * @param module module name - * @return Allowed if module is allowed, otherwise disallowed - */ - virtual TypeAccess CheckAccess(const ApplicationId& app_id, - const std::string& module) = 0; - - /** * Checks if module for application is present in policy table * @param app_id id of application * @param module type diff --git a/src/components/application_manager/src/core_service.cc b/src/components/application_manager/src/core_service.cc index 4e41744e27..d0e8bdd5f3 100644 --- a/src/components/application_manager/src/core_service.cc +++ b/src/components/application_manager/src/core_service.cc @@ -82,20 +82,6 @@ mobile_apis::Result::eType CoreService::CheckPolicyPermissions(MessagePtr msg) { #endif // SDL_REMOTE_CONTROL } -TypeAccess CoreService::CheckAccess(const ApplicationId& app_id, - const std::string& module) { -#ifdef SDL_REMOTE_CONTROL - ApplicationSharedPtr app = GetApplication(app_id); - if (app) { - std::string device_handle = MessageHelper::GetDeviceMacAddressForHandle( - app->device(), application_manager_); - return application_manager_.GetPolicyHandler().CheckAccess( - device_handle, app->policy_app_id(), module); - } -#endif // SDL_REMOTE_CONTROL - return kNone; -} - bool CoreService::CheckModule(const ApplicationId& app_id, const std::string& module) { #ifdef SDL_REMOTE_CONTROL diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index ae4fb033e9..10c1608b8c 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1955,23 +1955,6 @@ std::vector<std::string> PolicyHandler::GetDevicesIds( return application_manager_.devices(policy_app_id); } -namespace { -application_manager::TypeAccess ConvertTypeAccess(policy::TypeAccess access) { - application_manager::TypeAccess converted; - switch (access) { - case policy::TypeAccess::kAllowed: - converted = application_manager::TypeAccess::kAllowed; - break; - case policy::TypeAccess::kDisallowed: - converted = application_manager::TypeAccess::kDisallowed; - break; - default: - converted = application_manager::TypeAccess::kNone; - } - return converted; -} -} // namespace - void PolicyHandler::UpdateHMILevel(ApplicationSharedPtr app, mobile_apis::HMILevel::eType level) { LOG4CXX_AUTO_TRACE(logger_); @@ -1992,14 +1975,6 @@ void PolicyHandler::UpdateHMILevel(ApplicationSharedPtr app, } } -application_manager::TypeAccess PolicyHandler::CheckAccess( - const PTString& device_id, const PTString& app_id, const PTString& module) { - POLICY_LIB_CHECK(application_manager::TypeAccess::kNone); - policy::TypeAccess access = - policy_manager_->CheckAccess(device_id, app_id, module); - return ConvertTypeAccess(access); -} - bool PolicyHandler::CheckModule(const PTString& app_id, const PTString& module) { POLICY_LIB_CHECK(false); diff --git a/src/components/application_manager/test/rc_policy_handler_test.cc b/src/components/application_manager/test/rc_policy_handler_test.cc index efc3f5d46d..7faf3e36cb 100644 --- a/src/components/application_manager/test/rc_policy_handler_test.cc +++ b/src/components/application_manager/test/rc_policy_handler_test.cc @@ -267,27 +267,6 @@ TEST_F(RCPolicyHandlerTest, OnUpdateHMILevel_HmiLevelChanged_SUCCESS) { policy_handler_.OnUpdateHMILevel(kDeviceId_, kPolicyAppId_, hmi_level); } -TEST_F(RCPolicyHandlerTest, CheckAccess_ValidParams_SUCCESS) { - EnablePolicyAndPolicyManagerMock(); - - const PTString module("module"); - const PTString pt_rpc("rpc"); - const std::vector<PTString> params; - - EXPECT_CALL(*mock_policy_manager_, - CheckAccess(kDeviceId_, kPolicyAppId_, module)) - .WillOnce(Return(policy::TypeAccess::kDisallowed)); - EXPECT_EQ(application_manager::TypeAccess::kDisallowed, - policy_handler_.CheckAccess(kDeviceId_, kPolicyAppId_, module)); - - EXPECT_CALL(*mock_policy_manager_, - CheckAccess(kDeviceId_, kPolicyAppId_, module)) - .WillOnce(Return(policy::TypeAccess::kAllowed)); - - EXPECT_EQ(application_manager::TypeAccess::kAllowed, - policy_handler_.CheckAccess(kDeviceId_, kPolicyAppId_, module)); -} - TEST_F(RCPolicyHandlerTest, CheckModule_SUCCESS) { EnablePolicyAndPolicyManagerMock(); diff --git a/src/components/functional_module/test/include/mock_service.h b/src/components/functional_module/test/include/mock_service.h index c9f2d91dfb..947896051f 100644 --- a/src/components/functional_module/test/include/mock_service.h +++ b/src/components/functional_module/test/include/mock_service.h @@ -56,9 +56,6 @@ class MockService : public Service { void(ApplicationSharedPtr app, mobile_apis::HMILevel::eType level)); MOCK_CONST_METHOD0(GetRCCapabilities, const smart_objects::SmartObject*()); - MOCK_METHOD2(CheckAccess, - TypeAccess(const ApplicationId& app_id, - const std::string& module)); MOCK_METHOD2(CheckModule, bool(const ApplicationId& app_id, const std::string& module)); MOCK_METHOD1(RemoveHMIFakeParameters, diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h index 1b27ee7e94..4d2d09b412 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -449,18 +449,6 @@ class PolicyHandlerInterface { const std::string& hmi_level) = 0; /** - * Checks access to module of vehicle for application - * @param device_id unique identifier of device - * @param app_id policy id application - * @param module module name - * @return Allowed if module is allowed, otherwise disallowed - */ - virtual application_manager::TypeAccess CheckAccess( - const PTString& device_id, - const PTString& app_id, - const PTString& module) = 0; - - /** * Checks if module for application is present in policy table * @param app_id id of application * @param module type diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index 2642f600cc..302f1639b7 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -522,17 +522,6 @@ class PolicyManager : public usage_statistics::StatisticsManager { std::vector<int>* app_types) = 0; /** - * Checks access to module of vehicle for application - * @param device_id unique identifier of device - * @param app_id policy id application - * @param module module name - * @return Allowed if module is allowed, otherwise disallowed - */ - virtual TypeAccess CheckAccess(const PTString& device_id, - const PTString& app_id, - const PTString& module) = 0; - - /** * Checks if module for application is present in policy table * @param app_id id of application * @param module type diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h index 4d8ed65628..2acbb4c254 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -496,17 +496,6 @@ class PolicyManager : public usage_statistics::StatisticsManager { std::vector<int>* app_types) = 0; /** - * Checks access to module of vehicle for application - * @param device_id unique identifier of device - * @param app_id policy id application - * @param module module name - * @return Allowed if module is allowed, otherwise disallowed - */ - virtual TypeAccess CheckAccess(const PTString& device_id, - const PTString& app_id, - const PTString& module) = 0; - - /** * Checks if module for application is present in policy table * @param app_id id of application * @param module type diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h index 60420d1f5f..812df19ccd 100644 --- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h +++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h @@ -236,11 +236,6 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { bool(const std::string& application_id, mobile_apis::AppHMIType::eType hmi, const smart_objects::SmartObject* app_types)); - MOCK_METHOD3( - CheckAccess, - application_manager::TypeAccess(const policy::PTString& device_id, - const policy::PTString& app_id, - const policy::PTString& module)); MOCK_METHOD2(CheckModule, bool(const policy::PTString& app_id, diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index 7892de65f3..83874b1c2f 100644 --- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h @@ -155,10 +155,6 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(GetHMITypes, bool(const std::string& application_id, std::vector<int>* app_types)); - MOCK_METHOD3(CheckAccess, - TypeAccess(const PTString& device_id, - const PTString& app_id, - const PTString& module)); MOCK_METHOD2(CheckModule, bool(const PTString& app_id, const PTString& module)); MOCK_METHOD2(SendAppPermissionsChanged, diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index a3f93511c9..0987da4bd7 100644 --- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h +++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h @@ -154,10 +154,6 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(GetHMITypes, bool(const std::string& application_id, std::vector<int>* app_types)); - MOCK_METHOD3(CheckAccess, - TypeAccess(const PTString& device_id, - const PTString& app_id, - const PTString& module)); MOCK_METHOD2(CheckModule, bool(const PTString& app_id, const PTString& module)); MOCK_METHOD2(SendAppPermissionsChanged, diff --git a/src/components/policy/policy_external/include/policy/access_remote_impl.h b/src/components/policy/policy_external/include/policy/access_remote_impl.h index f1518e052c..268153f7f4 100644 --- a/src/components/policy/policy_external/include/policy/access_remote_impl.h +++ b/src/components/policy/policy_external/include/policy/access_remote_impl.h @@ -60,8 +60,6 @@ class AccessRemoteImpl : public AccessRemote { std::vector<std::string>* modules); private: - typedef std::map<Subject, TypeAccess> AccessControlRow; - typedef std::map<Object, AccessControlRow> AccessControlList; typedef std::map<Subject, policy_table::AppHMITypes> HMIList; inline void set_enabled(bool value); inline bool country_consent() const; @@ -77,7 +75,6 @@ class AccessRemoteImpl : public AccessRemote { RemoteControlParams* input) const; utils::SharedPtr<CacheManager> cache_; bool enabled_; - AccessControlList acl_; HMIList hmi_types_; friend struct Erase; diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h index 93cd07349e..b6865b645f 100644 --- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h @@ -380,9 +380,6 @@ class PolicyManagerImpl : public PolicyManager { void GetPermissions(const std::string device_id, const std::string application_id, Permissions* data); - virtual TypeAccess CheckAccess(const PTString& device_id, - const PTString& app_id, - const PTString& module); virtual bool CheckModule(const PTString& app_id, const PTString& module); virtual void SendAppPermissionsChanged(const std::string& device_id, const std::string& application_id); diff --git a/src/components/policy/policy_external/src/access_remote_impl.cc b/src/components/policy/policy_external/src/access_remote_impl.cc index a5628c5790..410c5f7520 100644 --- a/src/components/policy/policy_external/src/access_remote_impl.cc +++ b/src/components/policy/policy_external/src/access_remote_impl.cc @@ -44,29 +44,6 @@ using rpc::policy_table_interface_base::EnumFromJsonString; namespace policy { -struct Erase { - private: - const Subject& who_; - - public: - explicit Erase(const Subject& who) : who_(who) {} - void operator()(AccessRemoteImpl::AccessControlList::value_type& row) const { - row.second.erase(who_); - } -}; - -struct IsTypeAccess { - private: - const TypeAccess& type_; - - public: - explicit IsTypeAccess(const TypeAccess& type) : type_(type) {} - bool operator()( - const AccessRemoteImpl::AccessControlRow::value_type& item) const { - return item.second == type_; - } -}; - struct ToHMIType { policy_table::AppHMITypes::value_type operator()(int item) const { policy_table::AppHMIType type = static_cast<policy_table::AppHMIType>(item); @@ -110,29 +87,10 @@ struct ToModuleType { } }; -AccessRemoteImpl::AccessRemoteImpl() : cache_(new CacheManager()), acl_() {} +AccessRemoteImpl::AccessRemoteImpl() : cache_(new CacheManager()) {} AccessRemoteImpl::AccessRemoteImpl(utils::SharedPtr<CacheManager> cache) - : cache_(cache), acl_() {} - -TypeAccess AccessRemoteImpl::Check(const Subject& who, - const Object& what) const { - LOG4CXX_AUTO_TRACE(logger_); - AccessControlList::const_iterator i = acl_.find(what); - if (i != acl_.end()) { - const AccessControlRow& row = i->second; - AccessControlRow::const_iterator j = row.find(who); - if (j != row.end()) { - // who has permissions - TypeAccess ret = j->second; - LOG4CXX_TRACE(logger_, - "Subject " << who << " has permissions " << ret - << " to object " << what); - return ret; - } - } - return TypeAccess::kAllowed; -} + : cache_(cache) {} bool AccessRemoteImpl::CheckModuleType(const PTString& app_id, policy_table::ModuleType module) const { diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 779933906a..7e7dd2b7c1 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -1964,23 +1964,6 @@ bool PolicyManagerImpl::GetHMITypes(const std::string& application_id, return hmi_types; } -TypeAccess PolicyManagerImpl::CheckAccess(const PTString& device_id, - const PTString& app_id, - const PTString& module, - const PTString& rpc, - const RemoteControlParams& params) { - LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "Module type: " << module); - - policy_table::ModuleType module_type; - bool is_valid = EnumFromJsonString(module, &module_type); - if (is_valid && access_remote_->CheckModuleType(app_id, module_type)) { - return TypeAccess::kAllowed; - } - LOG4CXX_DEBUG(logger_, TypeAccess::kDisallowed); - return TypeAccess::kDisallowed; -} - bool PolicyManagerImpl::CheckModule(const PTString& app_id, const PTString& module) { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/policy/policy_external/test/include/policy/mock_access_remote.h b/src/components/policy/policy_external/test/include/policy/mock_access_remote.h index a0cb60fa9a..151958fd95 100644 --- a/src/components/policy/policy_external/test/include/policy/mock_access_remote.h +++ b/src/components/policy/policy_external/test/include/policy/mock_access_remote.h @@ -49,20 +49,6 @@ class MockObject : public policy::Object { class MockAccessRemote : public policy::AccessRemote { public: - MOCK_METHOD0(Init, void()); - MOCK_METHOD0(Enable, void()); - MOCK_METHOD0(Disable, void()); - MOCK_CONST_METHOD0(IsEnabled, bool()); - - MOCK_METHOD2(Allow, - void(const policy::Subject& who, const policy::Object& what)); - MOCK_METHOD2(Deny, - void(const policy::Subject& who, const policy::Object& what)); - MOCK_METHOD1(Reset, void(const policy::Subject& who)); - MOCK_METHOD1(Reset, void(const policy::Object& what)); - MOCK_CONST_METHOD2(Check, - policy::TypeAccess(const policy::Subject& who, - const policy::Object& what)); MOCK_CONST_METHOD3( FindGroup, policy::PTString(const policy::Subject& who, @@ -81,7 +67,6 @@ class MockAccessRemote : public policy::AccessRemote { bool(const policy::PTString& app_id, policy_table::ModuleType module)); MOCK_METHOD1(IsAppRemoteControl, bool(const policy::Subject& who)); - MOCK_METHOD0(Reset, void()); MOCK_METHOD2(GetModuleTypes, bool(const std::string& application_id, std::vector<std::string>* modules)); diff --git a/src/components/policy/policy_regular/include/policy/access_remote.h b/src/components/policy/policy_regular/include/policy/access_remote.h index 0097b3d5c7..a3d7e7dc3a 100644 --- a/src/components/policy/policy_regular/include/policy/access_remote.h +++ b/src/components/policy/policy_regular/include/policy/access_remote.h @@ -41,23 +41,6 @@ namespace policy_table = ::rpc::policy_table_interface_base; namespace policy { - -enum TypeAccess { kDisallowed, kAllowed }; -inline std::ostream& operator<<(std::ostream& output, TypeAccess x) { - output << "Access: "; - switch (x) { - case kDisallowed: - output << "DISALLOWED"; - break; - case kAllowed: - output << "ALLOWED"; - break; - default: - output << "Error: Unknown type"; - } - return output; -} - struct Subject { PTString dev_id; PTString app_id; diff --git a/src/components/policy/policy_regular/include/policy/access_remote_impl.h b/src/components/policy/policy_regular/include/policy/access_remote_impl.h index bf9d8e1d36..df93808776 100644 --- a/src/components/policy/policy_regular/include/policy/access_remote_impl.h +++ b/src/components/policy/policy_regular/include/policy/access_remote_impl.h @@ -45,8 +45,6 @@ namespace policy { class AccessRemoteImpl : public AccessRemote { public: - typedef std::map<Subject, TypeAccess> AccessControlRow; - typedef std::map<Object, AccessControlRow> AccessControlList; typedef std::map<Subject, policy_table::AppHMITypes> HMIList; AccessRemoteImpl(); diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h index 648fd85db6..f8362f8546 100644 --- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h +++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h @@ -352,9 +352,6 @@ class PolicyManagerImpl : public PolicyManager { void GetPermissions(const std::string device_id, const std::string application_id, Permissions* data); - virtual TypeAccess CheckAccess(const PTString& device_id, - const PTString& app_id, - const PTString& module); virtual bool CheckModule(const PTString& app_id, const PTString& module); virtual void SendAppPermissionsChanged(const std::string& device_id, const std::string& application_id); diff --git a/src/components/policy/policy_regular/src/access_remote_impl.cc b/src/components/policy/policy_regular/src/access_remote_impl.cc index dfdb6ab579..029bbfaa71 100644 --- a/src/components/policy/policy_regular/src/access_remote_impl.cc +++ b/src/components/policy/policy_regular/src/access_remote_impl.cc @@ -44,29 +44,6 @@ using rpc::policy_table_interface_base::EnumFromJsonString; namespace policy { -struct Erase { - private: - const Subject& who_; - - public: - explicit Erase(const Subject& who) : who_(who) {} - void operator()(AccessRemoteImpl::AccessControlList::value_type& row) const { - row.second.erase(who_); - } -}; - -struct IsTypeAccess { - private: - const TypeAccess& type_; - - public: - explicit IsTypeAccess(const TypeAccess& type) : type_(type) {} - bool operator()( - const AccessRemoteImpl::AccessControlRow::value_type& item) const { - return item.second == type_; - } -}; - struct ToHMIType { policy_table::AppHMITypes::value_type operator()(int item) const { policy_table::AppHMIType type = static_cast<policy_table::AppHMIType>(item); diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index db076e3108..30e2be537b 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -1196,21 +1196,6 @@ bool PolicyManagerImpl::GetHMITypes(const std::string& application_id, return hmi_types; } -TypeAccess PolicyManagerImpl::CheckAccess(const PTString& device_id, - const PTString& app_id, - const PTString& module) { - LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "Module type: " << module); - - policy_table::ModuleType module_type; - bool is_valid = EnumFromJsonString(module, &module_type); - if (is_valid && access_remote_->CheckModuleType(app_id, module_type)) { - return TypeAccess::kAllowed; - } - LOG4CXX_DEBUG(logger_, TypeAccess::kDisallowed); - return TypeAccess::kDisallowed; -} - bool PolicyManagerImpl::CheckModule(const PTString& app_id, const PTString& module) { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/policy/policy_regular/test/include/policy/mock_access_remote.h b/src/components/policy/policy_regular/test/include/policy/mock_access_remote.h index ffd0c5eba0..7b7191d52d 100644 --- a/src/components/policy/policy_regular/test/include/policy/mock_access_remote.h +++ b/src/components/policy/policy_regular/test/include/policy/mock_access_remote.h @@ -49,19 +49,6 @@ class MockObject : public policy::Object { class MockAccessRemote : public policy::AccessRemote { public: - MOCK_METHOD0(Init, void()); - MOCK_METHOD0(Enable, void()); - MOCK_METHOD0(Disable, void()); - MOCK_CONST_METHOD0(IsEnabled, bool()); - MOCK_METHOD2(Allow, - void(const policy::Subject& who, const policy::Object& what)); - MOCK_METHOD2(Deny, - void(const policy::Subject& who, const policy::Object& what)); - MOCK_METHOD1(Reset, void(const policy::Subject& who)); - MOCK_METHOD1(Reset, void(const policy::Object& what)); - MOCK_CONST_METHOD2(Check, - policy::TypeAccess(const policy::Subject& who, - const policy::Object& what)); MOCK_CONST_METHOD3( FindGroup, policy::PTString(const policy::Subject& who, @@ -80,7 +67,6 @@ class MockAccessRemote : public policy::AccessRemote { bool(const policy::PTString& app_id, policy_table::ModuleType module)); MOCK_METHOD1(IsAppRemoteControl, bool(const policy::Subject& who)); - MOCK_METHOD0(Reset, void()); MOCK_METHOD2(GetModuleTypes, bool(const std::string& application_id, std::vector<std::string>* modules)); diff --git a/src/components/remote_control/include/remote_control/commands/base_command_request.h b/src/components/remote_control/include/remote_control/commands/base_command_request.h index 315acfd6c2..a76f972930 100644 --- a/src/components/remote_control/include/remote_control/commands/base_command_request.h +++ b/src/components/remote_control/include/remote_control/commands/base_command_request.h @@ -229,7 +229,7 @@ class BaseCommandRequest virtual std::string ModuleType(const Json::Value& message); virtual std::vector<std::string> ControlData(const Json::Value& message); - virtual application_manager::TypeAccess CheckAccess( + virtual application_manager::TypeAccess CheckModule( const Json::Value& message); bool auto_allowed() const { diff --git a/src/components/remote_control/src/commands/base_command_request.cc b/src/components/remote_control/src/commands/base_command_request.cc index 150d79d18b..3961b79688 100644 --- a/src/components/remote_control/src/commands/base_command_request.cc +++ b/src/components/remote_control/src/commands/base_command_request.cc @@ -362,13 +362,15 @@ bool BaseCommandRequest::CheckPolicyPermissions() { return true; } -application_manager::TypeAccess BaseCommandRequest::CheckAccess( +application_manager::TypeAccess BaseCommandRequest::CheckModule( const Json::Value& message) { const std::string& module = ModuleType(message); - return service_->CheckAccess(app_->app_id(), module); + return service_->CheckModule(app_->app_id(), module) + ? application_manager::TypeAccess::kAllowed + : application_manager::TypeAccess::kDisallowed; } -bool BaseCommandRequest:: CheckDriverConsent() { +bool BaseCommandRequest::CheckDriverConsent() { LOG4CXX_AUTO_TRACE(logger_); RCAppExtensionPtr extension = GetAppExtension(app_); if (!extension) { @@ -379,7 +381,7 @@ bool BaseCommandRequest:: CheckDriverConsent() { LOG4CXX_DEBUG(logger_, "Request: " << message_->json_message()); reader.parse(message_->json_message(), value); - application_manager::TypeAccess access = CheckAccess(value); + application_manager::TypeAccess access = CheckModule(value); if (IsAutoAllowed(access)) { set_auto_allowed(true); @@ -449,9 +451,6 @@ void BaseCommandRequest::SendDisallowed( ? "The RPC is disallowed by vehicle settings" : disallowed_info_; break; - case application_manager::kNone: - info = "Internal issue"; - break; default: info = "Unknown issue"; } @@ -572,7 +571,6 @@ void BaseCommandRequest::CheckHMILevel(application_manager::TypeAccess access, } break; case application_manager::kDisallowed: - case application_manager::kNone: default: LOG4CXX_DEBUG(logger_, "No access information or disallowed: " diff --git a/src/components/remote_control/test/commands/button_press_request_test.cc b/src/components/remote_control/test/commands/button_press_request_test.cc index 4423f8cad8..063aa59b6f 100644 --- a/src/components/remote_control/test/commands/button_press_request_test.cc +++ b/src/components/remote_control/test/commands/button_press_request_test.cc @@ -199,8 +199,7 @@ TEST_F(ButtonPressRequestTest, application_manager::AppExtensionPtr app_extension; EXPECT_CALL(*mock_app_, AddExtension(_)) .WillOnce(DoAll(SaveArg<0>(&app_extension), Return(true))); - EXPECT_CALL(*mock_service_, CheckAccess(_, _)) - .WillOnce(Return(application_manager::TypeAccess::kAllowed)); + EXPECT_CALL(*mock_service_, CheckModule(_, _)).WillOnce(Return(true)); EXPECT_CALL(*mock_service_, GetNextCorrelationID()).WillOnce(Return(1)); const std::string resource = "CLIMATE"; @@ -255,8 +254,7 @@ TEST_F( application_manager::AppExtensionPtr app_extension; EXPECT_CALL(*mock_app_, AddExtension(_)) .WillOnce(DoAll(SaveArg<0>(&app_extension), Return(true))); - EXPECT_CALL(*mock_service_, CheckAccess(_, _)) - .WillOnce(Return(application_manager::TypeAccess::kAllowed)); + EXPECT_CALL(*mock_service_, CheckModule(_, _)).WillOnce(Return(true)); EXPECT_CALL(mock_allocation_manager_, IsResourceFree(_)) .WillOnce(Return(true)); EXPECT_CALL(mock_allocation_manager_, AcquireResource(_, _)) diff --git a/src/components/remote_control/test/commands/get_interior_vehicle_data_request_test.cc b/src/components/remote_control/test/commands/get_interior_vehicle_data_request_test.cc index 98404b441a..5e7366f48c 100644 --- a/src/components/remote_control/test/commands/get_interior_vehicle_data_request_test.cc +++ b/src/components/remote_control/test/commands/get_interior_vehicle_data_request_test.cc @@ -164,8 +164,7 @@ TEST_F(GetInteriorVehicleDataRequestTest, application_manager::AppExtensionPtr app_extension; EXPECT_CALL(*mock_app_, AddExtension(_)) .WillOnce(DoAll(SaveArg<0>(&app_extension), Return(true))); - EXPECT_CALL(*mock_service_, CheckAccess(_, _)) - .WillOnce(Return(application_manager::TypeAccess::kAllowed)); + EXPECT_CALL(*mock_service_, CheckModule(_, _)).WillOnce(Return(true)); EXPECT_CALL(*mock_service_, GetNextCorrelationID()).WillOnce(Return(1)); application_manager::MessagePtr result_msg; EXPECT_CALL(*mock_service_, SendMessageToHMI(_)) diff --git a/src/components/remote_control/test/commands/set_interior_vehicle_data_request_test.cc b/src/components/remote_control/test/commands/set_interior_vehicle_data_request_test.cc index b8e27a9c42..ac8548dd0d 100644 --- a/src/components/remote_control/test/commands/set_interior_vehicle_data_request_test.cc +++ b/src/components/remote_control/test/commands/set_interior_vehicle_data_request_test.cc @@ -174,8 +174,7 @@ TEST_F(SetInteriorVehicleDataRequestTest, application_manager::AppExtensionPtr app_extension; EXPECT_CALL(*mock_app_, AddExtension(_)) .WillOnce(DoAll(SaveArg<0>(&app_extension), Return(true))); - EXPECT_CALL(*mock_service_, CheckAccess(_, _)) - .WillOnce(Return(application_manager::TypeAccess::kAllowed)); + EXPECT_CALL(*mock_service_, CheckModule(_, _)).WillOnce(Return(true)); EXPECT_CALL(*mock_service_, GetNextCorrelationID()) .WillOnce(Return(kCorrelationId)); @@ -242,8 +241,7 @@ TEST_F( application_manager::AppExtensionPtr app_extension; EXPECT_CALL(*mock_app_, AddExtension(_)) .WillOnce(DoAll(SaveArg<0>(&app_extension), Return(true))); - EXPECT_CALL(*mock_service_, CheckAccess(_, _)) - .WillOnce(Return(application_manager::TypeAccess::kAllowed)); + EXPECT_CALL(*mock_service_, CheckModule(_, _)).WillOnce(Return(true)); EXPECT_CALL(*mock_service_, GetNextCorrelationID()) .WillOnce(Return(kCorrelationId)); @@ -312,8 +310,7 @@ TEST_F(SetInteriorVehicleDataRequestTest, application_manager::AppExtensionPtr app_extension; EXPECT_CALL(*mock_app_, AddExtension(_)) .WillOnce(DoAll(SaveArg<0>(&app_extension), Return(true))); - EXPECT_CALL(*mock_service_, CheckAccess(_, _)) - .WillOnce(Return(application_manager::TypeAccess::kAllowed)); + EXPECT_CALL(*mock_service_, CheckModule(_, _)).WillOnce(Return(true)); EXPECT_CALL(*mock_service_, SendMessageToHMI(_)).Times(0); application_manager::MessagePtr result_msg; |