blob: 693fed6c6dc614fc4130290853080da8eecb0231 [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2017 Ericsson Telecom AB
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
///////////////////////////////////////////////////////////////////////////////
// File: EPTF_LwM2M_Tests.ttcn
// Description:
// Rev: R1A
// Prodnr: CNL 113 859
// Updated: 2017-09-01
// Contact: http://ttcn.ericsson.se
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// Module: EPTF_LwM2M_Tests
//
// Purpose:
// This module contains the component tests for the EPTF COAP Applib
//
// Module Parameters:
// tsp_SUT_localHost - *charstring* - Hostname of the tested LwM2M entity
// tsp_SUT_localPort - *integer* - Port number of the tested LwM2M entity
// tsp_SUT_remoteHost - *charstring* - Hostname of the tester component
// tsp_SUT_remotePort - *integer* - Port number of the tester component
// tsp_Leshan_host - *charstring* - Hostname of the Leshan server used as SUT
// tsp_Leshan_coapPort - *integer* - Port number (unencyprted) of the Leshan server used as SUT
// tsp_Leshan_coapsPort - *integer* - Port number (DTLS) of the Leshan server used as SUT
//
///////////////////////////////////////////////////////////////
module EPTF_LwM2M_Tests
{
import from EPTF_MBT_LGen_Definitions all;
import from EPTF_MBT_LGen_Functions all;
import from EPTF_COAP_LGen_Definitions all;
import from EPTF_COAP_LGen_Functions all;
import from EPTF_COAP_LocalTransport_Definitions all;
import from EPTF_COAP_LocalTransport_Functions all;
import from EPTF_LwM2M_LGen_Definitions all;
import from EPTF_LwM2M_LGen_Functions all;
import from EPTF_LwM2M_CoapApplibTransport_Definitions all;
import from EPTF_LwM2M_CoapApplibTransport_Functions all;
import from EPTF_LwM2M_Object_Definitions all;
import from EPTF_CLL_Base_Functions all;
import from CoAP_Types all;
import from LightweightM2M_Types all;
import from IoT_FT_Framework_Definitions all;
import from IoT_FT_Framework_Functions all;
import from IFW_CoAP_Peer_Definitions all;
import from IFW_CoAP_Peer_TestSteps all;
import from Socket_API_Definitions all;
modulepar charstring tsp_SUT_localHost := "127.0.0.1";
modulepar integer tsp_SUT_localPort := 31111;
modulepar charstring tsp_SUT_remoteHost := "127.0.0.1";
modulepar integer tsp_SUT_remotePort := 5683;
modulepar charstring tsp_Leshan_host := "127.0.0.1";
modulepar integer tsp_Leshan_coapPort := 5683;
modulepar integer tsp_Leshan_coapsPort := 5684;
// SUT: LwM2M LGen
type component LWM2M_Applib_CT extends
EPTF_MBT_LGen_CT,
EPTF_COAP_LGen_CT, EPTF_COAP_LocalTransport_CT ,
EPTF_LwM2M_LGen_CT, EPTF_LwM2M_CoapApplibTransport_CT
{}
// Tester_CT
type component LWM2M_FSM_CT extends EPTF_MBT_Tester_CT, IFW_MAIN_CT {}
function f_LWM2M_Tests_begin(in boolean p_useDTLS := false) runs on LWM2M_FSM_CT
{
log(%definitionId, " started");
setverdict(pass);
f_EPTF_Base_init_CT("mtc");
log(%definitionId, " Creating SUT");
var LWM2M_Applib_CT vc_sut := LWM2M_Applib_CT.create;
connect(self:EPTF_MBT_TESTER_PCO, vc_sut:EPTF_MBT_PCO);
vc_sut.start(f_LWM2M_Applib_behavior(p_useDTLS));
EPTF_MBT_TESTER_PCO.receive(EPTF_MBT_CommandResponse:?) from vc_sut;
EPTF_MBT_TESTER_PCO.send(EPTF_MBT_ConfigRequest:
{
entityGroupName := "SUT_EntityType",
noEntities := 1,
behaviors := {c_EPTF_MBT_myBName, c_COAP_behaviorType, c_LwM2M_behaviorType},
fsmName := "FSM_MBT"
}
) to vc_sut;
EPTF_MBT_TESTER_PCO.receive(EPTF_MBT_ConfigResponse:?) from vc_sut;
log(%definitionId, " SUT ready");
log(%definitionId, " finished");
}
function f_LWM2M_Tests_end() runs on LWM2M_FSM_CT
{
log("### MAIN: END TESTCASE started");
f_EPTF_Base_stopAll(none, true);
log("### MAIN: END TESTCASE finished");
}
function f_handleVerdict(in boolean p_verdict)
{
if (p_verdict) { setverdict(pass) }
else { action("Setting verdict to fail"); setverdict(fail) }
}
function f_LWM2M_Applib_behavior(in boolean p_useDTLS := false) runs on LWM2M_Applib_CT
{
var charstring vl_selfName := "SUT_LGen";
// Init
f_EPTF_MBT_init(vl_selfName,0, "SUT_");
//////////////////////
// COAP applib init
f_EPTF_COAP_LGen_init(vl_selfName);
f_EPTF_COAP_LocalTransport_init();
vf_EPTF_COAP_Transport_send := refers(f_EPTF_COAP_LocalTransport_send);
vf_EPTF_COAP_Transport_receiveMessage := refers(f_EPTF_COAP_LGen_receiveMessage);
vf_EPTF_COAP_Transport_receiveEvent := refers(f_EPTF_COAP_LGen_receiveEvent);
vf_EPTF_COAP_Transport_apiRequest := refers(f_EPTF_COAP_LocalTransport_transportApiRequest);
vf_EPTF_COAP_Transport_apiResponse := refers(f_EPTF_COAP_LGen_transportApiResponse);
//////////////////////
// LWM2M applib init
f_EPTF_LwM2M_LGen_init(vl_selfName);
f_EPTF_LwM2M_CoapApplibTransport_init(vl_selfName);
vf_COAP_msgReceived := refers(f_EPTF_LwM2M_CoapApplibTransport_messageReceived);
vf_COAP_eventIndication := refers(f_EPTF_LwM2M_CoapApplibTransport_eventIndication);
vf_EPTF_LwM2M_Transport_send := refers(f_EPTF_LwM2M_CoapApplibTransport_send);
vf_EPTF_LwM2M_Transport_receiveMessage := refers(f_EPTF_LwM2M_LGen_receiveMessage);
vf_EPTF_LwM2M_Transport_receiveEvent := refers(f_EPTF_LwM2M_LGen_receiveEvent);
var integer vl_addrIdx;
var ProtoTuple vl_proto := { udp := {} };
if (p_useDTLS) {
vl_proto := { dtls := { udp := {} } };
}
f_EPTF_COAP_transportEndpointDB_add({ socket := {tsp_SUT_localHost, tsp_SUT_localPort}, proto := vl_proto }, vl_addrIdx);
f_EPTF_COAP_transportEndpointDB_add({ socket := {tsp_SUT_remoteHost, tsp_SUT_remotePort}, proto := vl_proto }, vl_addrIdx);
f_EPTF_COAP_transportEndpointDB_add({ socket := {tsp_Leshan_host, tsp_Leshan_coapPort}, proto := vl_proto }, vl_addrIdx);
f_EPTF_COAP_transportEndpointDB_add({ socket := {tsp_Leshan_host, tsp_Leshan_coapsPort}, proto := vl_proto }, vl_addrIdx);
var integer v_tempIdx;
v_tempIdx := f_EPTF_LwM2M_TemplateDB_add({id:= "t_LWM2M_register", msg:=valueof(t_LWM2M_register)});
v_tempIdx := f_EPTF_LwM2M_TemplateDB_add({id:= "t_LWM2M_update", msg:=valueof(t_LWM2M_update)});
v_tempIdx := f_EPTF_LwM2M_TemplateDB_add({id:= "t_LWM2M_deregister", msg:=valueof(t_LWM2M_deregister)});
v_tempIdx := f_EPTF_LwM2M_TemplateDB_add({id:= "t_LWM2M_register_psk", msg:=valueof(t_LWM2M_register_psk)});
f_EPTF_MBT_initLGenFsm(null, null);
EPTF_MBT_PCO.send(EPTF_MBT_CommandResponse:{ ready := {}}) to mtc;
// Loop
f_EPTF_Base_wait4Shutdown();
}
template EPTF_MBT_LGen_Definitions.FsmAddr t_addr(integer eIdx, template integer fIdx := 0) :=
{
entityGroupName := "SUT_EntityType",
eIdx := eIdx,
fIdx := fIdx
}
function f_delay(in float p_time)
{
timer t:= p_time;
t.start;
t.timeout;
}
template LWM2M_PDU t_LWM2M_register :=
{
Register :=
{
endpointClientName := "eantwuh_SimDev",
lifetime := 30,
version := omit,
bindingMode := U,
smsNumber := omit,
objectsAndObjectInstances := {}
}
}
template LWM2M_PDU t_LWM2M_register_psk :=
{
Register :=
{
endpointClientName := "client1",
lifetime := 30,
version := omit,
bindingMode := U,
smsNumber := omit,
objectsAndObjectInstances := {}
}
}
template LWM2M_PDU t_LWM2M_update :=
{
Update :=
{
location := {},
lifetime := 30,
bindingMode := U,
smsNumber := omit,
objectsAndObjectInstances := {}
}
}
template LWM2M_PDU t_LWM2M_deregister :=
{
Deregister :=
{
location := {}
}
}
const integer c_localAddr := 0;
const integer c_remoteAddr := 1;
const integer c_LeshanCoapAddr := 2;
const integer c_LeshanCoapsAddr := 3;
const integer c_t_Register := 0;
const integer c_t_Update := 1;
const integer c_t_Deregister := 2;
const integer c_t_Register_psk := 3;
const integer c_psk_identityIdx := 0;
template CoAP_ReqResp tr_COAP(Code p_code) :=
{
header :=
{
version := 1,
msg_type := ?,
code := p_code,
message_id := ?
},
token := ?,
options := *,
payload := *
}
template CoAP_ReqResp t_COAP_registered :=
{
header :=
{
version := 1,
msg_type := ACKNOWLEDGEMENT,
code := RESPONSE_CODE_Created,
message_id := 0
},
token := ''O,
options :=
{
{ location_path := "rd" },
{ location_path := "unique" }
},
payload := omit
}
template CoAP_ReqResp t_COAP_deregistered :=
{
header :=
{
version := 1,
msg_type := ACKNOWLEDGEMENT,
code := RESPONSE_CODE_Deleted,
message_id := 0
},
token := ''O,
options := {},
payload := omit
}
template CoAP_ReqResp t_COAP_read :=
{
header :=
{
version := 1,
msg_type := CONFIRMABLE,
code := METHOD_GET,
message_id := 0
},
token := ''O,
options :=
{
{ uri_path := "3303" },
{ uri_path := "0" },
{ uri_path := "5700" },
{ accept := 11542 }
},
payload := omit
}
template CoAP_ReqResp t_COAP_write :=
{
header :=
{
version := 1,
msg_type := CONFIRMABLE,
code := METHOD_PUT,
message_id := 0
},
token := ''O,
options :=
{
{ uri_path := "3303" },
{ uri_path := "0" },
{ uri_path := "5700" },
{ content_format := 1543 }
},
payload := char2oct(
"{\"e\":[ {\"n\":\"\", \"v\": 36.2 } ] }"
)
}
template CoAP_ReqResp t_COAP_execute :=
{
header :=
{
version := 1,
msg_type := CONFIRMABLE,
code := METHOD_POST,
message_id := 0
},
token := ''O,
options :=
{
{ uri_path := "3303" },
{ uri_path := "0" },
{ uri_path := "5605" },
{ accept := 11542 }
},
payload := omit
}
template CoAP_ReqResp t_COAP_observe :=
{
header :=
{
version := 1,
msg_type := CONFIRMABLE,
code := METHOD_GET,
message_id := 0
},
token := ''O,
options :=
{
{ observe := 0 },
{ uri_path := "3303" },
{ uri_path := "0" },
{ uri_path := "5700" },
{ accept := 11542 }
},
payload := omit
}
template CoAP_ReqResp t_RST_Empty :=
{
header :=
{
version := 1,
msg_type := RESET,
code := EMPTY_MESSAGE,
message_id := 0
},
token := ''O,
options := omit,
payload := omit
}
function f_initialization(in integer p_remoteAddr := c_remoteAddr) runs on LWM2M_FSM_CT
{
f_MBT_execute(c_COAP_stepName_init, valueof(t_addr(0, 0)), {}, false);
f_MBT_execute(c_COAP_stepName_setLocalAddress, valueof(t_addr(0, 0)), {c_localAddr}, false);
f_MBT_execute(c_COAP_stepName_setRemoteAddress_byIntIdx, valueof(t_addr(0, 0)), {p_remoteAddr}, false);
f_MBT_execute(c_COAP_stepName_reportCoapEventForEntity, valueof(t_addr(0, 0)), {c_COAP_stepParam_false}, false);
f_MBT_execute(c_LwM2M_stepName_createDevice, valueof(t_addr(0, 0)), {}, false);
f_MBT_execute(c_LwM2M_stepName_createObject, valueof(t_addr(0, 0)), {c_LwM2M_Temperature_obj_id}, false);
f_MBT_execute(c_LwM2M_stepName_createObjectInstance, valueof(t_addr(0, 0)), {c_LwM2M_Temperature_obj_id}, false);
}
function f_registration(integer peer) runs on LWM2M_FSM_CT
{
f_MBT_execute(c_LwM2M_stepName_loadTemplate_byIntIdx, valueof(t_addr(0, 0)), {c_t_Register}, false);
f_MBT_execute(c_LwM2M_stepName_send, valueof(t_addr(0, 0)), {}, false);
f_IFW_CoapPeer_receive(peer);
f_handleVerdict(f_IFW_CoapPeer_check(peer, tr_COAP(METHOD_POST)));
f_IFW_CoapPeer_setMessageToSend(peer,valueof(t_COAP_registered), USE_LAST_RECEIVED_MID, USE_LAST_RECEIVED_TOKEN);
f_IFW_CoapPeer_send(peer);
f_handleVerdict(f_MBT_waitFor(c_LwM2M_behaviorType, valueof(c_LwM2M_eventName(201)), valueof(t_addr(0, 0)), 3.0));
f_handleVerdict(f_MBT_waitFor(c_LwM2M_behaviorType, valueof(c_LwM2M_eventName_2xx), valueof(t_addr(0, 0)), 3.0));
}
function f_registration_againstLeshan(in integer p_t_register := c_t_Register) runs on LWM2M_FSM_CT
{
f_MBT_execute(c_LwM2M_stepName_loadTemplate_byIntIdx, valueof(t_addr(0, 0)), {p_t_register}, false);
f_MBT_execute(c_LwM2M_stepName_send, valueof(t_addr(0, 0)), {}, false);
f_handleVerdict(f_MBT_waitFor(c_LwM2M_behaviorType, valueof(c_LwM2M_eventName(201)), valueof(t_addr(0, 0)), 3.0));
f_handleVerdict(f_MBT_waitFor(c_LwM2M_behaviorType, valueof(c_LwM2M_eventName_2xx), valueof(t_addr(0, 0)), 3.0));
}
function f_deregistration(integer peer) runs on LWM2M_FSM_CT
{
f_MBT_execute(c_LwM2M_stepName_loadTemplate_byIntIdx, valueof(t_addr(0, 0)), {c_t_Deregister}, false);
f_MBT_execute(c_LwM2M_stepName_send, valueof(t_addr(0, 0)), {}, false);
f_IFW_CoapPeer_receive(peer);
f_handleVerdict(f_IFW_CoapPeer_check(peer, tr_COAP(METHOD_DELETE)));
f_IFW_CoapPeer_setMessageToSend(peer,valueof(t_COAP_deregistered), USE_LAST_RECEIVED_MID, USE_LAST_RECEIVED_TOKEN);
f_IFW_CoapPeer_send(peer);
f_handleVerdict(f_MBT_waitFor(c_LwM2M_behaviorType, valueof(c_LwM2M_eventName(202)), valueof(t_addr(0, 0)), 3.0));
f_handleVerdict(f_MBT_waitFor(c_LwM2M_behaviorType, valueof(c_LwM2M_eventName_2xx), valueof(t_addr(0, 0)), 3.0));
}
function f_deregistration_againstLeshan() runs on LWM2M_FSM_CT
{
f_MBT_execute(c_LwM2M_stepName_loadTemplate_byIntIdx, valueof(t_addr(0, 0)), {c_t_Deregister}, false);
f_MBT_execute(c_LwM2M_stepName_send, valueof(t_addr(0, 0)), {}, false);
f_handleVerdict(f_MBT_waitFor(c_LwM2M_behaviorType, valueof(c_LwM2M_eventName(202)), valueof(t_addr(0, 0)), 3.0));
f_handleVerdict(f_MBT_waitFor(c_LwM2M_behaviorType, valueof(c_LwM2M_eventName_2xx), valueof(t_addr(0, 0)), 3.0));
}
///////////////////////////////////////////////////////////
//
// Testcase: tc_initialization
//
// Purpose:
// Testcase for setting up a LWM2M device
//
// Action:
// (see EPTF_LwM2M_Tests.tc_initialization.jpg)
///////////////////////////////////////////////////////////
/*****************************************************************
* @startuml EPTF_LwM2M_Tests.tc_initialization.jpg
* FSM -> Applib: c_COAP_stepName_init()
* FSM -> Applib: c_COAP_stepName_setLocalAddress(c_localAddr)
* FSM -> Applib: c_COAP_stepName_setRemoteAddress_byIntIdx(c_remoteAddr)
* FSM -> Applib: c_COAP_stepName_reportCoapEventForEntity(c_COAP_stepParam_false)
* FSM -> Applib: c_LwM2M_stepName_createDevice
* FSM -> Applib: c_LwM2M_stepName_createObject(c_LwM2M_Temperature_obj_id)
* FSM -> Applib: c_LwM2M_stepName_createObjectInstance(c_LwM2M_Temperature_obj_id)
* FSM -> Applib: c_COAP_stepName_cleanUp()
* @enduml
******************************************************************/
testcase tc_initialization() runs on LWM2M_FSM_CT
{
f_LWM2M_Tests_begin();
var integer peer := f_IFW_addComponent(COAP_PEER, "tester");
f_IFW_CoapPeer_setRemote(peer, "sut");
f_IFW_initComponents();
f_initialization();
f_MBT_execute(c_COAP_stepName_cleanUp, valueof(t_addr(0, 0)), {}, false);
f_LWM2M_Tests_end();
}
///////////////////////////////////////////////////////////
//
// Testcase: tc_registration
//
// Purpose:
// Testcase for registering an LWM2M device
//
// Action:
// (see EPTF_LwM2M_Tests.tc_registration.jpg)
///////////////////////////////////////////////////////////
/*****************************************************************
* @startuml EPTF_LwM2M_Tests.tc_registration.jpg
* ref over Applib, Peer: tc_initialization
* FSM -> Applib: c_LwM2M_stepName_loadTemplate_byIntIdx(c_t_Register)
* FSM -> Applib: c_LwM2M_stepName_send()
* Peer <- Applib: CON-POST
* Peer -> Applib: ACK-registered with location /rd/unique
* FSM <- Applib: c_LwM2M_eventName(201)
* FSM <- Applib: c_LwM2M_eventName_2xx
* FSM -> Applib: c_COAP_stepName_cleanUp()
* @enduml
******************************************************************/
testcase tc_registration() runs on LWM2M_FSM_CT
{
f_LWM2M_Tests_begin();
var integer peer := f_IFW_addComponent(COAP_PEER, "tester");
f_IFW_CoapPeer_setRemote(peer, "sut");
f_IFW_initComponents();
f_initialization();
f_registration(peer);
f_MBT_execute(c_COAP_stepName_cleanUp, valueof(t_addr(0, 0)), {}, false);
f_LWM2M_Tests_end();
}
///////////////////////////////////////////////////////////
//
// Testcase: tc_registration_dtls
//
// Purpose:
// Testcase for registering an LWM2M device using DTLS
//
// Action:
// (see EPTF_LwM2M_Tests.tc_registration_dtls.jpg)
///////////////////////////////////////////////////////////
/*****************************************************************
* @startuml EPTF_LwM2M_Tests.tc_registration_dtls.jpg
* ref over Applib, Peer: tc_initialization
* FSM -> Applib: c_LwM2M_stepName_loadTemplate_byIntIdx(c_t_Register)
* FSM -> Applib: c_LwM2M_stepName_send()
* Peer <- Applib: DTLS establishment
* Peer -> Applib: DTLS established
* Peer <- Applib: CON-POST
* Peer -> Applib: ACK-registered with location /rd/unique
* FSM <- Applib: c_LwM2M_eventName(201)
* FSM <- Applib: c_LwM2M_eventName_2xx
* FSM -> Applib: c_COAP_stepName_cleanUp()
* @enduml
******************************************************************/
testcase tc_registration_dtls() runs on LWM2M_FSM_CT
{
f_LWM2M_Tests_begin(p_useDTLS := true);
var integer peer := f_IFW_addComponent(COAP_PEER, "tester");
f_IFW_CoapPeer_setRemote(peer, "sut");
var CoapContext v_ctx;
f_IFW_CoapPeer_getContext(peer, v_ctx);
v_ctx.listeningProtocol := { dtls := { udp := {} } };
f_IFW_CoapPeer_setContext(peer, v_ctx);
f_IFW_initComponents();
f_initialization();
f_registration(peer);
f_MBT_execute(c_COAP_stepName_cleanUp, valueof(t_addr(0, 0)), {}, false);
f_LWM2M_Tests_end();
}
///////////////////////////////////////////////////////////
//
// Testcase: tc_deregistration
//
// Purpose:
// Testcase for registering and deregistering an LWM2M device
//
// Action:
// (see EPTF_LwM2M_Tests.tc_deregistration.jpg)
///////////////////////////////////////////////////////////
/*****************************************************************
* @startuml EPTF_LwM2M_Tests.tc_deregistration.jpg
* ref over Applib, Peer: tc_initialization
* ref over Applib, Peer: tc_registration
* FSM -> Applib: c_LwM2M_stepName_loadTemplate_byIntIdx(c_t_Deregister)
* FSM -> Applib: c_LwM2M_stepName_send()
* Peer <- Applib: CON-DELETE
* Peer -> Applib: ACK-deregistered
* FSM <- Applib: c_LwM2M_eventName(202)
* FSM <- Applib: c_LwM2M_eventName_2xx
* FSM -> Applib: c_COAP_stepName_cleanUp()
* @enduml
******************************************************************/
testcase tc_deregistration() runs on LWM2M_FSM_CT
{
f_LWM2M_Tests_begin();
var integer peer := f_IFW_addComponent(COAP_PEER, "tester");
f_IFW_CoapPeer_setRemote(peer, "sut");
f_IFW_initComponents();
f_initialization();
f_registration(peer);
f_deregistration(peer);
f_MBT_execute(c_COAP_stepName_cleanUp, valueof(t_addr(0, 0)), {}, false);
f_LWM2M_Tests_end();
}
///////////////////////////////////////////////////////////
//
// Testcase: tc_read_resource
//
// Purpose:
// Testcase for reading a resource value
//
// Action:
// (see EPTF_LwM2M_Tests.tc_read_resource.jpg)
///////////////////////////////////////////////////////////
/*****************************************************************
* @startuml EPTF_LwM2M_Tests.tc_read_resource.jpg
* ref over Applib, Peer: tc_initialization
* ref over Applib, Peer: tc_registration
* Peer -> Applib: COAP GET 3303/0/5700
* FSM <- Applib: c_LwM2M_eventName_Read
* FSM -> Applib: c_COAP_stepName_handleRequest
* FSM -> Applib: c_LwM2M_stepName_handleReadRequest
* Peer <- Applib: COAP 205 content
* FSM -> Applib: c_COAP_stepName_cleanUp()
* @enduml
******************************************************************/
testcase tc_read_resource() runs on LWM2M_FSM_CT
{
f_LWM2M_Tests_begin();
var integer peer := f_IFW_addComponent(COAP_PEER, "tester");
f_IFW_CoapPeer_setRemote(peer, "sut");
f_IFW_initComponents();
f_initialization();
f_registration(peer);
f_IFW_CoapPeer_setMessageToSend(peer, valueof(t_COAP_read), GENERATE_NEW_MID, GENERATE_NEW_TOKEN);
f_IFW_CoapPeer_send(peer);
f_handleVerdict(f_MBT_waitFor(c_LwM2M_behaviorType, c_LwM2M_eventName_Read, t_addr(0, ?), 3.0));
f_MBT_execute(c_COAP_stepName_handleRequest, valueof(t_addr(0, 0)), {}, false);
f_MBT_execute(c_LwM2M_stepName_handleReadRequest, valueof(t_addr(0, 0)), {}, false);
f_IFW_CoapPeer_receive(peer);
f_handleVerdict(f_IFW_CoapPeer_check(peer, tr_COAP(RESPONSE_CODE_Content)));
f_MBT_execute(c_COAP_stepName_cleanUp, valueof(t_addr(0, 0)), {}, false);
f_LWM2M_Tests_end();
}
///////////////////////////////////////////////////////////
//
// Testcase: tc_write_resource
//
// Purpose:
// Testcase for writing a resource value
//
// Action:
// (see EPTF_LwM2M_Tests.tc_write_resource.jpg)
///////////////////////////////////////////////////////////
/*****************************************************************
* @startuml EPTF_LwM2M_Tests.tc_write_resource.jpg
* ref over Applib, Peer: tc_initialization
* ref over Applib, Peer: tc_registration
* Peer -> Applib: COAP PUT 3303/0/5700 200 (JSON)
* FSM <- Applib: c_LwM2M_eventName_Write
* FSM -> Applib: c_COAP_stepName_handleRequest
* FSM -> Applib: c_LwM2M_stepName_handleWriteRequest
* Peer <- Applib: COAP Response 204 changed
* FSM -> Applib: c_COAP_stepName_cleanUp()
* @enduml
******************************************************************/
testcase tc_write_resource() runs on LWM2M_FSM_CT
{
f_LWM2M_Tests_begin();
var integer peer := f_IFW_addComponent(COAP_PEER, "tester");
f_IFW_CoapPeer_setRemote(peer, "sut");
f_IFW_initComponents();
f_initialization();
f_registration(peer);
f_IFW_CoapPeer_setMessageToSend(peer, valueof(t_COAP_write), GENERATE_NEW_MID, GENERATE_NEW_TOKEN);
f_IFW_CoapPeer_send(peer);
f_handleVerdict(f_MBT_waitFor(c_LwM2M_behaviorType, c_LwM2M_eventName_Write, t_addr(0, ?), 3.0));
f_MBT_execute(c_COAP_stepName_handleRequest, valueof(t_addr(0, 0)), {}, false);
f_MBT_execute(c_LwM2M_stepName_handleWriteRequest, valueof(t_addr(0, 0)), {}, false);
f_IFW_CoapPeer_receive(peer);
f_handleVerdict(f_IFW_CoapPeer_check(peer, tr_COAP(RESPONSE_CODE_Changed)));
f_MBT_execute(c_COAP_stepName_cleanUp, valueof(t_addr(0, 0)), {}, false);
f_LWM2M_Tests_end();
}
///////////////////////////////////////////////////////////
//
// Testcase: tc_execute_resource
//
// Purpose:
// Testcase for writing a resource value
//
// Action:
// (see EPTF_LwM2M_Tests.tc_execute_resource.jpg)
///////////////////////////////////////////////////////////
/*****************************************************************
* @startuml EPTF_LwM2M_Tests.tc_execute_resource.jpg
* ref over Applib, Peer: tc_initialization
* ref over Applib, Peer: tc_registration
* Peer -> Applib: COAP POST 3303/0/5605 (Reset min max values executable resource)
* FSM <- Applib: c_LwM2M_eventName_Execute
* FSM -> Applib: c_COAP_stepName_handleRequest
* FSM -> Applib: c_LwM2M_stepName_handleExecuteRequest
* Peer <- Applib: COAP Response 204 changed
* FSM -> Applib: c_COAP_stepName_cleanUp()
* @enduml
******************************************************************/
testcase tc_execute_resource() runs on LWM2M_FSM_CT
{
f_LWM2M_Tests_begin();
var integer peer := f_IFW_addComponent(COAP_PEER, "tester");
f_IFW_CoapPeer_setRemote(peer, "sut");
f_IFW_initComponents();
f_initialization();
f_registration(peer);
f_IFW_CoapPeer_setMessageToSend(peer, valueof(t_COAP_execute), GENERATE_NEW_MID, GENERATE_NEW_TOKEN);
f_IFW_CoapPeer_send(peer);
f_handleVerdict(f_MBT_waitFor(c_LwM2M_behaviorType, c_LwM2M_eventName_Execute, t_addr(0, ?), 3.0));
f_MBT_execute(c_COAP_stepName_handleRequest, valueof(t_addr(0, 0)), {}, false);
f_MBT_execute(c_LwM2M_stepName_handleExecuteRequest, valueof(t_addr(0, 0)), {}, false);
f_IFW_CoapPeer_receive(peer);
f_handleVerdict(f_IFW_CoapPeer_check(peer, tr_COAP(RESPONSE_CODE_Changed)));
f_MBT_execute(c_COAP_stepName_cleanUp, valueof(t_addr(0, 0)), {}, false);
f_LWM2M_Tests_end();
}
///////////////////////////////////////////////////////////
//
// Testcase: tc_observe_subscription
//
// Purpose:
// Testcase for subscribing to a resource value
//
// Action:
// (see EPTF_LwM2M_Tests.tc_observe_subscription.jpg)
///////////////////////////////////////////////////////////
/*****************************************************************
* @startuml EPTF_LwM2M_Tests.tc_observe_subscription.jpg
* ref over Applib, Peer: tc_initialization
* ref over Applib, Peer: tc_registration
* Peer -> Applib: COAP GET 3303/0/5700 Observe:0
* FSM <- Applib: c_LwM2M_eventName_Read
* FSM -> Applib: c_COAP_stepName_handleRequest
* FSM -> Applib: c_LwM2M_stepName_handleReadRequest
* Peer <- Applib: COAP Content
* FSM -> Applib: c_COAP_stepName_cleanUp()
* @enduml
******************************************************************/
testcase tc_observe_subscription() runs on LWM2M_FSM_CT
{
f_LWM2M_Tests_begin();
var integer peer := f_IFW_addComponent(COAP_PEER, "tester");
f_IFW_CoapPeer_setRemote(peer, "sut");
f_IFW_initComponents();
f_initialization();
f_registration(peer);
f_IFW_CoapPeer_setMessageToSend(peer, valueof(t_COAP_observe), GENERATE_NEW_MID, GENERATE_NEW_TOKEN);
f_IFW_CoapPeer_send(peer);
f_handleVerdict(f_MBT_waitFor(c_LwM2M_behaviorType, c_LwM2M_eventName_Read, t_addr(0, ?), 3.0));
f_MBT_execute(c_COAP_stepName_handleRequest, valueof(t_addr(0, 0)), {}, false);
f_MBT_execute(c_LwM2M_stepName_handleReadRequest, valueof(t_addr(0, 0)), {}, false);
f_IFW_CoapPeer_receive(peer);
f_handleVerdict(f_IFW_CoapPeer_check(peer, tr_COAP(RESPONSE_CODE_Content)));
f_MBT_execute(c_COAP_stepName_cleanUp, valueof(t_addr(0, 0)), {}, false);
f_LWM2M_Tests_end();
}
///////////////////////////////////////////////////////////
//
// Testcase: tc_observe_notification
//
// Purpose:
// Testcase for sending notification for an observed resource
//
// Action:
// (see EPTF_LwM2M_Tests.tc_observe_notification.jpg)
///////////////////////////////////////////////////////////
/*****************************************************************
* @startuml EPTF_LwM2M_Tests.tc_observe_notification.jpg
* ref over Applib, Peer: tc_initialization
* ref over Applib, Peer: tc_registration
* Peer -> Applib: COAP GET 3303/0/5700 Observe:0
* FSM <- Applib: c_LwM2M_eventName_Read
* FSM -> Applib: c_COAP_stepName_handleRequest
* FSM -> Applib: c_LwM2M_stepName_handleReadRequest
* Peer <- Applib: COAP Content with Observe
* FSM -> Applib: c_LwM2M_stepName_sendNotificationForObservedResources
* Peer <- Applib: COAP Content with Observe
* FSM -> Applib: c_COAP_stepName_cleanUp()
* @enduml
******************************************************************/
testcase tc_observe_notification() runs on LWM2M_FSM_CT
{
f_LWM2M_Tests_begin();
var integer peer := f_IFW_addComponent(COAP_PEER, "tester");
f_IFW_CoapPeer_setRemote(peer, "sut");
f_IFW_initComponents();
f_initialization();
f_registration(peer);
f_IFW_CoapPeer_setMessageToSend(peer, valueof(t_COAP_observe), GENERATE_NEW_MID, GENERATE_NEW_TOKEN);
f_IFW_CoapPeer_send(peer);
f_handleVerdict(f_MBT_waitFor(c_LwM2M_behaviorType, c_LwM2M_eventName_Read, t_addr(0, ?), 3.0));
f_MBT_execute(c_COAP_stepName_handleRequest, valueof(t_addr(0, 0)), {}, false);
f_MBT_execute(c_LwM2M_stepName_handleReadRequest, valueof(t_addr(0, 0)), {}, false);
f_IFW_CoapPeer_receive(peer);
f_handleVerdict(f_IFW_CoapPeer_check(peer, tr_COAP(RESPONSE_CODE_Content)));
f_MBT_execute(c_LwM2M_stepName_sendNotificationForObservedResources, valueof(t_addr(0, 0)), {}, false);
f_IFW_CoapPeer_receive(peer);
f_handleVerdict(f_IFW_CoapPeer_check(peer, tr_COAP(RESPONSE_CODE_Content)));
f_MBT_execute(c_COAP_stepName_cleanUp, valueof(t_addr(0, 0)), {}, false);
f_LWM2M_Tests_end();
}
///////////////////////////////////////////////////////////
//
// Testcase: tc_observe_unsubscribe
//
// Purpose:
// Testcase for unsubscribing from a resource value
//
// Action:
// (see EPTF_LwM2M_Tests.tc_observe_unsubscribe.jpg)
///////////////////////////////////////////////////////////
/*****************************************************************
* @startuml EPTF_LwM2M_Tests.tc_observe_unsubscribe.jpg
* ref over Applib, Peer: tc_initialization
* ref over Applib, Peer: tc_registration
* Peer -> Applib: COAP GET 3303/0/5700 Observe:0
* FSM <- Applib: c_LwM2M_eventName_Read
* FSM -> Applib: c_COAP_stepName_handleRequest
* FSM -> Applib: c_LwM2M_stepName_handleReadRequest
* Peer <- Applib: COAP Content with Observe
* FSM -> Applib: c_LwM2M_stepName_sendNotificationForObservedResources
* Peer <- Applib: COAP Content with Observe
* FSM -> Applib: c_COAP_stepName_cleanUp()
* @enduml
******************************************************************/
testcase tc_observe_unsubscribe() runs on LWM2M_FSM_CT
{
f_LWM2M_Tests_begin();
var integer peer := f_IFW_addComponent(COAP_PEER, "tester");
f_IFW_CoapPeer_setRemote(peer, "sut");
f_IFW_initComponents();
f_initialization();
f_registration(peer);
f_IFW_CoapPeer_setMessageToSend(peer, valueof(t_COAP_observe), GENERATE_NEW_MID, GENERATE_NEW_TOKEN);
f_IFW_CoapPeer_send(peer);
f_handleVerdict(f_MBT_waitFor(c_LwM2M_behaviorType, c_LwM2M_eventName_Read, t_addr(0, ?), 3.0));
f_MBT_execute(c_COAP_stepName_handleRequest, valueof(t_addr(0, 0)), {}, false);
f_MBT_execute(c_LwM2M_stepName_handleReadRequest, valueof(t_addr(0, 0)), {}, false);
f_IFW_CoapPeer_receive(peer);
f_handleVerdict(f_IFW_CoapPeer_check(peer, tr_COAP(RESPONSE_CODE_Content)));
f_MBT_execute(c_LwM2M_stepName_sendNotificationForObservedResources, valueof(t_addr(0, 0)), {}, false);
f_IFW_CoapPeer_receive(peer);
f_handleVerdict(f_IFW_CoapPeer_check(peer, tr_COAP(RESPONSE_CODE_Content)));
f_IFW_CoapPeer_setMessageToSend(peer, valueof(t_RST_Empty), USE_LAST_RECEIVED_MID, USE_GIVEN_TOKEN);
f_IFW_CoapPeer_send(peer);
f_handleVerdict(f_MBT_waitFor(c_LwM2M_behaviorType, c_LwM2M_eventName_resourceNotObservedIndication, t_addr(0, ?), 3.0));
f_MBT_execute(c_COAP_stepName_cleanUp, valueof(t_addr(0, 0)), {}, false);
f_LWM2M_Tests_end();
}
///////////////////////////////////////////////////////////
//
// Testcase: tc_regDereg_againstLeshan
//
// Purpose:
// Testcase for registering and then deregistering an LWM2M device using an external Leshan LwM2M server
//
// Action:
// (see EPTF_LwM2M_Tests.tc_regDereg_againstLeshan.jpg)
///////////////////////////////////////////////////////////
/*****************************************************************
* @startuml EPTF_LwM2M_Tests.tc_regDereg_againstLeshan.jpg
* ref over Applib, Peer: tc_initialization(c_LeshanCoapAddr)
* FSM -> Applib: c_LwM2M_stepName_loadTemplate_byIntIdx(c_t_Register)
* FSM -> Applib: c_LwM2M_stepName_send()
* Leshan <- Applib: LWM2M Register
* Leshan -> Applib: 201 Created
* FSM <- Applib: c_LwM2M_eventName(201)
* FSM <- Applib: c_LwM2M_eventName_2xx
* FSM -> Applib: c_LwM2M_stepName_loadTemplate_byIntIdx(c_t_Deregister)
* FSM -> Applib: c_LwM2M_stepName_send()
* Leshan <- Applib: LWM2M Deregister
* Leshan -> Applib: 204 Deleted
* FSM <- Applib: c_LwM2M_eventName(202)
* FSM <- Applib: c_LwM2M_eventName_2xx
* FSM -> Applib: c_COAP_stepName_cleanUp()
* @enduml
******************************************************************/
testcase tc_regDereg_againstLeshan() runs on LWM2M_FSM_CT
{
f_LWM2M_Tests_begin();
f_initialization(c_LeshanCoapAddr);
f_registration_againstLeshan();
f_deregistration_againstLeshan();
f_MBT_execute(c_COAP_stepName_cleanUp, valueof(t_addr(0, 0)), {}, false);
f_LWM2M_Tests_end();
}
///////////////////////////////////////////////////////////
//
// Testcase: tc_regDereg_againstLeshan_dtls
//
// Purpose:
// Testcase for registering and then deregistering an LWM2M device using an external Leshan LwM2M server (DTLS transport)
//
// Action:
// (see EPTF_LwM2M_Tests.tc_regDereg_againstLeshan.jpg)
///////////////////////////////////////////////////////////
/*****************************************************************
* @startuml EPTF_LwM2M_Tests.tc_regDereg_againstLeshan.jpg
* ref over Applib, Peer: tc_initialization(c_LeshanCoapsAddr)
* Leshan <- Applib: DTLS hello
* Leshan -> Applib: DTLS established
* FSM -> Applib: c_LwM2M_stepName_loadTemplate_byIntIdx(c_t_Register)
* FSM -> Applib: c_LwM2M_stepName_send()
* Leshan <- Applib: LWM2M Register
* Leshan -> Applib: 201 Created
* FSM <- Applib: c_LwM2M_eventName(201)
* FSM <- Applib: c_LwM2M_eventName_2xx
* FSM -> Applib: c_LwM2M_stepName_loadTemplate_byIntIdx(c_t_Deregister)
* FSM -> Applib: c_LwM2M_stepName_send()
* Leshan <- Applib: LWM2M Deregister
* Leshan -> Applib: 204 Deleted
* FSM <- Applib: c_LwM2M_eventName(202)
* FSM <- Applib: c_LwM2M_eventName_2xx
* FSM -> Applib: c_COAP_stepName_cleanUp()
* @enduml
******************************************************************/
testcase tc_regDereg_againstLeshan_dtls() runs on LWM2M_FSM_CT
{
f_LWM2M_Tests_begin(p_useDTLS := true);
f_initialization(c_LeshanCoapsAddr);
f_MBT_execute(c_COAP_stepName_startDTLS, valueof(t_addr(0, 0)), {}, false);
f_handleVerdict(f_MBT_waitFor(c_COAP_behaviorType, c_COAP_eventName_transportSucc, valueof(t_addr(0, 0)), 3.0));
f_registration_againstLeshan();
f_deregistration_againstLeshan();
f_MBT_execute(c_COAP_stepName_cleanUp, valueof(t_addr(0, 0)), {}, false);
f_LWM2M_Tests_end();
}
///////////////////////////////////////////////////////////
//
// Testcase: tc_regDereg_againstLeshan_psk
//
// Purpose:
// Testcase for registering and then deregistering an LWM2M device using an external Leshan LwM2M server (DTLS PSK transport)
//
// Configuration:
// - Leshan must be configured with identity and key according to <tsp_EPTF_COAP_LGen_psks>[0]
// - Default identity: "client01"
// - Default key: "01020304"
//
// Action:
// (see EPTF_LwM2M_Tests.tc_regDereg_againstLeshan_psk.jpg)
///////////////////////////////////////////////////////////
/*****************************************************************
* @startuml EPTF_LwM2M_Tests.tc_regDereg_againstLeshan_psk.jpg
* ref over Applib, Peer: tc_initialization(c_LeshanCoapsAddr)
* FSM -> Applib: c_COAP_stepName_startDTLS_byIntIdx(c_psk_identityIdx)
* Leshan <- Applib: DTLS hello (PSK)
* Leshan -> Applib: DTLS established (PSDK)
* FSM -> Applib: c_LwM2M_stepName_loadTemplate_byIntIdx(c_t_Register_psk)
* FSM -> Applib: c_LwM2M_stepName_send()
* Leshan <- Applib: LWM2M Register
* Leshan -> Applib: 201 Created
* FSM <- Applib: c_LwM2M_eventName(201)
* FSM <- Applib: c_LwM2M_eventName_2xx
* FSM -> Applib: c_LwM2M_stepName_loadTemplate_byIntIdx(c_t_Deregister)
* FSM -> Applib: c_LwM2M_stepName_send()
* Leshan <- Applib: LWM2M Deregister
* Leshan -> Applib: 204 Deleted
* FSM <- Applib: c_LwM2M_eventName(202)
* FSM <- Applib: c_LwM2M_eventName_2xx
* FSM -> Applib: c_COAP_stepName_cleanUp()
* @enduml
******************************************************************/
testcase tc_regDereg_againstLeshan_psk() runs on LWM2M_FSM_CT
{
f_LWM2M_Tests_begin(p_useDTLS := true);
f_initialization(c_LeshanCoapsAddr);
f_MBT_execute(c_COAP_stepName_startDTLS_byIntIdx, valueof(t_addr(0, 0)), {c_psk_identityIdx}, false);
f_handleVerdict(f_MBT_waitFor(c_COAP_behaviorType, c_COAP_eventName_transportSucc, valueof(t_addr(0, 0)), 3.0));
f_registration_againstLeshan(c_t_Register_psk);
f_deregistration_againstLeshan();
f_MBT_execute(c_COAP_stepName_cleanUp, valueof(t_addr(0, 0)), {}, false);
f_LWM2M_Tests_end();
}
control
{
execute(tc_initialization());
execute(tc_registration());
execute(tc_deregistration());
execute(tc_read_resource());
execute(tc_write_resource());
execute(tc_execute_resource());
execute(tc_observe_subscription());
execute(tc_observe_notification());
execute(tc_observe_unsubscribe());
}
}