| /////////////////////////////////////////////////////////////////////////////// |
| // |
| // Copyright (c) 2000-2020 Ericsson Telecom AB |
| // |
| // All rights reserved. This program and the accompanying materials |
| // are made available under the terms of the Eclipse Public License v2.0 |
| // which accompanies this distribution, and is available at |
| // https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html |
| /////////////////////////////////////////////////////////////////////////////// |
| // File: Lwm2mTestSuite.ttcn |
| // Description: |
| // Rev: <RnXnn> |
| // Prodnr: CNL 113 910 |
| // Updated: 2020-02-06 |
| // Contact: http://ttcn.ericsson.se |
| /////////////////////////////////////////////////////////////////////////////// |
| module Lwm2mTestSuite |
| { |
| 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 CoAP_Types all; |
| import from LightweightM2M_Types all; |
| import from LightweightM2M_CoAP_Binding all; |
| import from IFW_Common all; |
| |
| testcase tc_client_LightweightM2M_10_int_101_102_103_regdereg() runs on IFW_MAIN_CT |
| { |
| setverdict(pass); |
| |
| var integer client := f_IFW_addComponent(COAP_PEER, "client"); |
| |
| f_IFW_CoapPeer_setRemote(client, "server"); |
| |
| f_IFW_initComponents(); |
| |
| f_IFW_CoapPeer_setMessageToSend(client, valueof(t_client_LightweightM2M_10_int_101_register)); |
| f_IFW_CoapPeer_send(client); |
| |
| f_IFW_CoapPeer_receive(client); |
| if (not f_IFW_CoapPeer_check(client, t_client_LightweightM2M_10_int_101_registered)) |
| { |
| setverdict(fail); stop; |
| } |
| f_IFW_CoapPeer_saveLocationPath(client); |
| |
| f_IFW_wait(3.0); |
| |
| f_IFW_CoapPeer_setMessageToSend(client, valueof(t_client_LightweightM2M_10_int_102_update)); |
| f_IFW_CoapPeer_addUriPath(client); |
| f_IFW_CoapPeer_send(client); |
| |
| f_IFW_CoapPeer_receive(client); |
| if (not f_IFW_CoapPeer_check(client, t_client_LightweightM2M_10_int_102_updated)) |
| { |
| setverdict(fail); stop; |
| } |
| |
| f_IFW_wait(3.0); |
| |
| f_IFW_CoapPeer_setMessageToSend(client, valueof(t_client_LightweightM2M_10_int_103_deregister)); |
| f_IFW_CoapPeer_addUriPath(client); |
| f_IFW_CoapPeer_send(client); |
| |
| f_IFW_CoapPeer_receive(client); |
| if (not f_IFW_CoapPeer_check(client, t_client_LightweightM2M_10_int_103_deregistered)) |
| { |
| setverdict(fail); stop; |
| } |
| } |
| |
| template CoAP_ReqResp t_client_LightweightM2M_10_int_101_register := |
| { |
| header := |
| { |
| version := 1, |
| msg_type := CONFIRMABLE, |
| code := METHOD_POST, |
| message_id := 0 |
| }, |
| token := ''O, |
| options := |
| { |
| { |
| uri_path := "rd" |
| }, |
| { |
| content_format := 40 |
| }, |
| { |
| uri_query := "ep=client1" |
| }, |
| { |
| uri_query := "lt=60" |
| }, |
| { |
| uri_query := "b=U" |
| } |
| }, |
| payload := char2oct("</0/0>,</1/0>,</3/0>") |
| } |
| |
| template CoAP_ReqResp t_client_LightweightM2M_10_int_101_registered := |
| { |
| header := |
| { |
| version := 1, |
| msg_type := ACKNOWLEDGEMENT, |
| code := RESPONSE_CODE_Created, |
| message_id := ? |
| }, |
| token := ''O, |
| options := {}, |
| payload := omit |
| } |
| |
| template CoAP_ReqResp t_client_LightweightM2M_10_int_102_update := |
| { |
| header := |
| { |
| version := 1, |
| msg_type := CONFIRMABLE, |
| code := METHOD_PUT, |
| message_id := 0 |
| }, |
| token := ''O, |
| options := |
| { |
| { |
| uri_query := "lt=60" |
| }, |
| { |
| uri_query := "b=U" |
| } |
| }, |
| payload := omit |
| } |
| |
| template CoAP_ReqResp t_client_LightweightM2M_10_int_102_updated := |
| { |
| header := |
| { |
| version := 1, |
| msg_type := ACKNOWLEDGEMENT, |
| code := RESPONSE_CODE_Changed, |
| message_id := ? |
| }, |
| token := ''O, |
| options := {}, |
| payload := omit |
| } |
| |
| template CoAP_ReqResp t_client_LightweightM2M_10_int_103_deregister := |
| { |
| header := |
| { |
| version := 1, |
| msg_type := CONFIRMABLE, |
| code := METHOD_DELETE, |
| message_id := 0 |
| }, |
| token := ''O, |
| options := |
| { |
| }, |
| payload := omit |
| } |
| |
| template CoAP_ReqResp t_client_LightweightM2M_10_int_103_deregistered := |
| { |
| header := |
| { |
| version := 1, |
| msg_type := ACKNOWLEDGEMENT, |
| code := RESPONSE_CODE_Deleted, |
| message_id := ? |
| }, |
| token := ''O, |
| options := {}, |
| payload := omit |
| } |
| |
| testcase tc_client_LightweightM2M_10_int_101_102_103_regdereg_dtls() runs on IFW_MAIN_CT |
| { |
| setverdict(pass); |
| |
| var integer client := f_IFW_addComponent(COAP_PEER, "client"); |
| |
| f_IFW_CoapPeer_setRemote(client, "server"); |
| |
| // Setting DTLS parameters |
| var CoapContext v_ctx; |
| f_IFW_CoapPeer_getContext(client, v_ctx); |
| v_ctx.connectProtocol := { dtls := { udp := {} } }; |
| v_ctx.connectOptions[sizeof(v_ctx.connectOptions)] := { |
| psk_options := { |
| psk_identity := "client1", |
| psk_identity_hint := omit, |
| psk_key := "01020304" |
| } |
| } |
| f_IFW_CoapPeer_setContext(client, v_ctx); |
| |
| f_IFW_initComponents(); |
| |
| f_IFW_CoapPeer_setMessageToSend(client, valueof(t_client_LightweightM2M_10_int_101_register)); |
| f_IFW_CoapPeer_send(client); |
| |
| f_IFW_CoapPeer_receive(client); |
| if (not f_IFW_CoapPeer_check(client, t_client_LightweightM2M_10_int_101_registered)) |
| { |
| setverdict(fail); stop; |
| } |
| f_IFW_CoapPeer_saveLocationPath(client); |
| |
| f_IFW_wait(3.0); |
| |
| f_IFW_CoapPeer_setMessageToSend(client, valueof(t_client_LightweightM2M_10_int_102_update)); |
| f_IFW_CoapPeer_addUriPath(client); |
| f_IFW_CoapPeer_send(client); |
| |
| f_IFW_CoapPeer_receive(client); |
| if (not f_IFW_CoapPeer_check(client, t_client_LightweightM2M_10_int_102_updated)) |
| { |
| setverdict(fail); stop; |
| } |
| |
| f_IFW_wait(3.0); |
| |
| f_IFW_CoapPeer_setMessageToSend(client, valueof(t_client_LightweightM2M_10_int_103_deregister)); |
| f_IFW_CoapPeer_addUriPath(client); |
| f_IFW_CoapPeer_send(client); |
| |
| f_IFW_CoapPeer_receive(client); |
| if (not f_IFW_CoapPeer_check(client, t_client_LightweightM2M_10_int_103_deregistered)) |
| { |
| setverdict(fail); stop; |
| } |
| } |
| |
| testcase tc_client_LightweightM2M_10_int_101_102_103_regdereg_lwm2mPDU() runs on IFW_MAIN_CT |
| { |
| setverdict(pass); |
| |
| var CoAP_ReqResp v_coap_encoded; |
| |
| var integer client := f_IFW_addComponent(COAP_PEER, "client"); |
| |
| f_IFW_CoapPeer_setRemote(client, "server"); |
| |
| f_IFW_initComponents(); |
| |
| f_enc_LWM2M_to_COAP(valueof(t_client_LightweightM2M_10_int_101_register_lwm2mPDU), v_coap_encoded); |
| f_IFW_CoapPeer_setMessageToSend(client, v_coap_encoded); |
| f_IFW_CoapPeer_send(client); |
| |
| f_IFW_CoapPeer_receive(client); |
| if (not f_IFW_CoapPeer_check(client, t_client_LightweightM2M_10_int_101_registered)) |
| { |
| setverdict(fail); stop; |
| } |
| f_IFW_CoapPeer_saveLocationPath(client); |
| |
| f_enc_LWM2M_to_COAP(valueof(t_client_LightweightM2M_10_int_102_update_lwm2mPDU), v_coap_encoded); |
| f_IFW_CoapPeer_setMessageToSend(client, v_coap_encoded); |
| f_IFW_CoapPeer_addUriPath(client); |
| f_IFW_CoapPeer_send(client); |
| |
| f_IFW_CoapPeer_receive(client); |
| if (not f_IFW_CoapPeer_check(client, t_client_LightweightM2M_10_int_102_updated)) |
| { |
| setverdict(fail); stop; |
| } |
| |
| f_enc_LWM2M_to_COAP(valueof(t_client_LightweightM2M_10_int_103_deregister_lwm2mPDU), v_coap_encoded); |
| f_IFW_CoapPeer_setMessageToSend(client, v_coap_encoded); |
| f_IFW_CoapPeer_addUriPath(client); |
| f_IFW_CoapPeer_send(client); |
| |
| f_IFW_CoapPeer_receive(client); |
| if (not f_IFW_CoapPeer_check(client, t_client_LightweightM2M_10_int_103_deregistered)) |
| { |
| setverdict(fail); stop; |
| } |
| } |
| |
| template LWM2M_PDU t_client_LightweightM2M_10_int_101_register_lwm2mPDU := |
| { |
| Register := |
| { |
| endpointClientName := "client1", |
| lifetime := 60, |
| version := omit, |
| bindingMode := U, |
| smsNumber := omit, |
| objectsAndObjectInstances := |
| { |
| {0, 0, omit}, |
| {1, 0, omit}, |
| {3, 0, omit} |
| } |
| } |
| } |
| |
| template LWM2M_PDU t_client_LightweightM2M_10_int_102_update_lwm2mPDU := |
| { |
| Update := |
| { |
| location := {}, |
| lifetime := 60, |
| bindingMode := U, |
| smsNumber := omit, |
| objectsAndObjectInstances := {} |
| } |
| } |
| |
| template LWM2M_PDU t_client_LightweightM2M_10_int_103_deregister_lwm2mPDU := |
| { |
| Deregister := |
| { |
| location := {} |
| } |
| } |
| |
| control |
| { |
| execute(tc_client_LightweightM2M_10_int_101_102_103_regdereg()); |
| execute(tc_client_LightweightM2M_10_int_101_102_103_regdereg_lwm2mPDU()); |
| } |
| } |