Skip to content

Commit

Permalink
RPC PassThrough missing permission ATF tests (#2189)
Browse files Browse the repository at this point in the history
* Implemented SendLocation and ButtonPress tests for misssing permissions

* Updated test set
  • Loading branch information
ShobhitAd authored Apr 11, 2019
1 parent 42dfb35 commit aa30a03
Show file tree
Hide file tree
Showing 4 changed files with 286 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---------------------------------------------------------------------------------------------------
-- Precondition:
-- 1) app1 and app2 are registered on SDL.
-- 2) AppServiceProvider permissions(with NAVIGATION AppService permissions to handle rpc SendLocation) are assigned for <app1ID>
-- 3) SendLocation permissions are NOT assigned for <app2ID>
-- 4) app1 sends a PublishAppService (with {serviceType=NAVIGATION, handledRPC=SendLocation} in the manifest)
--
-- Steps:
-- 1) app2 sends a SendLocation request to core
--
-- Expected:
-- 1) Core responds to app2 with {success = false, resultCode = "DISALLOWED"}
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
local common = require('test_scripts/AppServices/commonAppServices')

--[[ Test Configuration ]]
runner.testSettings.isSelfIncluded = false

--[[ Local variables ]]
local manifest = {
serviceName = config.application1.registerAppInterfaceParams.appName,
serviceType = "NAVIGATION",
handledRPCs = {39},
allowAppConsumers = true,
rpcSpecVersion = config.application1.registerAppInterfaceParams.syncMsgVersion,
navigationServiceManifest = {}
}

local disallowedResponse = {
success = false,
resultCode = "DISALLOWED",
}

local rpcRequest = {
name = "SendLocation",
hmi_name = "Navigation.SendLocation",
params = {
longitudeDegrees = 50,
latitudeDegrees = 50,
locationName = "TestLocation"
},
hmi_params = {
longitudeDegrees = 50,
latitudeDegrees = 50,
locationName = "TestLocation"
}
}

--[[ Local functions ]]
local function PTUfunc(tbl)
--Add permissions for app1
local pt_entry = common.getAppServiceProducerConfig(1)
pt_entry.app_services.NAVIGATION = { handled_rpcs = {{function_id = 39}} }
tbl.policy_table.app_policies[common.getConfigAppParams(1).fullAppID] = pt_entry
end

local function RPCPassThruTest()
local providerMobileSession = common.getMobileSession(1)
local mobileSession = common.getMobileSession(2)

local cid = mobileSession:SendRPC(rpcRequest.name, rpcRequest.params)

--Provider will NOT be forwarded the request
providerMobileSession:ExpectRequest(rpcRequest.name, rpcRequest.params):Times(0)

--Core will NOT handle the RPC
EXPECT_HMICALL(rpcRequest.hmi_name, rpcRequest.hmi_params):Times(0)

mobileSession:ExpectResponse(cid, disallowedResponse)
end

--[[ Scenario ]]
runner.Title("Preconditions")
runner.Step("Clean environment", common.preconditions)
runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start)
runner.Step("RAI App 1", common.registerApp)
runner.Step("PTU", common.policyTableUpdate, { PTUfunc })
runner.Step("PublishAppService", common.publishMobileAppService, { manifest, 1 })
runner.Step("RAI App 2", common.registerAppWOPTU, { 2 })
runner.Step("Activate App", common.activateApp, { 2 })

runner.Title("Test")
runner.Step("RPCPassThroughTest_DISALLOWED", RPCPassThruTest)

runner.Title("Postconditions")
runner.Step("Stop SDL", common.postconditions)
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---------------------------------------------------------------------------------------------------
-- Precondition:
-- 1) app1 and app2 are registered on SDL.
-- 2) AppServiceProvider permissions(with MEDIA AppService permissions to handle rpc ButtonPress) are assigned for <app1ID>
-- 3) RemoteControl permissions are assigned for <app2ID>
-- 4) app1 sends a PublishAppService (with {serviceType=MEDIA, handledRPC=ButtonPress} in the manifest)
--
-- Steps:
-- 1) app2 sends a ButtonPress request to core
--
-- Expected:
-- 1) Core forwards the request to app1
-- 2) app1 responds to core with { success = true, resultCode = "SUCCESS", info = "Request was handled by app services" }
-- 3) Core forwards the response from app1 to app2
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
local common = require('test_scripts/AppServices/commonAppServices')

