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

update 090 to new common files #2479

Merged
merged 4 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -16,167 +16,100 @@
-- PoliciesManager must initiate the PT Update through the app from consented device,
-- second(non-consented) device should not be used e.i. no second query for user consent should be sent to HMI
---------------------------------------------------------------------------------------------------------------------
if config.defaultMobileAdapterType == "WS" or config.defaultMobileAdapterType == "WSS" then
require('user_modules/script_runner').skipTest("Test is not applicable for WS/WSS connection")
end
require('user_modules/script_runner').isTestApplicable({ { extendedPolicy = { "EXTERNAL_PROPRIETARY" } } })

--[[ General Settings for configuration ]]
Test = require('user_modules/connecttest_resumption')
require('cardinalities')
local mobile_session = require('mobile_session')
local mobile_adapter_controller = require("mobile_adapter/mobile_adapter_controller")
local file_connection = require('file_connection')
local mobile = require('mobile_connection')
local events = require('events')
local utils = require ('user_modules/utils')

--[[ General configuration parameters ]]
-- Create dummy connection
os.execute("ifconfig lo:1 1.0.0.1")

--[[ Required Shared libraries ]]
local commonFunctions = require ('user_modules/shared_testcases/commonFunctions')
local commonSteps = require('user_modules/shared_testcases/commonSteps')
local commonTestCases = require('user_modules/shared_testcases/commonTestCases')
require('user_modules/AppTypes')
local runner = require('user_modules/script_runner')
local common = require('test_scripts/TheSameApp/commonTheSameApp')
local SDL = require('SDL')

--[[ General Precondition before ATF start ]]
commonFunctions:SDLForceStop()
commonSteps:DeleteLogsFileAndPolicyTable()
--[[ Test Configuration ]]
runner.testSettings.isSelfIncluded = false

--[[ Local variables ]]
local mobileHost = "1.0.0.1"
local deviceMAC2 = "9cc72994ab9ca68c1daaf02834f7a94552e82aad3250778f2e12d14afee0a5c6"
local deviceName2 = mobileHost .. ":" .. config.mobilePort
--[[ Local Variables ]]
local devices = {
[1] = { host = "1.0.0.1", port = config.mobilePort, name = "1.0.0.1:" .. config.mobilePort },
[2] = { host = "192.168.100.199", port = config.mobilePort, name = "192.168.100.199:" .. config.mobilePort }
}

--[[ Preconditions ]]
commonFunctions:newTestCasesGroup("Preconditions")
local appParams = {
[1] = { appName = "App1", appID = "0001", fullAppID = "0000001" },
[2] = { appName = "App2", appID = "0002", fullAppID = "0000002" }
}

function Test:Precondition_Connect_device1()
commonTestCases:DelayedExp(2000)
self:connectMobile()
if utils.getDeviceTransportType() == "WIFI" then
EXPECT_HMICALL("BasicCommunication.UpdateDeviceList")
:Do(function(_,data)
self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {})
end)
end
end
--[[ Local Functions ]]
local function connectDeviceTwo()
local deviceList = {
{
name = devices[1].name,
transportType = "WIFI"
},
{
isSDLAllowed = false,
name = devices[2].name,
transportType = "WIFI"
}
}

function Test:Precondition_Register_app_1()
commonTestCases:DelayedExp(3000)
self.mobileSession = mobile_session.MobileSession(self, self.mobileConnection)
self.mobileSession:StartService(7)
:Do(function()
local RequestIDRai1 = self.mobileSession:SendRPC("RegisterAppInterface", config.application1.registerAppInterfaceParams)
EXPECT_HMINOTIFICATION("BasicCommunication.OnAppRegistered")
:Do(function(_,data)
self.HMIAppID = data.params.application.appID
end)
self.mobileSession:ExpectResponse(RequestIDRai1, { success = true, resultCode = "SUCCESS" })
self.mobileSession:ExpectNotification("OnHMIStatus", {hmiLevel = "NONE", audioStreamingState = "NOT_AUDIBLE", systemContext = "MAIN"})
end)
end
if SDL.buildOptions.webSocketServerSupport == "ON" then
table.insert(deviceList, 1, { transportType = "WEBENGINE_WEBSOCKET" })
end

