From 5452dfc4910335c1ba49a4791087659839382135 Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Thu, 9 May 2019 15:09:57 -0400 Subject: [PATCH 1/9] Implement reset of mobileSecurities in Security Manager --- modules/mobile_session_impl.lua | 1 + modules/security/security_manager.lua | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/modules/mobile_session_impl.lua b/modules/mobile_session_impl.lua index b561bcb8..7c295a24 100644 --- a/modules/mobile_session_impl.lua +++ b/modules/mobile_session_impl.lua @@ -281,6 +281,7 @@ function mt.__index:StopRPC() return ret :Do(function(_, _) self.security:unregisterAllSecureServices() + self.security:unregisterSessionSecurity() end) end diff --git a/modules/security/security_manager.lua b/modules/security/security_manager.lua index acc09339..b6c70e16 100644 --- a/modules/security/security_manager.lua +++ b/modules/security/security_manager.lua @@ -133,6 +133,10 @@ function security_mt.__index:registerSessionSecurity() end end +function security_mt.__index:unregisterSessionSecurity() + SecurityManager.mobileSecurities[self.session.sessionId.get()] = nil +end + --- Register service into mobile session security. Service assumed as secure -- @tparam number service Service number function security_mt.__index:registerSecureService(service) From f488ecce854d9a0093c3e231a6bf23360c79a100 Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Wed, 29 May 2019 01:59:36 -0400 Subject: [PATCH 2/9] Make 1st frame always unencrypted --- modules/protocol_handler/protocol_handler.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/protocol_handler/protocol_handler.lua b/modules/protocol_handler/protocol_handler.lua index c79d9395..7101eb76 100644 --- a/modules/protocol_handler/protocol_handler.lua +++ b/modules/protocol_handler/protocol_handler.lua @@ -359,7 +359,7 @@ function mt.__index:Compose(message) -- Create message firstframe local firstFrameMessage = { version = message.version, - encryption = message.encryption, + encryption = false, -- 1st frame has to be always unencrypted frameType = constants.FRAME_TYPE.FIRST_FRAME, serviceType = message.serviceType, frameInfo = 0, From b2fa650b21f11255ad49c3265802c840172c081a Mon Sep 17 00:00:00 2001 From: ShobhitAd Date: Mon, 8 Jul 2019 09:02:23 -0400 Subject: [PATCH 3/9] Update SyncMsgVersion from 5.1 to 6.0 --- modules/config.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/config.lua b/modules/config.lua index 05c42534..967a7a3c 100644 --- a/modules/config.lua +++ b/modules/config.lua @@ -86,8 +86,8 @@ config.application1 = { syncMsgVersion = { - majorVersion = 5, - minorVersion = 1 + majorVersion = 6, + minorVersion = 0 }, appName = "Test Application", isMediaApplication = true, @@ -114,8 +114,8 @@ config.application2 = { syncMsgVersion = { - majorVersion = 5, - minorVersion = 1 + majorVersion = 6, + minorVersion = 0 }, appName = "Test Application2", isMediaApplication = true, @@ -142,8 +142,8 @@ config.application3 = { syncMsgVersion = { - majorVersion = 5, - minorVersion = 1 + majorVersion = 6, + minorVersion = 0 }, appName = "Test Application3", isMediaApplication = true, @@ -170,8 +170,8 @@ config.application4 = { syncMsgVersion = { - majorVersion = 5, - minorVersion = 1 + majorVersion = 6, + minorVersion = 0 }, appName = "Test Application4", isMediaApplication = true, @@ -198,8 +198,8 @@ config.application5 = { syncMsgVersion = { - majorVersion = 5, - minorVersion = 1 + majorVersion = 6, + minorVersion = 0 }, appName = "Test Application5", isMediaApplication = true, From 9d00061c91d00a0330f8230687e834b01c3033ec Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Fri, 28 Jun 2019 12:32:57 -0400 Subject: [PATCH 4/9] Remove dependency on 'excludeReport' configuration parameter --- modules/atf_logger.lua | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/modules/atf_logger.lua b/modules/atf_logger.lua index 44ad2780..75d42b33 100644 --- a/modules/atf_logger.lua +++ b/modules/atf_logger.lua @@ -49,9 +49,9 @@ local controlMessagesHB = {} controlMessagesHB[ford_constants.FRAME_INFO.HEARTBEAT] = "Heartbeat" controlMessagesHB[ford_constants.FRAME_INFO.HEARTBEAT_ACK] = "HeartbeatACK" -Logger.mobile_log_format = "%s (%s) [%s, sessionId: %s, version: %s, frameType: %s, " - .. "encryption: %s, serviceType: %s, frameInfo: %s, messageId: %s, binaryDataSize: %s] : %s \n" -Logger.hmi_log_format = "%s (%s) : %s \n" +Logger.mobile_log_format = "%s [%s] [%s, sessionId: %s, version: %s, frameType: %s, " + .. "encryption: %s, serviceType: %s, frameInfo: %s, messageId: %s, binaryDataSize: %s] : %s \n\n" +Logger.hmi_log_format = "%s [%s] %s \n" local rpc_function_id @@ -93,7 +93,7 @@ function Logger.formated_time(without_date) if without_date == true then return qdatetime.get_datetime("hh:mm:ss,zzz") end - return qdatetime.get_datetime("dd MM yyyy hh:mm:ss, zzz") + return qdatetime.get_datetime("dd-MM-yyyy hh:mm:ss,zzz") end --- Check message is it HMI tract @@ -123,7 +123,7 @@ end -- @tparam string tract Tract information -- @tparam string message String representation of message from mobile application to SDL function Logger:MOBtoSDL(tract, message) - local log_str = string.format(Logger.mobile_log_format,"MOB->SDL ", Logger.formated_time(), + local log_str = string.format(Logger.mobile_log_format,"MOB->SDL", Logger.formated_time(), get_function_name(message), message.sessionId, message.version, message.frameType, message.encryption, message.serviceType, message.frameInfo, message.messageId, getBinaryDataSize(message.binaryData), message.payload) if is_hmi_tract(tract, message) then @@ -167,7 +167,7 @@ end -- @tparam string tract Tract information -- @tparam string message String representation of message from HMI to SDL function Logger:HMItoSDL(tract, message) - local log_str = string.format(Logger.hmi_log_format, "HMI->SDL", Logger.formated_time(), message) + local log_str = string.format(Logger.hmi_log_format, "HMI->SDL", Logger.formated_time(), message .. "\n") if is_hmi_tract(tract, message) then self.atf_log_file:write(log_str) end @@ -244,10 +244,9 @@ function Logger.init_log(script_name) return Logger end ---- Store auxiliary message about start of new test step of test scenario into ATF log file (only if `config.excludeReport` is set to `false`) +--- Store auxiliary message about start of new test step of test scenario into ATF log file -- @tparam string test_case Test step name function Logger.LOGTestCaseStart(test_case) - if config.excludeReport then return end Logger:StartTestCase(test_case) end @@ -255,7 +254,6 @@ end -- @tparam string tract Tract information -- @tparam string message String representation of message function Logger.LOG(tract, message) - if config.excludeReport then return end Logger[tract](Logger, tract, message) end From 36200d48d3d47fe64b674cd31e170d8cdb28a784 Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Fri, 28 Jun 2019 12:33:40 -0400 Subject: [PATCH 5/9] Switch off XML Report by default --- modules/config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/config.lua b/modules/config.lua index 967a7a3c..0b31fd61 100644 --- a/modules/config.lua +++ b/modules/config.lua @@ -68,7 +68,7 @@ config.ShowTimeInConsole = true --- Flag which defines whether ATF performs validation of Mobile and HMI messages by API config.ValidateSchema = true --- Flag which defines whether ATF ignores collecting of reports -config.excludeReport = false +config.excludeReport = true --- Flag which defines whether ATF creates full ATF logs (with json files and service messages) config.storeFullATFLogs = true --- Flag which defines whether ATF stores full SDLCore logs From 212482844c6792d75053ca9fbc2ceb241ac09f5d Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Thu, 22 Aug 2019 14:51:43 -0400 Subject: [PATCH 6/9] Fix delay for zero expectations in callbacks --- modules/expectations.lua | 6 +++++- modules/testbase.lua | 46 ++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/modules/expectations.lua b/modules/expectations.lua index cb529bc3..cbffd0c6 100644 --- a/modules/expectations.lua +++ b/modules/expectations.lua @@ -46,6 +46,9 @@ function Expectations.Expectation(name, connection) else error("Expectation:Times() must be called with number or Cardinality argument") end + if self.timesLE == 0 and self.timesGE == 0 then + self.isDelayNeedsToBeApplied = true + end return self end @@ -170,7 +173,8 @@ function Expectations.Expectation(name, connection) actions = { }, -- Sequence of actions to be executed when complied pinned = false, -- True if the expectation is pinned list = nil, -- ExpectationsList the expectation belongs to - isAtLeastOneFail = false -- True if at least one validation fails + isAtLeastOneFail = false, -- True if at least one validation fails + isDelayNeedsToBeApplied = false -- True if delay for zero occurrence expectation needs to be applied } setmetatable(e, mt) diff --git a/modules/testbase.lua b/modules/testbase.lua index 7652610e..4c7f0ca4 100644 --- a/modules/testbase.lua +++ b/modules/testbase.lua @@ -135,32 +135,7 @@ function control.runNextCase() end atf_logger.LOGTestCaseStart(Test.current_case_name) testcase(Test) - --- Perform delay for the time defined in 'zeroOccurrenceTimeout' configuration parameter - -- Create expectation on a custom event and then raise this event after timeout - -- @tparam Connection pConnection Network connection (Mobile or HMI) - local function wait(pConnection) - local timeout = config.zeroOccurrenceTimeout - local event = events.Event() - event.level = 3 - event.matches = function(event1, event2) return event1 == event2 end - local ret = Expectation("Wait", pConnection) - ret.event = event - ret:Timeout(timeout + 5000) - event_dispatcher:AddEvent(pConnection, event, ret) - Test:AddExpectation(ret) - --- Raise an event - local function toRun() - event_dispatcher:RaiseEvent(pConnection, event) - end - Test:RunAfter(toRun, timeout) - end - - for _, v in Test.expectations_list:List() do - if v.timesLE == 0 and v.timesGE == 0 then - wait(v.connection) - end - end else if SDL.autoStarted then @@ -203,6 +178,27 @@ local function CheckStatus() critical(SDL.exitOnCrash) SDL:DeleteFile() end + --- Perform delay for the time defined in 'zeroOccurrenceTimeout' configuration parameter + -- Create expectation on a custom event and then raise this event after timeout + -- @tparam Connection pConnection Network connection (Mobile or HMI) + local function wait(pConnection) + local timeout = config.zeroOccurrenceTimeout + local event = events.Event() + event.level = 3 + event.matches = function(event1, event2) return event1 == event2 end + local ret = Expectation("Wait", pConnection) + ret.event = event + ret:Timeout(timeout + 5000) + event_dispatcher:AddEvent(pConnection, event, ret) + Test:AddExpectation(ret) + Test:RunAfter(function() event_dispatcher:RaiseEvent(pConnection, event) end, timeout) + end + for _, v in Test.expectations_list:List() do + if v.isDelayNeedsToBeApplied then + v.isDelayNeedsToBeApplied = false + wait(v.connection) + end + end if Test.expectations_list:Any(function(e) return not e.status end) then return end for _, e in ipairs(Test.expectations_list) do if e.status ~= SUCCESS then From 6af334eb77a15e6ea1664a668b807c43158233cd Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Mon, 9 Sep 2019 03:35:31 -0400 Subject: [PATCH 7/9] Disable unused SDL loggers --- modules/SDL.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/SDL.lua b/modules/SDL.lua index 9c598e55..1e7f6b73 100644 --- a/modules/SDL.lua +++ b/modules/SDL.lua @@ -187,7 +187,15 @@ local function updateSDLLogProperties() }, { name = "log4j.appender.TelnetLogging.layout.ConversionPattern", - value = "%%-5p [%%d{yyyy-MM-dd HH-mm:ss,SSS}][%%t][%%c] %%F:%%L %%M: %%m" + value = "%%-5p [%%d{yyyy-MM-dd HH:mm:ss,SSS}][%%t][%%c] %%F:%%L %%M: %%m" + }, + { + name = "log4j.appender.TransportManagerLogFile.File", + value = "/dev/null" + }, + { + name = "log4j.appender.ProtocolFordHandlingLogFile.File", + value = "/dev/null" } } From a1d4bebade3ea02cfb3f2a0ed6fb6999a2eb9deb Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Tue, 24 Sep 2019 00:57:14 -0400 Subject: [PATCH 8/9] Fix parsing of multi-frame messages for 2 sessions --- modules/protocol_handler/protocol_handler.lua | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/protocol_handler/protocol_handler.lua b/modules/protocol_handler/protocol_handler.lua index a251dbab..d34a6f1d 100644 --- a/modules/protocol_handler/protocol_handler.lua +++ b/modules/protocol_handler/protocol_handler.lua @@ -23,7 +23,8 @@ function ProtocolHandler.ProtocolHandler() local ret = { buffer = "", - frames = { } + frames = { }, + totalSize = { } } setmetatable(ret, mt) return ret @@ -276,24 +277,25 @@ function mt.__index:Parse(binary, validateJson, frameHandler) or msg._technical.decryptionStatus == securityConstants.SECURITY_STATUS.ERROR then table.insert(res, msg) else + local key = "s"..msg.sessionId.."m"..msg.messageId if msg.frameType == constants.FRAME_TYPE.CONTROL_FRAME then table.insert(res, msg) elseif msg.frameType == constants.FRAME_TYPE.FIRST_FRAME then - self.frames[msg.messageId] = "" - self.totalSize = msg.size + self.frames[key] = "" + self.totalSize[key] = msg.size elseif msg.frameType == constants.FRAME_TYPE.SINGLE_FRAME then if isBinaryDataHasHeader(msg) then parseBinaryHeader(msg, validateJson) end table.insert(res, msg) elseif msg.frameType == constants.FRAME_TYPE.CONSECUTIVE_FRAME then - self.frames[msg.messageId] = self.frames[msg.messageId] .. msg.binaryData - self.totalSize = self.totalSize + msg.size + self.frames[key] = self.frames[key] .. msg.binaryData + self.totalSize[key] = self.totalSize[key] + msg.size if msg.frameInfo == constants.FRAME_INFO.LAST_FRAME then - msg.binaryData = self.frames[msg.messageId] - msg.size = self.totalSize - self.frames[msg.messageId] = nil - self.totalSize = nil + msg.binaryData = self.frames[key] + msg.size = self.totalSize[key] + self.frames[key] = nil + self.totalSize[key] = nil if isBinaryDataHasHeader(msg) then parseBinaryHeader(msg, validateJson) end From d848a7a53c69eca9320bdf86f38088bb9c587442 Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Thu, 26 Sep 2019 14:11:15 -0400 Subject: [PATCH 9/9] Implement another solution by using Threshold option --- modules/SDL.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/SDL.lua b/modules/SDL.lua index 1e7f6b73..69ddde39 100644 --- a/modules/SDL.lua +++ b/modules/SDL.lua @@ -190,12 +190,12 @@ local function updateSDLLogProperties() value = "%%-5p [%%d{yyyy-MM-dd HH:mm:ss,SSS}][%%t][%%c] %%F:%%L %%M: %%m" }, { - name = "log4j.appender.TransportManagerLogFile.File", - value = "/dev/null" + name = "log4j.appender.TransportManagerLogFile", + value = "SafeFileAppender\nlog4j.appender.TransportManagerLogFile.Threshold=OFF" }, { - name = "log4j.appender.ProtocolFordHandlingLogFile.File", - value = "/dev/null" + name = "log4j.appender.ProtocolFordHandlingLogFile", + value = "SafeFileAppender\nlog4j.appender.ProtocolFordHandlingLogFile.Threshold=OFF" } }