Skip to content

Commit

Permalink
Update common modules to support HTTP and EXT PTU flows
Browse files Browse the repository at this point in the history
  • Loading branch information
dboltovskyi committed Jul 23, 2019
1 parent f6c9223 commit edfe039
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ local commonFunctions = require("user_modules/shared_testcases/commonFunctions")
local utils = require("user_modules/utils")
local events = require("events")
local json = require("modules/json")
local runner = require('user_modules/script_runner')

-- Set applicalbe SDL policy mode
runner.testSettings.restrictions.sdlBuildOptions = { { extendedPolicy = { "PROPRIETARY", "EXTERNAL_PROPRIETARY" } } }

--[[ General configuration parameters ]]
config.defaultProtocolVersion = 2
Expand Down
4 changes: 4 additions & 0 deletions test_scripts/API/VehicleData/DOP/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@ function m.checkAbsenceOfParam(pParam, pData)
return true
end

function m.ptUpdate(pTbl)
pTbl.policy_table.functional_groupings["Location-1"].user_consent_prompt = nil
end

return m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ m.gpsParams = {
--[[ Functions ]]
function m.pTUpdateFunc(tbl)
tbl.policy_table.app_policies[config.application1.registerAppInterfaceParams.fullAppID].groups = {"Base-4", "Location-1"}
tbl.policy_table.functional_groupings["Location-1"].user_consent_prompt = nil
end

function m.checkShifted(data, pShiftValue)
Expand Down
11 changes: 2 additions & 9 deletions test_scripts/AppServices/commonAppServices.lua
Original file line number Diff line number Diff line change
Expand Up @@ -459,16 +459,9 @@ function commonAppServices.getRpcPassThroughTimeoutFromINI()
return tonumber(RpcPassThroughTimeout)
end

function commonAppServices:Request_PTU()
local is_test_fail = false
local hmi_app1_id = config.application1.registerAppInterfaceParams.appName
function commonAppServices:Request_PTU()
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)
commonAppServices.isPTUStarted()
end

function commonAppServices.GetPolicySnapshot()
Expand Down
11 changes: 2 additions & 9 deletions test_scripts/CloudAppRPCs/commonCloudAppRPCs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,9 @@ function commonCloudAppRPCs.getCloudAppStoreConfig()
}
end

function commonCloudAppRPCs:Request_PTU()
local is_test_fail = false
local hmi_app1_id = config.application1.registerAppInterfaceParams.appName
function commonCloudAppRPCs:Request_PTU()
commonCloudAppRPCs.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)
commonCloudAppRPCs.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {})
end)
commonCloudAppRPCs.isPTUStarted()
end

function commonCloudAppRPCs.test_assert(condition, msg)
Expand Down
3 changes: 3 additions & 0 deletions test_scripts/SDL5_0/FullAppID/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ local sdl = require("SDL")
local commonSteps = require("user_modules/shared_testcases/commonSteps")
local commonSmoke = require('test_scripts/Smoke/commonSmoke')

-- Set applicalbe SDL policy mode
runner.testSettings.restrictions.sdlBuildOptions = { { extendedPolicy = { "PROPRIETARY" } } }

--[[ Local Variables ]]

