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

[Issue-3620] Added scripts for issue #2535

Merged
merged 2 commits into from
Apr 12, 2021
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
@@ -0,0 +1,51 @@
---------------------------------------------------------------------------------------------------
-- Issue: https://github.com/smartdevicelink/sdl_core/issues/3620
---------------------------------------------------------------------------------------------------
-- Description: Check SDL responds with NACK to Start RPC Service request over 5th SDL protocol
-- if it contains invalid data in bson payload
--
-- Steps:
-- 1. Start SDL, HMI, connect mobile device
-- 2. App tries to start RPC service over 5th SDL protocol with invalid data in bson payload
-- SDL does:
-- - send 'OnServiceUpdate' notification to HMI with 'REQUEST_REJECTED'
-- - respond with NACK to start service request
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local common = require('test_scripts/Defects/7_1/3620/common')

--[[ Local Variables ]]
local appId = 1
local serviceParams = {
reqParams = {
protocolVersion = { type = common.bsonType.STRING, value = "invalid_value" } -- invalid value
},
nackParams = {
rejectedParams = {
type = common.bsonType.ARRAY,
value = {
[1] = { type = common.bsonType.STRING, value = "protocolVersion" }
}
}
}
}

--[[ Local Functions ]]
local function onServiceUpdateExp()
common.hmi.getConnection():ExpectNotification("BasicCommunication.OnServiceUpdate",
{ serviceEvent = "REQUEST_RECEIVED", serviceType = "RPC" },
{ serviceEvent = "REQUEST_REJECTED", serviceType = "RPC" })
:Times(2)
end

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

common.Title("Test")
common.Step("Start RPC Service, NACK", common.startServiceUnprotectedNACK,
{ appId, common.serviceType.RPC, serviceParams.reqParams, serviceParams.nackParams, onServiceUpdateExp })

common.Title("Postconditions")
common.Step("Stop SDL", common.postconditions)
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---------------------------------------------------------------------------------------------------
-- Issue: https://github.com/smartdevicelink/sdl_core/issues/3620
---------------------------------------------------------------------------------------------------
-- Description: Check SDL responds with NACK to protected Start RPC Service request over 5th SDL protocol
-- if it contains invalid data in bson payload
--
-- Steps:
-- 1. Start SDL, HMI, connect mobile device
-- 2. Unprotected RPC service has been started
-- 3. App tries to start protected RPC service over 5th SDL protocol with invalid data in bson payload
-- SDL does:
-- - send 'OnServiceUpdate' notification to HMI with 'REQUEST_REJECTED'
-- - respond with NACK to start service request
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local common = require('test_scripts/Defects/7_1/3620/common')

--[[ Local Variables ]]
local serviceParams = {
serviceType = common.serviceType.RPC,
serviceName = "RPC",
reqParams = {
protocolVersion = { type = common.bsonType.STRING, value = "invalid_value" } -- invalid value
},
nackParams = {
rejectedParams = {
type = common.bsonType.ARRAY,
value = {
[1] = { type = common.bsonType.STRING, value = "protocolVersion" }
}
}
}
}

--[[ Scenario ]]
common.Title("Preconditions")
common.Step("Clean environment", common.preconditions)
common.Step("Start SDL, HMI, connect Mobile, start Session", common.start)
common.Step("Start unprotected RPC service", common.startUnprotectedRPCservice)

common.Title("Test")
common.Step("Start protected RPC Service, NACK", common.startProtectedServiceWithOnServiceUpdate, { serviceParams })

common.Title("Postconditions")
common.Step("Stop SDL", common.postconditions)
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---------------------------------------------------------------------------------------------------
-- Issue: https://github.com/smartdevicelink/sdl_core/issues/3620
---------------------------------------------------------------------------------------------------
-- Description: Check SDL responds with NACK to Start RPC Service request over 5th SDL protocol
-- if it contains non existed session id
--
-- Steps:
-- 1. Start SDL, HMI, connect mobile device
-- 2. App tries to start RPC service over 5th SDL protocol with non existed session id
-- SDL does:
-- - send 'OnServiceUpdate' notification to HMI with 'REQUEST_REJECTED'
-- - respond with NACK to start service request
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local common = require('test_scripts/Defects/7_1/3620/common')

