From 8139bd6d796008c62c6f4ee7d5f06168efeb1052 Mon Sep 17 00:00:00 2001 From: collin Date: Wed, 13 May 2020 14:17:08 -0400 Subject: Revert "RAI reply DUPLICATE_NAME when app has same id and name as existing app" This reverts commit 236bdbaa283147044a6144f8c96cc43b82ff1014. --- .../mobile/register_app_interface_request.h | 2 +- .../mobile/register_app_interface_request.cc | 17 +++---- .../mobile/register_app_interface_request_test.cc | 58 +--------------------- 3 files changed, 8 insertions(+), 69 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h index 1321285bde..d59964bbc7 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h @@ -140,7 +140,7 @@ class RegisterAppInterfaceRequest * * return TRUE if ID is known already, otherwise - FALSE */ - bool IsApplicationWithSameAppIdOrAppNameRegistered(); + bool IsApplicationWithSameAppIdRegistered(); /** * @brief Check new application parameters (name, tts, vr) for diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index bdb648d815..54649980c6 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -248,11 +248,6 @@ void RegisterAppInterfaceRequest::Run() { logger_, "device_handle: " << device_handle_ << " device_id: " << device_id_); - if (IsApplicationWithSameAppIdOrAppNameRegistered()) { - SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); - return; - } - if (IsApplicationSwitched()) { return; } @@ -287,6 +282,11 @@ void RegisterAppInterfaceRequest::Run() { (*message_)[strings::msg_params][strings::full_app_id] = new_app_id_full; } + if (IsApplicationWithSameAppIdRegistered()) { + SendResponse(false, mobile_apis::Result::DISALLOWED); + return; + } + mobile_apis::Result::eType policy_result = CheckWithPolicyData(); if (Compare( @@ -1236,13 +1236,11 @@ void RegisterAppInterfaceRequest::FillDeviceInfo( } } -bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdOrAppNameRegistered() { +bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() { LOG4CXX_AUTO_TRACE(logger_); const custom_string::CustomString mobile_app_id( application_manager_.GetCorrectMobileIDFromMessage(message_)); - const custom_str::CustomString& app_name = - (*message_)[strings::msg_params][strings::app_name].asCustomString(); const auto& applications = application_manager_.applications().GetData(); @@ -1259,9 +1257,6 @@ bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdOrAppNameRegistered( } return true; } - if (app_name.CompareIgnoreCase(app->name())) { - return true; - } } return false; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc index 74c292efa7..6376570106 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc @@ -530,10 +530,6 @@ TEST_F(RegisterAppInterfaceRequestTest, const std::string request_hash_id = "abc123"; (*msg_)[am::strings::msg_params][am::strings::hash_id] = request_hash_id; - ON_CALL(app_mngr_, applications()) - .WillByDefault( - Return(DataAccessor(app_set_, lock_ptr_))); - MockAppPtr mock_app = CreateBasicMockedApp(); app_set_.insert(mock_app); EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1)) @@ -547,7 +543,7 @@ TEST_F(RegisterAppInterfaceRequestTest, ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id, _, _, _, _)) .WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0))); - ON_CALL(*mock_app, device()).WillByDefault(Return(kDeviceHandle)); + EXPECT_CALL(*mock_app, device()).WillOnce(Return(kDeviceHandle)); EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey)); @@ -581,10 +577,6 @@ TEST_F(RegisterAppInterfaceRequestTest, const std::string request_hash_id = "abc123"; (*msg_)[am::strings::msg_params][am::strings::hash_id] = request_hash_id; - ON_CALL(app_mngr_, applications()) - .WillByDefault( - Return(DataAccessor(app_set_, lock_ptr_))); - connection_handler::DeviceHandle device_id = 1; ON_CALL(mock_connection_handler_, GetDataOnSessionKey(kConnectionKey, _, _, _)) @@ -628,10 +620,6 @@ TEST_F(RegisterAppInterfaceRequestTest, SwitchApplication_NoHash_ExpectCleanupResumeFailed) { InitBasicMessage(); - ON_CALL(app_mngr_, applications()) - .WillByDefault( - Return(DataAccessor(app_set_, lock_ptr_))); - connection_handler::DeviceHandle device_id = 1; ON_CALL(mock_connection_handler_, GetDataOnSessionKey(kConnectionKey, _, _, _)) @@ -665,50 +653,6 @@ TEST_F(RegisterAppInterfaceRequestTest, command_->Run(); } -TEST_F(RegisterAppInterfaceRequestTest, - Run_Other_App_With_Same_App_Name_DUPLICATE_NAME) { - InitBasicMessage(); - - app_set_.insert(CreateBasicMockedApp()); - - const uint32_t kConnection_key_ = 2u; - const std::string kApp_Id = "other_app_id"; - (*msg_)[am::strings::params][am::strings::connection_key] = kConnection_key_; - (*msg_)[am::strings::msg_params][am::strings::app_id] = kApp_Id; - - ON_CALL(app_mngr_, applications()) - .WillByDefault( - Return(DataAccessor(app_set_, lock_ptr_))); - - EXPECT_CALL(mock_rpc_service_, - ManageMobileCommand( - MobileResultCodeIs(mobile_apis::Result::DUPLICATE_NAME), _)); - - command_->Run(); -} - -TEST_F(RegisterAppInterfaceRequestTest, - Run_Other_App_With_Same_App_ID_DUPLICATE_NAME) { - InitBasicMessage(); - - app_set_.insert(CreateBasicMockedApp()); - - const uint32_t kConnection_key_ = 2u; - const std::string kApp_Name = "other_app_name"; - (*msg_)[am::strings::params][am::strings::connection_key] = kConnection_key_; - (*msg_)[am::strings::msg_params][am::strings::app_name] = kApp_Name; - - ON_CALL(app_mngr_, applications()) - .WillByDefault( - Return(DataAccessor(app_set_, lock_ptr_))); - - EXPECT_CALL(mock_rpc_service_, - ManageMobileCommand( - MobileResultCodeIs(mobile_apis::Result::DUPLICATE_NAME), _)); - - command_->Run(); -} - TEST_F(RegisterAppInterfaceRequestTest, RegisterApp_SameAppId_SameDeviceFailed) { using namespace am; -- cgit v1.2.1