function Test:Precondition_Activate_app_1()
local RequestId = self.hmiConnection:SendRequest("SDL.ActivateApp", { appID = self.HMIAppID})
EXPECT_HMIRESPONSE(RequestId, {result = { code = 0, device = { id = utils.getDeviceMAC(), name = utils.getDeviceName() }, isSDLAllowed = false, method ="SDL.ActivateApp" }})
:Do(function(_, _)
local RequestIdGetMes = self.hmiConnection:SendRequest("SDL.GetUserFriendlyMessage", {language = "EN-US", messageCodes = {"DataConsent"}})
EXPECT_HMIRESPONSE(RequestIdGetMes)
:Do(function()
self.hmiConnection:SendNotification("SDL.OnAllowSDLFunctionality",
{allowed = true, source = "GUI", device = {id = utils.getDeviceMAC(), name = utils.getDeviceName()}})
EXPECT_HMICALL("BasicCommunication.ActivateApp")
:Do(function(_, data)
self.hmiConnection:SendResponse(data.id,"BasicCommunication.ActivateApp", "SUCCESS", {})
end)
:Times(AtLeast(1))
end)
end)
EXPECT_NOTIFICATION("OnHMIStatus", {hmiLevel = "FULL", systemContext = "MAIN", audioStreamingState = "AUDIBLE"})
end
common.getHMIConnection():ExpectRequest("BasicCommunication.UpdateDeviceList",
{
deviceList = deviceList
})
:Do(function(_,data)
common.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {})
end)

function Test:Precondition_Connect_device_2()
local mobileAdapter = self.getDefaultMobileAdapter(mobileHost, config.mobilePort)
local fileConnection = file_connection.FileConnection("mobile.out", mobileAdapter)
self.connection2 = mobile.MobileConnection(fileConnection)
self.mobileSession2 = mobile_session.MobileSession(self, self.connection2)
event_dispatcher:AddConnection(self.connection2)
self.mobileSession2:ExpectEvent(events.connectedEvent, "Connection started")
self.connection2:Connect()
EXPECT_HMICALL("BasicCommunication.UpdateDeviceList",
{
deviceList = {
{
id = deviceMAC2,
name = deviceName2 ,
transportType = utils.getDeviceTransportType()
},
{
id = utils.getDeviceMAC(),
name = utils.getDeviceName(),
transportType = utils.getDeviceTransportType()
},
{
transportType = "WEBENGINE_WEBSOCKET",
}
}
}
):Do(function(_,data)
self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {})
end)
:Times(AtLeast(1))
common.connectMobDevice(2, devices[2], false)
end

--[[ Test ]]
commonFunctions:newTestCasesGroup("Test")
function Test:Test_Register_app_2()
self.mobileSession2:StartService(7)
local function activateAppTwo()
local hmiConnection = common.getHMIConnection()
local RequestId = hmiConnection:SendRequest("SDL.ActivateApp", { appID = common.getHMIAppId(2) })
hmiConnection:ExpectResponse(RequestId, {result = { code = 0, device = { name = devices[2].name }, isSDLAllowed = false, method = "SDL.ActivateApp" }})
:Do(function()
local RaiIdSecond = self.mobileSession2:SendRPC("RegisterAppInterface", config.application2.registerAppInterfaceParams)
EXPECT_HMINOTIFICATION("BasicCommunication.OnAppRegistered")
:Do(function(_,data)
self.HMIAppID2 = data.params.application.appID
end)
self.mobileSession2:ExpectResponse(RaiIdSecond, { success = true, resultCode = "SUCCESS"})
self.mobileSession2:ExpectNotification("OnHMIStatus", {hmiLevel = "NONE", audioStreamingState = "NOT_AUDIBLE", systemContext = "MAIN"})
local RequestIdGetMes = hmiConnection:SendRequest("SDL.GetUserFriendlyMessage", { language = "EN-US", messageCodes = { "DataConsent" } })
hmiConnection:ExpectResponse(RequestIdGetMes)
:Do(function()
hmiConnection:SendNotification("SDL.OnAllowSDLFunctionality",
{ allowed = false, source = "GUI", device = { name = devices[2].name } })
end)
end)
end

function Test:Teat_Activate_app_2()
local RequestId = self.hmiConnection:SendRequest("SDL.ActivateApp", { appID = self.HMIAppID2})
EXPECT_HMIRESPONSE(RequestId, {result = { code = 0, device = { id = deviceMAC2, name = deviceName2 }, isSDLAllowed = false, method ="SDL.ActivateApp" }})
local function startPTU()
local hmiConnection = common.getHMIConnection()
hmiConnection:ExpectRequest("BasicCommunication.PolicyUpdate")
:Do(function()
local RequestIdGetMes = self.hmiConnection:SendRequest("SDL.GetUserFriendlyMessage", {language = "EN-US", messageCodes = {"DataConsent"}})
EXPECT_HMIRESPONSE(RequestIdGetMes)
:Do(function()
self.hmiConnection:SendNotification("SDL.OnAllowSDLFunctionality",
{allowed = false, source = "GUI", device = {id = deviceMAC2, name = deviceName2}})
EXPECT_HMICALL("BasicCommunication.ActivateApp")
:Do(function(_, data)
self.hmiConnection:SendResponse(data.id,"BasicCommunication.ActivateApp", "SUCCESS", {})
end)
:Times(AtLeast(1))
end)
hmiConnection:SendNotification("BasicCommunication.OnSystemRequest",
{ requestType = "PROPRIETARY", fileName = "PolicyTableUpdate", appID = common.getHMIAppId(1) })
common.getMobileSession(2):ExpectNotification("OnSystemRequest", {requestType = "PROPRIETARY"})
:Times(0)
common.getMobileSession(1):ExpectNotification("OnSystemRequest", {requestType = "PROPRIETARY"})
:Do(function(_, data)
hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {})
end)
end)
end