--[[ Local Variables ]]
local nonExistedSessionId = 5
local serviceParams = {
serviceType = common.serviceType.RPC,
serviceName = "RPC",
reqParams = {
protocolVersion = { type = common.bsonType.STRING, value = "5.4.0" }
},
nackParams = {
reason = {
type = common.bsonType.STRING,
value = "Cannot start an unprotected service of type " .. common.serviceType.RPC ..
". Session " .. nonExistedSessionId .. " not found for connection 1"
}
}
}

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

common.Title("Test")
common.Step("Start RPC Service, NACK", common.startServiceNACKwithNonExistedSessionId,
{ serviceParams, nonExistedSessionId })

common.Title("Postconditions")
common.Step("Stop SDL", common.postconditions)
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---------------------------------------------------------------------------------------------------
-- Issue: https://github.com/smartdevicelink/sdl_core/issues/3620
---------------------------------------------------------------------------------------------------
-- Description: Check SDL responds with NACK to protected Start RPC Service request over 5th SDL protocol
-- if it contains non existed session id
--
-- Steps:
-- 1. Start SDL, HMI, connect mobile device
-- 2. Unprotected RPC service has been started
-- 3. App tries to start protected RPC service over 5th SDL protocol with non existed session id
-- SDL does:
-- - send 'OnServiceUpdate' notification to HMI with 'REQUEST_REJECTED'
-- - respond with NACK to start service request
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local common = require('test_scripts/Defects/7_1/3620/common')

--[[ Local Variables ]]
local nonExistedSessionId = 5
local isEncrypted = true
local serviceParams = {
serviceType = common.serviceType.RPC,
serviceName = "RPC",
reqParams = {
protocolVersion = { type = common.bsonType.STRING, value = "5.4.0" }
},
nackParams = {
reason = {
type = common.bsonType.STRING,
value = "Cannot start a protected service of type " .. common.serviceType.RPC ..
". Session " .. nonExistedSessionId .. " not found for connection 1"
}
}
}

--[[ Scenario ]]
common.Title("Preconditions")
common.Step("Clean environment", common.preconditions)
common.Step("Start SDL, HMI, connect Mobile, start Session", common.start)
common.Step("Start unprotected RPC service", common.startUnprotectedRPCservice)

common.Title("Test")
common.Step("Start protected RPC Service, NACK", common.startServiceNACKwithNonExistedSessionId,
{ serviceParams, nonExistedSessionId, isEncrypted })

common.Title("Postconditions")
common.Step("Stop SDL", common.postconditions)
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---------------------------------------------------------------------------------------------------
-- Issue: https://github.com/smartdevicelink/sdl_core/issues/3620
---------------------------------------------------------------------------------------------------
-- Description: Check SDL responds with NACK to protected Start RPC Service request over 5th SDL protocol
-- if BC.OnSystemTimeReady notification has not been received by SDL
--
-- Steps:
-- 1. Start SDL, HMI, connect mobile device
-- 2. Unprotected RPC service is started
-- 3 HMI has not sent BC.OnSystemTimeReady notification
-- 4. App tries to start protected RPC service over 5th SDL protocol with valid data
-- SDL does:
-- - send 'OnServiceUpdate' notification to HMI with 'REQUEST_REJECTED'
-- - respond with NACK to start service request
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local common = require('test_scripts/Defects/7_1/3620/common')

--[[ Local Variables ]]
local serviceParams = {
serviceType = common.serviceType.RPC,
serviceName = "RPC",
reqParams = {
protocolVersion = { type = common.bsonType.STRING, value = "5.4.0" }
},
nackParams = {
reason = {
type = common.bsonType.STRING ,
value = "System time provider is not ready"
}
}
}

--[[ Scenario ]]
common.Title("Preconditions")
common.Step("Clean environment", common.preconditions)
common.Step("Start SDL, HMI, connect Mobile, start Session", common.startWithoutOnSystemTimeReady)
common.Step("Start unprotected RPC service", common.startUnprotectedRPCservice)

common.Title("Test")
common.Step("Start protected RPC Service, NACK", common.startProtectedServiceWithOnServiceUpdate, { serviceParams })

common.Title("Postconditions")
common.Step("Stop SDL", common.postconditions)
93 changes: 93 additions & 0 deletions test_scripts/Defects/7_1/3620/common.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---------------------------------------------------------------------------------------------------
-- Common module
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local common = require("test_scripts/Protocol/commonProtocol")
local constants = require("protocol_handler/ford_protocol_constants")

