Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,11 @@ mobile_apis::Result::eType CommandRequestImpl::GetMobileResultCode(
bool CommandRequestImpl::CheckAllowedParameters() {
LOG4CXX_AUTO_TRACE(logger_);

// RegisterAppInterface should always be allowed
if (mobile_apis::FunctionID::RegisterAppInterfaceID ==
static_cast<mobile_apis::FunctionID::eType>(function_id())) {
// RegisterAppInterface and UnregisterAppInterface should always be allowed
const mobile_apis::FunctionID::eType func_id =
static_cast<mobile_apis::FunctionID::eType>(function_id());
if (mobile_apis::FunctionID::RegisterAppInterfaceID == func_id ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pvvasilev I propose you to use helpers::Compare here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mobile_apis::FunctionID::UnregisterAppInterfaceID == func_id) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,26 @@ TEST_F(CommandRequestImplTest,
(*result)[strings::msg_params][strings::info].asString().empty());
}

TEST_F(CommandRequestImplTest, CheckPermissions_UnregisterAppInterface_True) {
MessageSharedPtr msg = CreateMessage();
(*msg)[strings::params][strings::function_id] =
mobile_apis::FunctionID::UnregisterAppInterfaceID;

CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);

EXPECT_TRUE(command->CheckPermissions());
}

TEST_F(CommandRequestImplTest, CheckPermissions_RegisterAppInterface_True) {
MessageSharedPtr msg = CreateMessage();
(*msg)[strings::params][strings::function_id] =
mobile_apis::FunctionID::RegisterAppInterfaceID;

CommandPtr command = CreateCommand<UCommandRequestImpl>(msg);

EXPECT_TRUE(command->CheckPermissions());
}

} // namespace command_request_impl
} // namespace commands_test
} // namespace components
Expand Down