From 5eb34c63ee411bdf3fa561db8805c005d8a4e945 Mon Sep 17 00:00:00 2001 From: uhi22 Date: Mon, 15 May 2023 22:34:49 +0200 Subject: [PATCH] feature: prepared some test cases for fault injection of response codes --- exiConnector.py | 19 +++++++++++++++++++ fsmEvse.py | 10 ++++++++++ mytestsuite.py | 23 ++++++++++++++++------- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/exiConnector.py b/exiConnector.py index 46be452..5d57443 100644 --- a/exiConnector.py +++ b/exiConnector.py @@ -82,6 +82,25 @@ exiHexDemoSupportedApplicationProtocolRequest2="8000ebab9371d34b9b79d189a98989c1 # (7) PreChargeReq # "result": "809a001150400000c80006400000" +# 809a0232417b661514a4cb91e0202d0691559529548c0841e0fc1af4507460c0 SessionSetupRes with NewSessionEstablished +# 809a0232417b661514a4cb91e0A02d0691559529548c0841e0fc1af4507460c0 SessionSetupRes with SequenceError +# 809a021a3b7c417774813311a00120024100c4 ServiceDiscoveryRes +# 809a021a3b7c417774813311a0A120024100c4 ServiceDiscoveryRes with SequenceError +# 809a021a3b7c417774813311c000 ServicePaymentSelectionRes +# 809a021a3b7c417774813311c0A0 ServicePaymentSelectionRes with SequenceError +# 809a021a3b7c417774813310c00200 ContractAuthenticationRes +# 809a021a3b7c417774813310c0A200 ContractAuthenticationRes with SequenceError +# 809a0125e6cecc50800001ec00200004051828758405500080000101844138101c2432c04081436c900c0c000041435ecc044606000200 ChargeParameterDiscovery +# 809a0125e6cecd50810001ec00201004051828758405500080000101844138101c2432c04081436c900c0c000041435ecc044606000200 ChargeParameterDiscovery with ServiceSelectionInvalid +# 809a0125e6cecc5020004080000400 CableCheckRes +# 809a0125e6cecc5020804080000400 CableCheckRes with "FAILED" +# 809a0125e6cecc516000408000008284de880800 PreChargeRes +# 809a0125e6cecc516080408000008284de880800 PreChargeRes with "FAILED" +# 809a0125e6cecc51400420400000 PowerDeliveryRes +# 809a0125e6cecc51408420400000 PowerDeliveryRes with "FAILED" +# 809a0125e6cecc50e0004080000082867dc8081818000000040a1b64802030882702038486580800 CurrentDemandRes +# 809a0125e6cecc50e0804080000082867dc8081818000000040a1b64802030882702038486580800 CurrentDemandRes with "FAILED" + # Configuration of the exi converter tool if os.name == "nt": diff --git a/fsmEvse.py b/fsmEvse.py index d2d402b..930e924 100644 --- a/fsmEvse.py +++ b/fsmEvse.py @@ -78,6 +78,10 @@ class fsmEvse(): # todo: check the request content, and fill response parameters msg = addV2GTPHeader(exiEncode("EDa")) # EDa for Encode, Din, SessionSetupResponse self.addToTrace("responding " + prettyHexMessage(msg)) + if (testsuite_faultinjection_is_triggered(TC_EVSE_ResponseCode_SequenceError_for_SessionSetup)): + # send a SessionSetupResponse with Responsecode SequenceError + msg = addV2GTPHeader("809a0232417b661514a4cb91e0A02d0691559529548c0841e0fc1af4507460c0") + self.addToTrace("responding " + prettyHexMessage(msg)) self.Tcp.transmit(msg) self.publishStatus("Session established") self.enterState(stateWaitForServiceDiscoveryRequest) @@ -94,6 +98,9 @@ class fsmEvse(): if (strConverterResult.find("ServiceDiscoveryReq")>0): # todo: check the request content, and fill response parameters msg = addV2GTPHeader(exiEncode("EDb")) # EDb for Encode, Din, ServiceDiscoveryResponse + if (testsuite_faultinjection_is_triggered(TC_EVSE_ResponseCode_SequenceError_for_ServiceDiscoveryRes)): + # send a ServiceDiscoveryRes with Responsecode SequenceError + msg = addV2GTPHeader("809a021a3b7c417774813311a0A120024100c4") self.addToTrace("responding " + prettyHexMessage(msg)) self.Tcp.transmit(msg) self.publishStatus("Services discovered") @@ -111,6 +118,9 @@ class fsmEvse(): if (strConverterResult.find("ServicePaymentSelectionReq")>0): # todo: check the request content, and fill response parameters msg = addV2GTPHeader(exiEncode("EDc")) # EDc for Encode, Din, ServicePaymentSelectionResponse + if (testsuite_faultinjection_is_triggered(TC_EVSE_ResponseCode_SequenceError_for_ServicePaymentSelectionRes)): + # send a ServicePaymentSelectionRes with Responsecode SequenceError + msg = addV2GTPHeader("809a021a3b7c417774813311c0A0") self.addToTrace("responding " + prettyHexMessage(msg)) self.Tcp.transmit(msg) self.publishStatus("ServicePayment selected") diff --git a/mytestsuite.py b/mytestsuite.py index 0e6a918..1843b7e 100644 --- a/mytestsuite.py +++ b/mytestsuite.py @@ -11,13 +11,22 @@ # The list of test cases. Each must have a unique test case ID. TC_NOTHING_TO_TEST = 0 -TC_EVSE_Timeout_during_CableCheck = 1 -TC_EVSE_Timeout_during_PreCharge = 2 -TC_EVSE_Shutdown_during_PreCharge = 3 -TC_EVSE_Shutdown_during_CurrentDemand = 4 -TC_EVSE_Malfunction_during_CurrentDemand = 5 -TC_EVSE_Timeout_during_CurrentDemand = 6 -TC_EVSE_LastTest = 7 +TC_EVSE_ResponseCode_SequenceError_for_SessionSetup = 1 +TC_EVSE_ResponseCode_SequenceError_for_ServiceDiscoveryRes = 2 +TC_EVSE_ResponseCode_SequenceError_for_ServicePaymentSelectionRes = 3 +TC_EVSE_ResponseCode_SequenceError_for_ContractAuthenticationRes = 4 +TC_EVSE_ResponseCode_ServiceSelectionInvalid_for_ChargeParameterDiscovery = 5 +TC_EVSE_ResponseCode_Failed_for_CableCheckRes = 6 +TC_EVSE_ResponseCode_Failed_for_PreChargeRes = 7 +TC_EVSE_ResponseCode_Failed_for_PowerDeliveryRes = 8 +TC_EVSE_ResponseCode_Failed_for_CurrentDemandRes = 9 +TC_EVSE_Timeout_during_CableCheck = 10 +TC_EVSE_Timeout_during_PreCharge = 11 +TC_EVSE_Shutdown_during_PreCharge = 12 +TC_EVSE_Shutdown_during_CurrentDemand = 13 +TC_EVSE_Malfunction_during_CurrentDemand = 14 +TC_EVSE_Timeout_during_CurrentDemand = 15 +TC_EVSE_LastTest = 16 # variables