summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcollin <collin+i@collinmcqueen.com>2020-05-13 14:18:47 -0400
committercollin <collin+i@collinmcqueen.com>2020-05-13 14:18:47 -0400
commit82d3ba69bcc1e98769e6d3b8e9b4b675dc4b4998 (patch)
tree22c635df16c8ba595f33e7a0da355320ef1609f1
parent9cc81b71830bf00911b44bd7e88328c6c17683c4 (diff)
downloadsdl_core-fix/rai_dupe_name_id.tar.gz
RAI reply DUPLICATE_NAME when app has same id and name as existing appfix/rai_dupe_name_id
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/register_app_interface_request.h2
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc17
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/register_app_interface_request_test.cc58
3 files changed, 69 insertions, 8 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 d59964bbc7..1321285bde 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 IsApplicationWithSameAppIdRegistered();
+ bool IsApplicationWithSameAppIdOrAppNameRegistered();
/**
* @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 54649980c6..bdb648d815 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,6 +248,11 @@ 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;
}
@@ -282,11 +287,6 @@ 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<mobile_apis::Result::eType, NEQ, ALL>(
@@ -1236,11 +1236,13 @@ void RegisterAppInterfaceRequest::FillDeviceInfo(
}
}
-bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() {
+bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdOrAppNameRegistered() {
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();
@@ -1257,6 +1259,9 @@ bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() {
}
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 6376570106..74c292efa7 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,6 +530,10 @@ 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<am::ApplicationSet>(app_set_, lock_ptr_)));
+
MockAppPtr mock_app = CreateBasicMockedApp();
app_set_.insert(mock_app);
EXPECT_CALL(app_mngr_, reregister_application_by_policy_id(kAppId1))
@@ -543,7 +547,7 @@ TEST_F(RegisterAppInterfaceRequestTest,
ON_CALL(mock_session_observer_, GetDataOnDeviceID(device_id, _, _, _, _))
.WillByDefault(DoAll(SetArgPointee<3>(kMacAddress1), Return(0)));
- EXPECT_CALL(*mock_app, device()).WillOnce(Return(kDeviceHandle));
+ ON_CALL(*mock_app, device()).WillByDefault(Return(kDeviceHandle));
EXPECT_CALL(app_mngr_, ProcessReconnection(_, kConnectionKey));
@@ -577,6 +581,10 @@ 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<am::ApplicationSet>(app_set_, lock_ptr_)));
+
connection_handler::DeviceHandle device_id = 1;
ON_CALL(mock_connection_handler_,
GetDataOnSessionKey(kConnectionKey, _, _, _))
@@ -620,6 +628,10 @@ TEST_F(RegisterAppInterfaceRequestTest,
SwitchApplication_NoHash_ExpectCleanupResumeFailed) {
InitBasicMessage();
+ ON_CALL(app_mngr_, applications())
+ .WillByDefault(
+ Return(DataAccessor<am::ApplicationSet>(app_set_, lock_ptr_)));
+
connection_handler::DeviceHandle device_id = 1;
ON_CALL(mock_connection_handler_,
GetDataOnSessionKey(kConnectionKey, _, _, _))
@@ -654,6 +666,50 @@ TEST_F(RegisterAppInterfaceRequestTest,
}
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<am::ApplicationSet>(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<am::ApplicationSet>(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;