local m = commonSteps
Expand Down
1 change: 1 addition & 0 deletions test_scripts/Security/DTLS/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ function m.policyTableUpdate(pPTUpdateFunc)
m.getHMIConnection():ExpectRequest("BasicCommunication.DecryptCertificate")
:Do(function(_, d)
m.getHMIConnection():SendResponse(d.id, d.method, "SUCCESS", { })
utils.wait(1000)
end)
:Times(AnyNumber())
m.getHMIConnection():ExpectRequest("VehicleInfo.GetVehicleData", { odometer = true })
Expand Down
1 change: 1 addition & 0 deletions test_scripts/Security/GetSystemTime/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ function m.policyTableUpdate(pPTUpdateFunc)
m.getHMIConnection():ExpectRequest("BasicCommunication.DecryptCertificate")
:Do(function(_, d)
m.getHMIConnection():SendResponse(d.id, d.method, "SUCCESS", { })
utils.wait(1000)
end)
:Times(AnyNumber())
m.getHMIConnection():ExpectRequest("VehicleInfo.GetVehicleData", { odometer = true })
Expand Down
10 changes: 4 additions & 6 deletions test_scripts/Security/SSLHandshakeFlow/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,14 @@ function m.policyTableUpdateSuccess(pPTUpdateFunc)
m.getHMIConnection():ExpectRequest("BasicCommunication.DecryptCertificate")
:Do(function(_, d)
m.getHMIConnection():SendResponse(d.id, d.method, "SUCCESS", { })
utils.wait(1000)
end)
:Times(AnyNumber())
m.getHMIConnection():ExpectRequest("VehicleInfo.GetVehicleData", { odometer = true })
end
m.getHMIConnection():ExpectRequest("BasicCommunication.PolicyUpdate")
:Do(function(e, d)
if e.occurences == 1 then
m.getHMIConnection():SendResponse(d.id, d.method, "SUCCESS", { })
m.policyTableUpdate(pPTUpdateFunc, expNotificationFunc)
end
m.isPTUStarted()
:Do(function()
m.policyTableUpdate(pPTUpdateFunc, expNotificationFunc)
end)
end

Expand Down
116 changes: 92 additions & 24 deletions user_modules/sequences/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local test = require("user_modules/dummy_connecttest")
local expectations = require('expectations')
local reporter = require("reporter")
local utils = require("user_modules/utils")
local sdl = require("SDL")

--[[ Module ]]
local m = {}
Expand All @@ -22,6 +23,12 @@ m.minTimeout = 500
--[[ Variables ]]
local hmiAppIds = {}
local originalValuesInSDLIni = {}
local policyModes = {
P = "PROPRIETARY",
EP = "EXTERNAL_PROPRIETARY",
H = "HTTP"
}
local ptuAppNum

test.mobileSession = {}

Expand Down Expand Up @@ -80,16 +87,7 @@ function m.getAppDataForPTU(pAppId)
}
end

--[[ @policyTableUpdate: perform PTU
--! @parameters:
--! pPTUpdateFunc - function with additional updates (optional)
--! pExpNotificationFunc - function with specific expectations (optional)
--! @return: none
--]]
function m.policyTableUpdate(pPTUpdateFunc, pExpNotificationFunc)
if pExpNotificationFunc then
pExpNotificationFunc()
end
local function policyTableUpdateProprietary(pPTUpdateFunc, pExpNotificationFunc)
local ptsFileName = commonFunctions:read_parameter_from_smart_device_link_ini("SystemFilesPath") .. "/"
.. commonFunctions:read_parameter_from_smart_device_link_ini("PathToSnapshot")
local ptuFileName = os.tmpname()
Expand All @@ -112,19 +110,19 @@ function m.policyTableUpdate(pPTUpdateFunc, pExpNotificationFunc)
for id = 1, m.getAppsCount() do
m.getMobileSession(id):ExpectNotification("OnSystemRequest", { requestType = "PROPRIETARY" })
:Do(function()
if not pExpNotificationFunc then
m.getHMIConnection():ExpectRequest("VehicleInfo.GetVehicleData", { odometer = true })
m.getHMIConnection():ExpectNotification("SDL.OnStatusUpdate", { status = "UP_TO_DATE" })
end
utils.cprint(35, "App ".. id .. " was used for PTU")
m.getHMIConnection():RaiseEvent(event, "PTU event")
local corIdSystemRequest = m.getMobileSession(id):SendRPC("SystemRequest", {
requestType = "PROPRIETARY" }, ptuFileName)
m.getHMIConnection():ExpectRequest("BasicCommunication.SystemRequest")
:Do(function(_, d3)
if not pExpNotificationFunc then
m.getHMIConnection():ExpectRequest("VehicleInfo.GetVehicleData", { odometer = true })
m.getHMIConnection():ExpectNotification("SDL.OnStatusUpdate", { status = "UP_TO_DATE" })
end
m.getHMIConnection():SendResponse(d3.id, "BasicCommunication.SystemRequest", "SUCCESS", { })
m.getHMIConnection():SendNotification("SDL.OnReceivedPolicyUpdate", { policyfile = d3.params.fileName })
end)
utils.cprint(35, "App ".. id .. " was used for PTU")
m.getHMIConnection():RaiseEvent(event, "PTU event")
local corIdSystemRequest = m.getMobileSession(id):SendRPC("SystemRequest", {
requestType = "PROPRIETARY" }, ptuFileName)
m.getMobileSession(id):ExpectResponse(corIdSystemRequest, { success = true, resultCode = "SUCCESS" })
:Do(function() os.remove(ptuFileName) end)
end)
Expand All @@ -133,6 +131,43 @@ function m.policyTableUpdate(pPTUpdateFunc, pExpNotificationFunc)
end)
end