--[[ Test Configuration ]]
runner.testSettings.isSelfIncluded = false

--[[ Local variables ]]
local manifest = {
serviceName = config.application1.registerAppInterfaceParams.appName,
serviceType = "MEDIA",
handledRPCs = {41},
allowAppConsumers = true,
rpcSpecVersion = config.application1.registerAppInterfaceParams.syncMsgVersion,
mediaServiceManifest = {}
}

local successResponse = {
success = true,
resultCode = "SUCCESS",
info = "Request was handled by app services"
}

local rpcRequest = {
name = "ButtonPress",
hmi_name = "Buttons.ButtonPress",
params = {
moduleType = "RADIO",
buttonName = "OK",
buttonPressMode = "SHORT"
},
hmi_params = {
moduleType = "RADIO",
buttonName = "OK",
buttonPressMode = "SHORT"
}
}

local rpcResponse = {
params = successResponse
}

--[[ Local functions ]]
local function PTUfunc(tbl)
--Add permissions for app1
local pt_entry = common.getAppServiceProducerConfig(1)
pt_entry.app_services.MEDIA.handled_rpcs = {{function_id = 41}}
tbl.policy_table.app_policies[common.getConfigAppParams(1).fullAppID] = pt_entry
--Add permissions for app2
pt_entry = common.getAppDataForPTU(2)
pt_entry.groups = { "Base-4" , "RemoteControl" }
tbl.policy_table.app_policies[common.getConfigAppParams(2).fullAppID] = pt_entry
end

local function RPCPassThruTest()
local providerMobileSession = common.getMobileSession(1)
local mobileSession = common.getMobileSession(2)

local cid = mobileSession:SendRPC(rpcRequest.name, rpcRequest.params)

providerMobileSession:ExpectRequest(rpcRequest.name, rpcRequest.params):Do(function(_, data)
providerMobileSession:SendResponse(rpcRequest.name, data.rpcCorrelationId, successResponse)
end)

--Core will NOT handle the RPC
EXPECT_HMICALL(rpcRequest.hmi_name, rpcRequest.hmi_params):Times(0)

mobileSession:ExpectResponse(cid, rpcResponse.params)
end

--[[ Scenario ]]
runner.Title("Preconditions")
runner.Step("Clean environment", common.preconditions)
runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start)
runner.Step("RAI App 1", common.registerApp)
runner.Step("PTU", common.policyTableUpdate, { PTUfunc })
runner.Step("PublishAppService", common.publishMobileAppService, { manifest, 1 })
runner.Step("RAI App 2", common.registerAppWOPTU, { 2 })
runner.Step("Activate App", common.activateApp, { 2 })

runner.Title("Test")
runner.Step("RPCPassThroughTest_SUCCESS", RPCPassThruTest)

runner.Title("Postconditions")
runner.Step("Stop SDL", common.postconditions)
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---------------------------------------------------------------------------------------------------
-- Precondition:
-- 1) app1 and app2 are registered on SDL.
-- 2) AppServiceProvider permissions(with MEDIA AppService permissions to handle rpc ButtonPress) are assigned for <app1ID>
-- 3) RemoteControl permissions are NOT assigned for <app2ID>
-- 4) app1 sends a PublishAppService (with {serviceType=MEDIA, handledRPC=ButtonPress} in the manifest)
--
-- Steps:
-- 1) app2 sends a ButtonPress request to core
--
-- Expected:
-- 1) Core responds to app2 with {success = false, resultCode = "DISALLOWED"}
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
local common = require('test_scripts/AppServices/commonAppServices')

