Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PTU check for allow_unknown_rpc_passthrough #2187

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
@@ -0,0 +1,48 @@
---------------------------------------------------------------------------------------------------
-- Precondition:
-- 1) Application with <appID> is registered on SDL.
-- 2) PTU is completed with <app1> permissions all_unknown_rpc_passthrough = true
--
-- Steps:
-- 1) HMI initiates PTU to deliver PT snapshot to mobile
--
-- Expected:
-- 1) PT Snapshot contains <app1> permissions all_unknown_rpc_passthrough = true
---------------------------------------------------------------------------------------------------

--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
local common = require('test_scripts/AppServices/commonAppServices')

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

--[[ Local Functions ]]
local function PTUfunc(tbl)
tbl.policy_table.app_policies[common.getConfigAppParams(1).fullAppID] = common.getAppServiceConsumerConfig(1);
tbl.policy_table.app_policies[common.getConfigAppParams(1).fullAppID]["allow_unknown_rpc_passthrough"] = true
end

local function verifyAllowUnknownRPCPassthrough()
local snp_tbl = common.GetPolicySnapshot()
local app_id = common.getConfigAppParams(1).fullAppID
local result = {}
result.allow_unknown_rpc_passthrough = snp_tbl.policy_table.app_policies[app_id].allow_unknown_rpc_passthrough
common.test_assert(result.allow_unknown_rpc_passthrough == true, "Incorrect result value")
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", common.registerApp)
runner.Step("PTU", common.policyTableUpdate, { PTUfunc })
runner.Step("Activate App", common.activateApp)

runner.Title("Test")
runner.Step("Request PTU", common.Request_PTU)
runner.Step("Validate PTU", verifyAllowUnknownRPCPassthrough)

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 NAVIGATION AppService permissions to handle rpc FutureRequest) are assigned for <app1ID>
-- 3) allow_unknown_rpc_passthrough is set to true for <app2ID>
Jack-Byrne marked this conversation as resolved.
Show resolved Hide resolved
-- 4) app1 sends a PublishAppService (with {serviceType=NAVIGATION, handledRPC=FutureRequest} in the manifest)
--
-- Steps:
-- 1) app2 sends a FutureRequest request to core
--
-- Expected:
-- 1) Core does not forward the request to any provider application
-- 2) core responds to app3 with { success = false, resultCode = "UNSUPPORTED_REQUEST" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
-- 2) core responds to app3 with { success = false, resultCode = "UNSUPPORTED_REQUEST" }
-- 2) Core responds to app3 with { success = false, resultCode = "UNSUPPORTED_REQUEST" }

Jack-Byrne marked this conversation as resolved.
Show resolved Hide resolved
---------------------------------------------------------------------------------------------------
--[[ 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 rpcRequest = {
name = "FutureRequest",
hmi_name = "FutureInterface.FutureRequest",
func_id = 956,
params = {
futureParam = 50,
futureParam2 = { 50 },
futureParam3 = "StringValue"
},
hmi_params = {
futureParam = 50,
futureParam2 = { 50 },
futureParam3 = "StringValue"
}
}

local unsupportedResponse = {
success = false,
resultCode = "UNSUPPORTED_REQUEST"
}

local manifest = {
serviceName = config.application1.registerAppInterfaceParams.appName,
serviceType = "NAVIGATION",
handledRPCs = { rpcRequest.func_id },
allowAppConsumers = true,
rpcSpecVersion = config.application1.registerAppInterfaceParams.syncMsgVersion,
navigationServiceManifest = {}
}

local rpcResponse = {
params = unsupportedResponse
}

--[[ 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 = rpcRequest.func_id}} }
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" }
pt_entry.allow_unknown_rpc_passthrough = false
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.func_id, rpcRequest.params)

-- Core will NOT pass the message to mobile provider
providerMobileSession:ExpectRequest(rpcRequest.func_id, rpcRequest.params):Times(0)

--Core will NOT attempt to process message
EXPECT_HMICALL(rpcRequest.hmi_name, rpcRequest.hmi_params):Times(0)

--Core will respond with UNSUPPORTED_REQUEST because the RPC is unknown
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_UNSUPPORTED", RPCPassThruTest)

runner.Title("Postconditions")
runner.Step("Stop SDL", common.postconditions)
23 changes: 23 additions & 0 deletions test_scripts/AppServices/commonAppServices.lua
Original file line number Diff line number Diff line change
Expand Up @@ -456,4 +456,27 @@ function commonAppServices.getRpcPassThroughTimeoutFromINI()
return tonumber(RpcPassThroughTimeout)
end

function commonAppServices:Request_PTU()
local is_test_fail = false
local hmi_app1_id = config.application1.registerAppInterfaceParams.appName
commonAppServices.getHMIConnection():SendNotification("SDL.OnPolicyUpdate", {} )
EXPECT_HMINOTIFICATION("SDL.OnStatusUpdate", {status = "UPDATE_NEEDED"})

EXPECT_HMICALL("BasicCommunication.PolicyUpdate",{ file = "/tmp/fs/mp/images/ivsu_cache/sdl_snapshot.json" })
:Do(function(_,data)
commonAppServices.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {})
end)
end

function commonAppServices.GetPolicySnapshot()
return utils.jsonFileToTable("/tmp/fs/mp/images/ivsu_cache/sdl_snapshot.json")
end

function commonAppServices.test_assert(condition, msg)
if not condition then
test:FailTestCase(msg)
end
end


return commonAppServices