Skip to content

Commit

Permalink
Add validation to PT snapshot creation for webengine (#2399)
Browse files Browse the repository at this point in the history
* Add validation to PT snapshot creation for webengine

* Remove new lines

* Address comments

* Apply suggestions from code review

Co-authored-by: Collin <iCollin@users.noreply.github.com>

* Update test_scripts/WebEngine/commonWebEngine.lua

Co-authored-by: Collin <iCollin@users.noreply.github.com>

* Address review comments

* Fix conflicts

Co-authored-by: Collin <iCollin@users.noreply.github.com>
  • Loading branch information
Jack-Byrne and iCollin authored May 12, 2020
1 parent 8b2019d commit a2040db
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 49 deletions.
52 changes: 3 additions & 49 deletions test_scripts/WebEngine/026_PTU_snapshot_validation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
-- 1. HMI sends BC.SetAppProperties request with new application properties of the policyAppID to SDL
-- a. SDL sends successful response to HMI
-- b. PTU is triggered, SDL sends UPDATE_NEDDED to HMI
-- с. PTS is created with application properties of the policyAppID
-- с. PTS is created with application properties of the policyAppID and other mandatory fields
--------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
Expand Down Expand Up @@ -38,7 +38,7 @@ local appPropExpected = {
nicknames = { "Test Web Application_21", "Test Web Application_22" },
auth_token = "ABCD12345",
cloud_transport_type = "WS",
enabled = "true",
enabled = true,
hybrid_app_preference = "CLOUD"
}

Expand All @@ -56,52 +56,6 @@ local function setAppProperties(pData)
common.wait(1000)
end

local function verifyAppProperties()
local snp_tbl = common.ptsTable()
local app_id = appProperties.policyAppID
local result = {}
local msg = ""

result.nicknames = snp_tbl.policy_table.app_policies[app_id].nicknames
if not common.isTableEqual(result.nicknames, appPropExpected.nicknames) then
msg = msg .. "Incorrect nicknames\n" ..
" Expected: " .. common.tableToString(appPropExpected.nicknames) .. "\n" ..
" Actual: " .. common.tableToString(result.nicknames) .. "\n"
end

result.auth_token = snp_tbl.policy_table.app_policies[app_id].auth_token
if not (result.auth_token == appPropExpected.auth_token) then
msg = msg .. "Incorrect auth token value\n" ..
" Expected: " .. appPropExpected.auth_token .. "\n" ..
" Actual: " .. result.auth_token .. "\n"
end

result.cloud_transport_type = snp_tbl.policy_table.app_policies[app_id].cloud_transport_type
if not (result.cloud_transport_type == appPropExpected.cloud_transport_type) then
msg = msg .. "Incorrect cloud_transport_type value\n" ..
" Expected: " .. appPropExpected.cloud_transport_type .. "\n" ..
" Actual: " .. result.cloud_transport_type .. "\n"
end

result.enabled = tostring(snp_tbl.policy_table.app_policies[app_id].enabled)
if not (result.enabled == appPropExpected.enabled) then
msg = msg .. "Incorrect enabled value\n"..
" Expected: " .. appPropExpected.enabled .. "\n" ..
" Actual: " .. result.enabled .. "\n"
end

result.hybrid_app_preference = snp_tbl.policy_table.app_policies[app_id].hybrid_app_preference
if not (result.hybrid_app_preference == appPropExpected.hybrid_app_preference) then
msg = msg .. "Incorrect hybrid_app_preference value\n" ..
" Expected: " .. appPropExpected.hybrid_app_preference .. "\n" ..
" Actual: " .. result.hybrid_app_preference .. "\n"
end

if string.len(msg) > 0 then
common.failTestStep("PTS is incorrect\n".. msg)
end
end

-- [[ Scenario ]]
common.Title("Preconditions")
common.Step("Clean environment", common.preconditions)
Expand All @@ -111,7 +65,7 @@ common.Title("Test")
common.Step("RAI", common.registerApp)
common.Step("PTU", common.policyTableUpdate, { PTUfunc })
common.Step("SetAppProperties request to check: PTU is triggered", setAppProperties, { appProperties })
common.Step("Verify app properties via PTS", verifyAppProperties)
common.Step("Validate PTS", common.verifyPTSnapshot, { appProperties, appPropExpected })

common.Title("Postconditions")
common.Step("Stop SDL", common.postconditions)
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---------------------------------------------------------------------------------------------------
-- Proposal: https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0240-sdl-js-pwa.md
--
-- Description:
-- Verify that PTU is performed after BC.SetAppProperties request with new application properties of the policyAppID
-- Precondition:
-- 1. SDL and HMI are started
--
-- Sequence:
-- 1. HMI sends BC.SetAppProperties request with new application properties of the policyAppID to SDL
-- a. SDL sends successful response to HMI
-- b. PTU is triggered, SDL sends UPDATE_NEDDED to HMI
-- с. PTS is created with application properties of the policyAppID and other mandatory pts
--------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local common = require('test_scripts/WebEngine/commonWebEngine')
local hmi_ptu = require('test_scripts/Policies/HMI_PTU/common_hmi_ptu')
--[[ Local Variables ]]
local appStoreConfig = {
keep_context = false,
steal_focus = false,
priority = "NONE",
default_hmi = "NONE",
groups = { "Base-4" }
}

local appProperties = {
nicknames = { "Test Web Application_21", "Test Web Application_22" },
policyAppID = "0000002",
enabled = true,
authToken = "ABCD12345",
transportType = "WS",
hybridAppPreference = "CLOUD"
}

local appPropExpected = {
nicknames = { "Test Web Application_21", "Test Web Application_22" },
auth_token = "ABCD12345",
cloud_transport_type = "WS",
enabled = true,
hybrid_app_preference = "CLOUD"
}

--[[ Local Functions ]]
local function PTUfunc(tbl)
tbl.policy_table.app_policies[common.getConfigAppParams().fullAppID] = appStoreConfig;
end

local function setAppProperties(pData)
local corId = common.getHMIConnection():SendRequest("BasicCommunication.SetAppProperties",
{ properties = pData })
common.getHMIConnection():ExpectResponse(corId,
{ result = { code = 0 }})
common.isPTUStarted()
common.wait(1000)
end

-- [[ Scenario ]]
common.Title("Preconditions")
common.Step("Clean environment", common.preconditions)
common.Step("Start SDL, HMI, connect regular mobile, start Session", common.start)

common.Title("Test")
common.Step("SetAppProperties request to check: PTU is triggered", setAppProperties, { appProperties })
common.Step("Validate PTS", common.verifyPTSnapshot, { appProperties, appPropExpected })

common.Title("Postconditions")
common.Step("Stop SDL", common.postconditions)
82 changes: 82 additions & 0 deletions test_scripts/WebEngine/commonWebEngine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,86 @@ function common.checkUpdateAppList(pPolicyAppID, pTimes, pExpNumOfApps)
common.wait()
end

function common.verifyPTSnapshot(appProperties, appPropExpected)
local snp_tbl = common.ptsTable()
local app_id = appProperties.policyAppID
local result = {}
local msg = ""

if (snp_tbl.policy_table.app_policies == nil) then
msg = msg .. "Incorrect app_policies value\n" ..
" Expected: exists \n" ..
" Actual: nil \n"
end

if (snp_tbl.policy_table.consumer_friendly_messages == nil) then
msg = msg .. "Incorrect consumer_friendly_messages value\n" ..
" Expected: exists \n" ..
" Actual: nil \n"
end

if (snp_tbl.policy_table.device_data == nil) then
msg = msg .. "Incorrect device_data value\n" ..
" Expected: exists \n" ..
" Actual: nil \n"
end

if (snp_tbl.policy_table.functional_groupings == nil) then
msg = msg .. "Incorrect functional_groupings value\n" ..
" Expected: exists \n" ..
" Actual: nil \n"
end

if (snp_tbl.policy_table.module_config == nil) then
msg = msg .. "Incorrect module_config value\n" ..
" Expected: exists \n" ..
" Actual: nil \n"
end

if (snp_tbl.policy_table.usage_and_error_counts == nil) then
msg = msg .. "Incorrect usage_and_error_counts value\n" ..
" Expected: exists \n" ..
" Actual: nil \n"
end

local nicknames = snp_tbl.policy_table.app_policies[app_id].nicknames
if not common.isTableEqual(nicknames, appPropExpected.nicknames) then
msg = msg .. "Incorrect nicknames\n" ..
" Expected: " .. common.tableToString(appPropExpected.nicknames) .. "\n" ..
" Actual: " .. common.tableToString(nicknames) .. "\n"
end

local auth_token = snp_tbl.policy_table.app_policies[app_id].auth_token
if (auth_token ~= appPropExpected.auth_token) then
msg = msg .. "Incorrect auth token value\n" ..
" Expected: " .. appPropExpected.auth_token .. "\n" ..
" Actual: " .. auth_token .. "\n"
end

local cloud_transport_type = snp_tbl.policy_table.app_policies[app_id].cloud_transport_type
if (cloud_transport_type ~= appPropExpected.cloud_transport_type) then
msg = msg .. "Incorrect cloud_transport_type value\n" ..
" Expected: " .. appPropExpected.cloud_transport_type .. "\n" ..
" Actual: " .. cloud_transport_type .. "\n"
end

local enabled = snp_tbl.policy_table.app_policies[app_id].enabled
if (enabled ~= appPropExpected.enabled) then
msg = msg .. "Incorrect enabled value\n"..
" Expected: " .. tostring(appPropExpected.enabled) .. "\n" ..
" Actual: " .. tostring(enabled) .. "\n"
end

local hybrid_app_preference = snp_tbl.policy_table.app_policies[app_id].hybrid_app_preference
if (hybrid_app_preference ~= appPropExpected.hybrid_app_preference) then
msg = msg .. "Incorrect hybrid_app_preference value\n" ..
" Expected: " .. appPropExpected.hybrid_app_preference .. "\n" ..
" Actual: " .. hybrid_app_preference .. "\n"
end

if string.len(msg) > 0 then
common.failTestStep("PTS is incorrect\n".. msg)
end
end

return common
1 change: 1 addition & 0 deletions test_sets/webengine.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@
./test_scripts/WebEngine/025_PTU_update_app_properties.lua
./test_scripts/WebEngine/026_PTU_snapshot_validation.lua
./test_scripts/WebEngine/027_UpdateAppList_unregister_2apps.lua
./test_scripts/WebEngine/028_PTU_snapshot_validation_no_app_connected.lua

0 comments on commit a2040db

Please sign in to comment.