function Test:Test_Start_PTU()
EXPECT_HMICALL("BasicCommunication.PolicyUpdate")
:Do(function()
self.hmiConnection:SendNotification("BasicCommunication.OnSystemRequest",
{ requestType = "PROPRIETARY", fileName = "PolicyTableUpdate", appID = self.HMIAppID })
self.mobileSession2:ExpectNotification("OnSystemRequest", {requestType = "PROPRIETARY"})
:Times(0)
self.mobileSession:ExpectNotification("OnSystemRequest", {requestType = "PROPRIETARY"})
:Do(function(_, data)
self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {})
end)
end)
end
runner.Title("Preconditions")
runner.Step("Clean environment", common.preconditions)
runner.Step("Start SDL, HMI", common.start)
runner.Step("Connect device 1 to SDL", common.connectMobDevice, { 1, devices[1] })
runner.Step("Register App1 from device 1", common.registerAppEx, { 1, appParams[1], 1 })
runner.Step("Activate App1 from device 1", common.activateApp, { 1 })
runner.Step("Connect device 2 to SDL", connectDeviceTwo)

--[[ Postconditions ]]
commonFunctions:newTestCasesGroup("Postconditions")
runner.Title("Test")
runner.Step("Register App2 from device 2", common.registerAppEx, { 2, appParams[2], 2 })
runner.Step("Activate App2 from device 2", activateAppTwo)
runner.Step("Start PTU", startPTU)

function Test.Postcondition_SDLForceStop()
StopSDL()
end
runner.Title("Postconditions")
runner.Step("Stop SDL", common.postconditions)
2 changes: 1 addition & 1 deletion test_sets/policies_all_flows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
./test_scripts/Policies/build_options/087_ATF_New_PTU_Sequence_AppRegistered_PTU_Progress_HTTP.lua
./test_scripts/Policies/build_options/088_ATF_Apply_UpdatedPT_after_OnReceivedPolicyUpdate_from_HMI_PROPRIETARY.lua
./test_scripts/Policies/build_options/089_ATF_Check_SDL_respond_GetURLs_Request_fromHMI_PROPRIETARY.lua
;./test_scripts/Policies/build_options/090_ATF_For_PTU_use_consented_device_only.lua
./test_scripts/Policies/build_options/090_ATF_For_PTU_use_consented_device_only.lua
./test_scripts/Policies/build_options/091_ATF_Check_STATUS_UPDATE_NEEDED_PROPRIETARY.lua
./test_scripts/Policies/build_options/093_ATF_OnStatusUpdate_Trigger_PROPRIETARY.lua
./test_scripts/Policies/build_options/094_ATF_PTS_creation_rule_PROPRIETARY.lua
Expand Down
1 change: 1 addition & 0 deletions test_sets/policies_happy_paths_EXTERNAL_PROPRIETARY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
./test_scripts/Policies/appID_Management/045_ATF_Register_App_Interface_Assign_Default_Policies_To_Application_Which_Appid_Does_Not_Exist_In_LPT.lua
./test_scripts/Policies/appID_Management/046_ATF_Register_App_Interface_Assign_Existing_Policies_To_Application_Which_Appid_Exists_In_LPT.lua
./test_scripts/Policies/build_options/047_ATF_SDL_Build_DEXTENDED_POLICY_EXTERNAL_PROPRIETARY.lua
./test_scripts/Policies/build_options/090_ATF_For_PTU_use_consented_device_only.lua
./test_scripts/Policies/Policies_Security/119_ATF_P_Policies_Performance_Requirement.lua
./test_scripts/Policies/Policies_Security/120_ATF_PolicyTable_Certificate_EMPTY_value.lua
./test_scripts/Policies/Policy_Table_Update/121_ATF_PTU_AppID_NotListed_PT_DeviceConsented_SecondApp.lua
Expand Down