local function policyTableUpdateHttp(pPTUpdateFunc, pExpNotificationFunc)
local ptuFileName = os.tmpname()
local ptuTable = getPTUFromPTS()
for i = 1, m.getAppsCount() do
ptuTable.policy_table.app_policies[m.getConfigAppParams(i).fullAppID] = m.getAppDataForPTU(i)
end
if pPTUpdateFunc then
pPTUpdateFunc(ptuTable)
end
utils.tableToJsonFile(ptuTable, ptuFileName)
local cid = m.getMobileSession(ptuAppNum):SendRPC("SystemRequest",
{ requestType = "HTTP", fileName = "PolicyTableUpdate" }, ptuFileName)
if not pExpNotificationFunc then
m.getHMIConnection():ExpectRequest("VehicleInfo.GetVehicleData", { odometer = true })
m.getHMIConnection():ExpectNotification("SDL.OnStatusUpdate", { status = "UP_TO_DATE" })
end
m.getMobileSession(ptuAppNum):ExpectResponse(cid, { success = true, resultCode = "SUCCESS" })
:Do(function() os.remove(ptuFileName) end)
end
--[[ @policyTableUpdate: perform PTU
--! @parameters:
--! pPTUpdateFunc - function with additional updates (optional)
--! pExpNotificationFunc - function with specific expectations (optional)
--! @return: none
--]]
function m.policyTableUpdate(pPTUpdateFunc, pExpNotificationFunc)
if pExpNotificationFunc then
pExpNotificationFunc()
end
local policyMode = sdl.buildOptions.extendedPolicy
if policyMode == policyModes.P or policyMode == policyModes.EP then
policyTableUpdateProprietary(pPTUpdateFunc, pExpNotificationFunc)
elseif policyMode == policyModes.H then
policyTableUpdateHttp(pPTUpdateFunc, pExpNotificationFunc)
end
end

--[[ @allowSDL: allow SDL functionality for default device
--! @parameters: none
--! @return: none
Expand Down Expand Up @@ -179,8 +214,8 @@ function m.activateApp(pAppId)
m.getHMIConnection():ExpectResponse(requestId)
local params = m.getConfigAppParams(pAppId)
local audioStreamingState = "NOT_AUDIBLE"
if params.isMediaApplication or
commonFunctions:table_contains(params.appHMIType, "NAVIGATION") or
if params.isMediaApplication or
commonFunctions:table_contains(params.appHMIType, "NAVIGATION") or
commonFunctions:table_contains(params.appHMIType, "COMMUNICATION") then
audioStreamingState = "AUDIBLE"
end
Expand Down Expand Up @@ -222,6 +257,42 @@ function m.getMobileSession(pAppId)
return session
end

function m.isPTUStarted()
local event = events.Event()
event.matches = function(e1, e2) return e1 == e2 end
local function raisePtuEvent()
RUN_AFTER(function() m.getHMIConnection():RaiseEvent(event, "PTU start event") end, m.minTimeout)
end
local policyMode = sdl.buildOptions.extendedPolicy
if policyMode == policyModes.P or policyMode == policyModes.EP then
m.getHMIConnection():ExpectRequest("BasicCommunication.PolicyUpdate")
:Do(function(_, d2)
m.getHMIConnection():SendResponse(d2.id, d2.method, "SUCCESS", { })
raisePtuEvent()
end)
elseif policyMode == policyModes.H then
local function getAppNums()
local out = {}
for k in pairs(test.mobileSession) do
table.insert(out, k)
end
return out
end
for _, appNum in pairs(getAppNums()) do
m.getMobileSession(appNum):ExpectNotification("OnSystemRequest")
:Do(function(_, d3)
if d3.payload.requestType == "HTTP" then
utils.cprint(35, "App ".. appNum .. " will be used for PTU")
ptuAppNum = appNum
raisePtuEvent()
end
end)
:Times(AtMost(2))
end
end
return m.getHMIConnection():ExpectEvent(event, "PTU start event")
end

--[[ @registerApp: register mobile application
--! @parameters:
--! pAppId - application number (1, 2, etc.)
Expand All @@ -236,10 +307,7 @@ function m.registerApp(pAppId)
{ application = { appName = m.getConfigAppParams(pAppId).appName } })
:Do(function(_, d1)
m.setHMIAppId(d1.params.application.appID, pAppId)
m.getHMIConnection():ExpectRequest("BasicCommunication.PolicyUpdate")
:Do(function(_, d2)
m.getHMIConnection():SendResponse(d2.id, d2.method, "SUCCESS", { })
end)
m.isPTUStarted()
end)
m.getMobileSession(pAppId):ExpectResponse(corId, { success = true, resultCode = "SUCCESS" })
:Do(function()
Expand Down

0 comments on commit edfe039

Please sign in to comment.