--[[ General configuration parameters ]]
common.testSettings.isSelfIncluded = false
config.defaultProtocolVersion = 5

--[[ Common Variables ]]
common.SERVICE_TYPE = constants.SERVICE_TYPE
common.FRAME_TYPE = constants.FRAME_TYPE
common.FRAME_INFO = constants.FRAME_INFO

--[[ Common Functions ]]
function common.startServiceNACKwithNonExistedSessionId(pServiceParams, pNonExistedSessionId, isEncrypted)
isEncrypted = isEncrypted or false
local mobSession = common.getMobileSession()
mobSession.sessionId = pNonExistedSessionId
local msg = {
serviceType = pServiceParams.serviceType,
frameType = common.FRAME_TYPE.CONTROL_FRAME,
frameInfo = common.FRAME_INFO.START_SERVICE,
encryption = isEncrypted,
binaryData = common.bson_to_bytes(pServiceParams.reqParams)
}
mobSession:Send(msg)
mobSession:ExpectControlMessage(pServiceParams.serviceType, {
frameInfo = common.FRAME_INFO.START_SERVICE_NACK,
encryption = false
})
:ValidIf(function(_, data)
local act = common.bson_to_table(data.binaryData)
return compareValues(pServiceParams.nackParams, act, "binaryData")
end)
:Timeout(1000)
common.hmi.getConnection():ExpectNotification("BasicCommunication.OnServiceUpdate",
{ serviceEvent = "REQUEST_RECEIVED", serviceType = pServiceParams.serviceName},
{ serviceEvent = "REQUEST_REJECTED", serviceType = pServiceParams.serviceName })
:Times(2)
end

function common.startUnprotectedRPCservice()
local session = common.getMobileSession()
local msg = {
serviceType = common.serviceType.RPC,
frameType = constants.FRAME_TYPE.CONTROL_FRAME,
frameInfo = constants.FRAME_INFO.START_SERVICE,
encryption = false,
binaryData = common.bson_to_bytes({ protocolVersion = { type = common.bsonType.STRING, value = "5.4.0" }})
}
session:Send(msg)

session:ExpectControlMessage(common.serviceType.RPC, {
frameInfo = common.frameInfo.START_SERVICE_ACK,
encryption = false
})
end

function common.startProtectedServiceWithOnServiceUpdate(pServiceParams)
local appId = 1
common.startServiceProtectedNACK(appId, pServiceParams.serviceType, pServiceParams.reqParams,
pServiceParams.nackParams)
common.hmi.getConnection():ExpectNotification("BasicCommunication.OnServiceUpdate",
{ serviceEvent = "REQUEST_RECEIVED", serviceType = pServiceParams.serviceName },
{ serviceEvent = "REQUEST_REJECTED", serviceType = pServiceParams.serviceName })
:Times(2)
end

function common.startWithoutOnSystemTimeReady(pHMIParams)
local event = common.run.createEvent()
common.init.SDL()
:Do(function()
common.init.HMI()
:Do(function()
common.init.HMI_onReady(pHMIParams)
:Do(function()
common.init.connectMobile()
:Do(function()
common.init.allowSDL()
:Do(function()
common.hmi.getConnection():RaiseEvent(event, "Start event")
end)
end)
end)
end)
end)
return common.hmi.getConnection():ExpectEvent(event, "Start event")
end

return common
5 changes: 5 additions & 0 deletions test_sets/Defects/Defects_release_7_1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@
./test_scripts/Defects/7_1/1714_OnSystemRequest_send_binaryData_for_any_requestType.lua
./test_scripts/Defects/7_1/3412_Two_Streaming_apps_and_Alert_requests.lua
./test_scripts/Defects/7_1/3163_SDL_restart_with_gear_change.lua
./test_scripts/Defects/7_1/3620/3620_1_RPC_Service_NACK_invalid_bson.lua
./test_scripts/Defects/7_1/3620/3620_2_RPC_Service_NACK_protected_invalid_bson.lua
./test_scripts/Defects/7_1/3620/3620_3_RPC_Service_NACK_non_existed_session_id.lua
./test_scripts/Defects/7_1/3620/3620_4_RPC_Service_NACK_protected_non_existed_session_id.lua
./test_scripts/Defects/7_1/3620/3620_5_RPC_Service_NACK_before_OnSystemTimeReady.lua