--[[ Test Configuration ]]
runner.testSettings.isSelfIncluded = false

--[[ Local variables ]]
local manifest = {
serviceName = config.application1.registerAppInterfaceParams.appName,
serviceType = "MEDIA",
handledRPCs = {41},
allowAppConsumers = true,
rpcSpecVersion = config.application1.registerAppInterfaceParams.syncMsgVersion,
mediaServiceManifest = {}
}

local successResponse = {
success = true,
resultCode = "SUCCESS",
info = "Request was handled by app services"
}

local rpcRequest = {
name = "ButtonPress",
hmi_name = "Buttons.ButtonPress",
params = {
moduleType = "RADIO",
buttonName = "OK",
buttonPressMode = "SHORT"
},
hmi_params = {
moduleType = "RADIO",
buttonName = "OK",
buttonPressMode = "SHORT"
}
}

local rpcResponse = {
params = {success = false, resultCode="DISALLOWED"}
}

--[[ Local functions ]]
local function PTUfunc(tbl)
--Add permissions for app1
local pt_entry = common.getAppServiceProducerConfig(1)
pt_entry.app_services.MEDIA.handled_rpcs = {{function_id = 41}}
tbl.policy_table.app_policies[common.getConfigAppParams(1).fullAppID] = pt_entry
end

local function RPCPassThruTest()
local providerMobileSession = common.getMobileSession(1)
local mobileSession = common.getMobileSession(2)

local cid = mobileSession:SendRPC(rpcRequest.name, rpcRequest.params)

--Provider will NOT be forwarded the request
providerMobileSession:ExpectRequest(rpcRequest.name, rpcRequest.params):Times(0)

--Core will NOT handle the RPC
EXPECT_HMICALL(rpcRequest.hmi_name, rpcRequest.hmi_params):Times(0)

mobileSession:ExpectResponse(cid, rpcResponse.params)
end

--[[ Scenario ]]
runner.Title("Preconditions")
runner.Step("Clean environment", common.preconditions)
runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start)
runner.Step("RAI App 1", common.registerApp)
runner.Step("PTU", common.policyTableUpdate, { PTUfunc })
runner.Step("PublishAppService", common.publishMobileAppService, { manifest, 1 })
runner.Step("RAI App 2", common.registerAppWOPTU, { 2 })
runner.Step("Activate App", common.activateApp, { 2 })

runner.Title("Test")
runner.Step("RPCPassThroughTest_DISALLOWED", RPCPassThruTest)

runner.Title("Postconditions")
runner.Step("Stop SDL", common.postconditions)
5 changes: 5 additions & 0 deletions test_sets/app_services.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
./test_scripts/AppServices/RPCPassThrough/002_SendLocation_Unsupported_Request.lua
./test_scripts/AppServices/RPCPassThrough/003_SendLocation_Request_Timeout.lua
./test_scripts/AppServices/RPCPassThrough/004_SendLocation_MultipleAS.lua
./test_scripts/AppServices/RPCPassThrough/005_SendLocation_Invalid_Permissions.lua
./test_scripts/AppServices/RPCPassThrough/006_ButtonPress_Handled_Request.lua
./test_scripts/AppServices/RPCPassThrough/007_ButtonPress_Invalid_Permissions.lua
./test_scripts/AppServices/RPCPassThrough/008_PTU_allow_unknown_rpc_passthrough.lua
./test_scripts/AppServices/RPCPassThrough/009_UnknownRPC_Consumer_UNSUPPORTED_REQUEST_policy_allow_flag_false.lua
./test_scripts/AppServices/RPCPassThrough/010_UnknownRpc_Handled_Request.lua
./test_scripts/AppServices/RPCPassThrough/011_UnknownRpc_Unsupported_Request.lua
./test_scripts/AppServices/RPCPassThrough/012_UnknownRpc_Request_Timeout.lua
Expand Down

0 comments on commit aa30a03

Please sign in to comment.