From 890c21d2b3daf00cd7cc268fd46cc8ee431463f2 Mon Sep 17 00:00:00 2001 From: collin Date: Mon, 16 Nov 2020 12:20:23 -0500 Subject: [PATCH 1/4] update 090 to new common files --- ..._ATF_For_PTU_use_consented_device_only.lua | 191 +++++------------- 1 file changed, 56 insertions(+), 135 deletions(-) diff --git a/test_scripts/Policies/build_options/090_ATF_For_PTU_use_consented_device_only.lua b/test_scripts/Policies/build_options/090_ATF_For_PTU_use_consented_device_only.lua index 04f51a61b9..1bc894686a 100644 --- a/test_scripts/Policies/build_options/090_ATF_For_PTU_use_consented_device_only.lua +++ b/test_scripts/Policies/build_options/090_ATF_For_PTU_use_consented_device_only.lua @@ -18,165 +18,86 @@ --------------------------------------------------------------------------------------------------------------------- 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') - ---[[ General Precondition before ATF start ]] -commonFunctions:SDLForceStop() -commonSteps:DeleteLogsFileAndPolicyTable() - ---[[ Local variables ]] -local mobileHost = "1.0.0.1" -local deviceMAC2 = "9cc72994ab9ca68c1daaf02834f7a94552e82aad3250778f2e12d14afee0a5c6" -local deviceName2 = mobileHost .. ":" .. config.mobilePort +local runner = require('user_modules/script_runner') +local common = require('test_scripts/TheSameApp/commonTheSameApp') +local common2 = require('test_scripts/Capabilities/PersistingHMICapabilities/common') ---[[ Preconditions ]] -commonFunctions:newTestCasesGroup("Preconditions") - -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 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 } +} -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 - -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 +local appParams = { + [1] = { appName = "App1", appID = "0001", fullAppID = "0000001" }, + [2] = { appName = "App2", appID = "0002", fullAppID = "0000002" } +} -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", +--[[ Local Functions ]] +local function connectDeviceTwo() + common.getHMIConnection():ExpectRequest("BasicCommunication.UpdateDeviceList", { deviceList = { { - id = deviceMAC2, - name = deviceName2 , - transportType = utils.getDeviceTransportType() + transportType = "WEBENGINE_WEBSOCKET", }, { - id = utils.getDeviceMAC(), - name = utils.getDeviceName(), - transportType = utils.getDeviceTransportType() + name = devices[1].name, + transportType = "WIFI" }, { - transportType = "WEBENGINE_WEBSOCKET", + isSDLAllowed = false, + name = devices[2].name, + transportType = "WIFI" } - } - } - ):Do(function(_,data) - self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + }}) + :Do(function(_,data) + common.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {}) end) - :Times(AtLeast(1)) -end ---[[ Test ]] -commonFunctions:newTestCasesGroup("Test") -function Test:Test_Register_app_2() - self.mobileSession2:StartService(7) - :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"}) - end) + common.connectMobDevice(2, devices[2], false) 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 activateAppTwo() + local RequestId = common.getHMIConnection():SendRequest("SDL.ActivateApp", { appID = common.getHMIAppId(2) }) + EXPECT_HMIRESPONSE(RequestId, {result = { code = 0, device = { name = devices[2].name }, 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 = 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) + local RequestIdGetMes = common.getHMIConnection():SendRequest("SDL.GetUserFriendlyMessage", { language = "EN-US", messageCodes = { "DataConsent" } }) + EXPECT_HMIRESPONSE(RequestIdGetMes) + :Do(function() + common.getHMIConnection():SendNotification("SDL.OnAllowSDLFunctionality", + { allowed = false, source = "GUI", device = { name = devices[2].name } }) 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"}) +local function startPTU() + EXPECT_HMICALL("BasicCommunication.PolicyUpdate") + :Do(function() + common.getHMIConnection():SendNotification("BasicCommunication.OnSystemRequest", + { requestType = "PROPRIETARY", fileName = "PolicyTableUpdate", appID = common.getHMIAppId(1) }) + common.getMobileSession(2):ExpectNotification("OnSystemRequest", {requestType = "PROPRIETARY"}) :Times(0) - self.mobileSession:ExpectNotification("OnSystemRequest", {requestType = "PROPRIETARY"}) + common.getMobileSession(1):ExpectNotification("OnSystemRequest", {requestType = "PROPRIETARY"}) :Do(function(_, data) - self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + common.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {}) end) end) end ---[[ Postconditions ]] -commonFunctions:newTestCasesGroup("Postconditions") +runner.Title("Preconditions") +runner.Step("Clean environment", common.preconditions) +runner.Step("Start SDL, HMI", common2.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) -function Test.Postcondition_SDLForceStop() - StopSDL() -end +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) + +runner.Title("Postconditions") +runner.Step("Stop SDL", common.postconditions) \ No newline at end of file From 669c8680a255840c488d74d164f59b9988e56ccb Mon Sep 17 00:00:00 2001 From: collin Date: Wed, 18 Nov 2020 17:24:36 -0500 Subject: [PATCH 2/4] address review comments --- ..._ATF_For_PTU_use_consented_device_only.lua | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/test_scripts/Policies/build_options/090_ATF_For_PTU_use_consented_device_only.lua b/test_scripts/Policies/build_options/090_ATF_For_PTU_use_consented_device_only.lua index 1bc894686a..082f12607a 100644 --- a/test_scripts/Policies/build_options/090_ATF_For_PTU_use_consented_device_only.lua +++ b/test_scripts/Policies/build_options/090_ATF_For_PTU_use_consented_device_only.lua @@ -21,7 +21,9 @@ require('user_modules/script_runner').isTestApplicable({ { extendedPolicy = { "E --[[ Required Shared libraries ]] local runner = require('user_modules/script_runner') local common = require('test_scripts/TheSameApp/commonTheSameApp') -local common2 = require('test_scripts/Capabilities/PersistingHMICapabilities/common') + +--[[ Test Configuration ]] +runner.testSettings.isSelfIncluded = false --[[ Local Variables ]] local devices = { @@ -60,35 +62,37 @@ local function connectDeviceTwo() end local function activateAppTwo() - local RequestId = common.getHMIConnection():SendRequest("SDL.ActivateApp", { appID = common.getHMIAppId(2) }) - EXPECT_HMIRESPONSE(RequestId, {result = { code = 0, device = { name = devices[2].name }, isSDLAllowed = false, method = "SDL.ActivateApp" }}) + 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 RequestIdGetMes = common.getHMIConnection():SendRequest("SDL.GetUserFriendlyMessage", { language = "EN-US", messageCodes = { "DataConsent" } }) - EXPECT_HMIRESPONSE(RequestIdGetMes) + local RequestIdGetMes = hmiConnection:SendRequest("SDL.GetUserFriendlyMessage", { language = "EN-US", messageCodes = { "DataConsent" } }) + hmiConnection:ExpectResponse(RequestIdGetMes) :Do(function() - common.getHMIConnection():SendNotification("SDL.OnAllowSDLFunctionality", + hmiConnection:SendNotification("SDL.OnAllowSDLFunctionality", { allowed = false, source = "GUI", device = { name = devices[2].name } }) end) end) end local function startPTU() - EXPECT_HMICALL("BasicCommunication.PolicyUpdate") - :Do(function() - common.getHMIConnection():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) - common.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {}) - end) + local hmiConnection = common.getHMIConnection() + hmiConnection:ExpectRequest("BasicCommunication.PolicyUpdate") + :Do(function() + 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 runner.Title("Preconditions") runner.Step("Clean environment", common.preconditions) -runner.Step("Start SDL, HMI", common2.start) +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 }) From dfcf113c0bfdd78a3fd1864eef0b2dcfc9bd8084 Mon Sep 17 00:00:00 2001 From: collin Date: Thu, 19 Nov 2020 09:54:55 -0500 Subject: [PATCH 3/4] fix test when core ws server is off, skip when running WS mobile adapter --- ..._ATF_For_PTU_use_consented_device_only.lua | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/test_scripts/Policies/build_options/090_ATF_For_PTU_use_consented_device_only.lua b/test_scripts/Policies/build_options/090_ATF_For_PTU_use_consented_device_only.lua index 082f12607a..e773b89c74 100644 --- a/test_scripts/Policies/build_options/090_ATF_For_PTU_use_consented_device_only.lua +++ b/test_scripts/Policies/build_options/090_ATF_For_PTU_use_consented_device_only.lua @@ -16,11 +16,15 @@ -- 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" } } }) --[[ Required Shared libraries ]] local runner = require('user_modules/script_runner') local common = require('test_scripts/TheSameApp/commonTheSameApp') +local SDL = require('SDL') --[[ Test Configuration ]] runner.testSettings.isSelfIncluded = false @@ -38,27 +42,31 @@ local appParams = { --[[ Local Functions ]] local function connectDeviceTwo() - common.getHMIConnection():ExpectRequest("BasicCommunication.UpdateDeviceList", + local deviceList = { { - deviceList = { - { - transportType = "WEBENGINE_WEBSOCKET", - }, - { - name = devices[1].name, - transportType = "WIFI" - }, - { - isSDLAllowed = false, - name = devices[2].name, - transportType = "WIFI" - } - }}) - :Do(function(_,data) - common.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {}) - end) + name = devices[1].name, + transportType = "WIFI" + }, + { + isSDLAllowed = false, + name = devices[2].name, + transportType = "WIFI" + } + } + + if SDL.buildOptions.webSocketServerSupport == "ON" then + table.insert(deviceList, 1, { transportType = "WEBENGINE_WEBSOCKET" }) + end + + common.getHMIConnection():ExpectRequest("BasicCommunication.UpdateDeviceList", + { + deviceList = deviceList + }) + :Do(function(_,data) + common.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {}) + end) - common.connectMobDevice(2, devices[2], false) + common.connectMobDevice(2, devices[2], false) end local function activateAppTwo() From 7c293dd9723024d24808db160a770928292d2169 Mon Sep 17 00:00:00 2001 From: collin Date: Thu, 19 Nov 2020 09:57:59 -0500 Subject: [PATCH 4/4] enable 090 in test sets --- test_sets/policies_all_flows.txt | 2 +- test_sets/policies_happy_paths_EXTERNAL_PROPRIETARY.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test_sets/policies_all_flows.txt b/test_sets/policies_all_flows.txt index 7427a2447f..c27db0a309 100644 --- a/test_sets/policies_all_flows.txt +++ b/test_sets/policies_all_flows.txt @@ -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 diff --git a/test_sets/policies_happy_paths_EXTERNAL_PROPRIETARY.txt b/test_sets/policies_happy_paths_EXTERNAL_PROPRIETARY.txt index 5d626256b2..600c8d748f 100644 --- a/test_sets/policies_happy_paths_EXTERNAL_PROPRIETARY.txt +++ b/test_sets/policies_happy_paths_EXTERNAL_PROPRIETARY.txt @@ -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