Skip to content

Commit a9caceb

Browse files
committed
Add script to cover unsuccessful PTU retry sequence without force protection
1 parent 182955c commit a9caceb

File tree

2 files changed

+171
-0
lines changed

2 files changed

+171
-0
lines changed
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
-----------------------------------------------------------------------------------------------------------------------
2+
-- Proposal:
3+
-- https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0211-ServiceStatusUpdateToHMI.md
4+
-----------------------------------------------------------------------------------------------------------------------
5+
-- Description: Attempt to open protected Audio/Video service with OnServiceUpdate notification
6+
-- and unsuccessful PTU due to timeout
7+
-- Force protection is disabled
8+
--
9+
-- Preconditions:
10+
-- 1) SDL certificate is missing/expired
11+
-- 2) Force protection for the service is switched OFF
12+
-- 3) App is registered with NAVIGATION appHMIType and activated
13+
-- Steps:
14+
-- 1) App sends StartService request (<service_type>, encryption = true)
15+
-- SDL does:
16+
-- - send OnServiceUpdate (<service_type>, REQUEST_RECEIVED) to HMI
17+
-- - send GetSystemTime() request to HMI and wait for the response
18+
-- 2) HMI sends valid GetSystemTime response
19+
-- SDL does:
20+
-- - start PTU sequence and send OnStatusUpdate(UPDATE_NEEDED) to HMI
21+
-- 3) Policy Table Update retry sequence is finished without update from App
22+
-- SDL does:
23+
-- - send OnStatusUpdate(UPDATE_NEEDED) to HMI
24+
-- - send OnServiceUpdate (<service_type>, REQUEST_ACCEPTED, PROTECTION_DISABLED) to HMI
25+
-- - send StartServiceACK(<service_type>, encryption = false) to App
26+
-----------------------------------------------------------------------------------------------------------------------
27+
--[[ Required Shared libraries ]]
28+
local runner = require('user_modules/script_runner')
29+
local common = require('test_scripts/API/ServiceStatusUpdateToHMI/common')
30+
31+
--[[ Test Configuration ]]
32+
runner.testSettings.isSelfIncluded = false
33+
runner.testSettings.restrictions.sdlBuildOptions = { { extendedPolicy = { "EXTERNAL_PROPRIETARY" } } }
34+
35+
--[[ Local Constants ]]
36+
local serviceId = 11
37+
local numOfIter = 2
38+
local secondsBetweenRetries = { 1, 2 }
39+
40+
--[[ Local Variables ]]
41+
local timeout = 10000 * numOfIter + 10000
42+
local result = { }
43+
44+
--[[ Local Functions ]]
45+
local function ptUpdate(pTbl)
46+
local retries = {}
47+
for i = 1, numOfIter do
48+
table.insert(retries, secondsBetweenRetries[i])
49+
end
50+
pTbl.policy_table.module_config.timeout_after_x_seconds = 5
51+
pTbl.policy_table.module_config.seconds_between_retries = retries
52+
end
53+
54+
function common.onServiceUpdateFunc(pServiceTypeValue)
55+
common.getHMIConnection():ExpectNotification("BasicCommunication.OnServiceUpdate",
56+
{ serviceEvent = "REQUEST_RECEIVED", serviceType = pServiceTypeValue, appID = common.getHMIAppId() },
57+
{ serviceEvent = "REQUEST_ACCEPTED", serviceType = pServiceTypeValue, appID = common.getHMIAppId(),
58+
reason = "PROTECTION_DISABLED" })
59+
:Do(function(e, d)
60+
common.log("SDL->HMI:", "BC.OnServiceUpdate", d.params.serviceEvent, d.params.reason)
61+
if e.occurences == 2 then
62+
result.onServiceUpdateTime = timestamp()
63+
end
64+
end)
65+
:Times(2)
66+
:Timeout(timeout)
67+
end
68+
69+
function common.serviceResponseFunc(pServiceId)
70+
common.getMobileSession():ExpectControlMessage(pServiceId, {
71+
frameInfo = common.frameInfo.START_SERVICE_ACK,
72+
encryption = false
73+
})
74+
:Do(function(_, data)
75+
if data.frameInfo == common.frameInfo.START_SERVICE_ACK then
76+
common.log("SDL->MOB:", "START_SERVICE_ACK")
77+
result.serviceNackTime = timestamp()
78+
end
79+
end)
80+
:Timeout(timeout)
81+
end
82+
83+
local function startServiceWithOnServiceUpdate_PTU_FAILED(pServiceId, pHandShakeExpeTimes, pGSTExpTimes, pPTUNum)
84+
result.serviceNackTime = 0
85+
result.retryFinishedTime = 0
86+
result.onServiceUpdateTime = 0
87+
local curRetry = 0
88+
local function getExpOnStatusUpdate()
89+
local expRes = {}
90+
for i = 1, numOfIter + 2 do
91+
if pPTUNum == 1 or i > 1 then table.insert(expRes, { status = "UPDATE_NEEDED" }) end
92+
table.insert(expRes, { status = "UPDATING" })
93+
end
94+
table.insert(expRes, { status = "UPDATE_NEEDED" })
95+
return expRes
96+
end
97+
local function sendBCOnSystemRequest()
98+
curRetry = curRetry + 1
99+
local delay = 0
100+
if curRetry > 2 then
101+
delay = secondsBetweenRetries[curRetry - 2] * 1000
102+
end
103+
common.log("Delay:", delay)
104+
RUN_AFTER(function()
105+
common.getHMIConnection():SendNotification("BasicCommunication.OnSystemRequest",
106+
{ requestType = "PROPRIETARY", fileName = "files/ptu.json" })
107+
common.log("HMI->SDL:", "BC.OnSystemRequest")
108+
end, delay)
109+
end
110+
function common.policyTableUpdateFunc()
111+
function common.policyTableUpdate()
112+
local cid = common.getHMIConnection():SendRequest("SDL.GetURLS", { service = 7 })
113+
common.getHMIConnection():ExpectResponse(cid)
114+
:Do(function()
115+
common.getHMIConnection():ExpectRequest("BasicCommunication.PolicyUpdate")
116+
:Do(function()
117+
common.log("SDL->HMI:", "BC.PolicyUpdate")
118+
sendBCOnSystemRequest()
119+
end)
120+
common.getMobileSession():ExpectNotification("OnSystemRequest", { requestType = "PROPRIETARY" })
121+
:Do(function(_, d)
122+
common.log("SDL->MOB:", "OnSystemRequest", d.payload.requestType)
123+
end)
124+
:Times(numOfIter + 2)
125+
:Timeout(timeout)
126+
end)
127+
end
128+
local expNotifRes = getExpOnStatusUpdate()
129+
common.getHMIConnection():ExpectNotification("SDL.OnStatusUpdate", unpack(expNotifRes))
130+
:Times(#expNotifRes)
131+
:Do(function(e, d)
132+
common.log("SDL->HMI:", d.method, d.params.status)
133+
if e.occurences == #expNotifRes then
134+
result.retryFinishedTime = timestamp()
135+
end
136+
if e.occurences > 1 and e.occurences < #expNotifRes and d.params.status == "UPDATE_NEEDED" then
137+
sendBCOnSystemRequest()
138+
end
139+
end)
140+
:Timeout(timeout)
141+
common.policyTableUpdate()
142+
common.wait(timeout)
143+
end
144+
common.startServiceWithOnServiceUpdate(pServiceId, pHandShakeExpeTimes, pGSTExpTimes)
145+
end
146+
147+
--[[ Scenario ]]
148+
runner.Title("Preconditions")
149+
runner.Step("Clean environment", common.preconditions, { nil, nil })
150+
runner.Step("Init SDL certificates", common.initSDLCertificates,
151+
{ "./files/Security/client_credential_expired.pem", false })
152+
runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start)
153+
runner.Step("App registration", common.registerApp)
154+
runner.Step("PolicyTableUpdate", common.policyTableUpdate, { ptUpdate })
155+
runner.Step("App activation", common.activateApp)
156+
157+
runner.Title("Test")
158+
159+
runner.Title("PTU 1")
160+
runner.Step("Start " .. common.serviceData[serviceId].serviceType .. " service protected, REJECTED",
161+
startServiceWithOnServiceUpdate_PTU_FAILED, { serviceId, 0, 1, 1 })
162+
runner.Step("Check result", common.checkResult, { result })
163+
164+
-- runner.Title("PTU 2")
165+
-- runner.Step("Start " .. common.serviceData[serviceId].serviceType .. " service protected, REJECTED",
166+
-- startServiceWithOnServiceUpdate_PTU_FAILED, { serviceId, 0, 1, 2 })
167+
-- runner.Step("Check result", common.checkResult, { result })
168+
169+
runner.Title("Postconditions")
170+
runner.Step("Stop SDL", common.postconditions)

test_sets/service_status_update_to_hmi.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@
3131
./test_scripts/API/ServiceStatusUpdateToHMI/020_Video_service_protected_PTU_FAILED_TimeOut_2_failed_external.lua
3232
./test_scripts/API/ServiceStatusUpdateToHMI/021_Video_service_protected_PTU_FAILED_TimeOut_failed_success_failed_external.lua
3333
./test_scripts/API/ServiceStatusUpdateToHMI/022_Video_service_protected_PTU_FAILED_TimeOut_failed_success_2rd_try_failed_external.lua
34+
./test_scripts/API/ServiceStatusUpdateToHMI/023_Video_service_protected_PTU_FAILED_TimeOut_unprotected.lua

0 commit comments

Comments
 (0)