Commit eb94ac14 authored by Michael Proestler's avatar Michael Proestler
Browse files

Add TC_ESRP_HTTP_DEQUEUE_REGISTRATION_TARGET_REGISTRATION_BV_01

parent 79b85951
Loading
Loading
Loading
Loading
+166 −0
Original line number Diff line number Diff line
module AtsESRP_Functions {
    import from LibItsHttp_Templates all;
    import from LibItsHttp_TypesAndValues all;
    import from LibItsHttp_TestSystem all;
    import from LibItsHttp_XmlMessageBodyTypes all;
    import from LibItsHttp_MessageBodyTypes all;
    import from LibItsHttp_Functions all;

    import from LibSip_SIPTypesAndValues all;
        
    import from LibNg112_Templates all;
    import from LibNg112_TypesAndValues all;

    import from LibSip_Templates all;
    import from LibSip_Steps all;

    import from AtsESRP_Pixits all;

    import from LibNg112_TestSystem all;
    import from LibCommon_Sync all;

    import from LibNg112_DequeueRegistration all;

    type record Statement {    
        charstring name,
        boolean val
    }

    type record of Statement StatementList;

    function f_check_statements(StatementList p_statements) {
        var charstring v_msg := "";
        for(var integer v_i := 0; v_i < sizeof(p_statements); v_i := v_i + 1) {
            if (not(p_statements[v_i].val)) {
                if (lengthof(v_msg) > 0) {
                    v_msg := v_msg & ", ";
                }
                v_msg := v_msg & p_statements[v_i].name;
            }
        }

        if (lengthof(v_msg) > 0) {
            log("*** " & testcasename() & ": " & v_msg &" required for executing the TC ***")
            setverdict(inconc);
            stop;
        }
    }

    function awaitingRequest_sendReply(template LibItsHttp_TypesAndValues.Request p_request, template (value) XmlBody p_reply) runs on HttpComponent {
        var Headers v_headers;
        
        alt {
            [] httpPort.receive(mw_http_request(p_request)) {
            tc_ac.stop;
            
            // Send the response
            f_init_default_headers_list(-, -, v_headers);
            httpPort.send(
                            m_http_response(
                                            m_http_response_ok(
                                                                {xml_body := p_reply},
                                                                v_headers)));
            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
            }
            [] tc_ac.timeout {
            log("*** " & testcasename() & ": INCONC: Expected message not received ***");
            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
            }            
        }
    }

    function f_http_post(in charstring p_uri, in template (omit) HttpMessageBody p_body := omit) runs on HttpComponent {
        // Local variables
        var Headers v_headers;
        
        f_init_default_headers_list(-, -, v_headers);
        f_remove_headers_list({ c_header_accept, c_header_authorization }, v_headers);

        if (PX_ADD_TC_NAME_HTTP_HEADER) {
            f_set_headers_list({ "X-TestcaseName"},{ testcasename()},v_headers);
        }
        
        httpPort.send(
            m_http_request(
                            m_http_request_post(
                                                p_uri,
                                                v_headers,
                                                p_body
                            )
            )
        );
    }

    function f_http_put(in charstring p_uri, in template (omit) HttpMessageBody p_body := omit) runs on HttpComponent {
        // Local variables
        var Headers v_headers;
        
        f_init_default_headers_list(-, -, v_headers);
        f_remove_headers_list({ c_header_accept, c_header_authorization }, v_headers);

        if (PX_ADD_TC_NAME_HTTP_HEADER) {
            f_set_headers_list({ "X-TestcaseName"},{ testcasename()},v_headers);
        }
        
        httpPort.send(
            m_http_request(
                            m_http_request_put(
                                                p_uri,
                                                v_headers,
                                                p_body
                            )
            )
        );
    }

    group QueueState {
        function f_awaitingSubscribeQueueState() runs on HttpSipComponent {
            var LibSip_SIPTypesAndValues.Request v_request;

            template LibSip_SIPTypesAndValues.Request mw_request := ?;

            log("**** f_awaitingSubscribeQueueState ****");
            // f_awaitingSUBSCRIBE(mw_SUBSCRIBE_QueueState_Request);                        
            SIPP.receive(mw_request) -> value v_request 
            log("**** f_awaitingSubscribeQueueState: -> ");
            log(v_request);            
        }    

        function f_sendSubscribeQueueStateResponse() runs on HttpSipComponent {
            log("**** f_sendSubscribeQueueStateResponse ****") ;
            f_send200OK();
        }

    } // End of group QueueState

    group DequeueRegistration {
        function f_sendDequeueRegistration(template DequeueRegistrationRequest p_request) runs on HttpComponent { 
            log("**** f_sendDequeueRegistration ****") ;                
            f_http_put(
                        PX_ESRP_DEQUEUE_REGISTRATION_URI, 
                        m_http_message_body_json(
                                                m_body_json_dequeue_registration_request(p_request)
                                                )
                        )                
        }

        function f_awaitingDequeueRegistrationResponse(template (present) DequeueRegistrationResponse p_response) runs on HttpComponent {
            alt {
                [] httpPort.receive(
                                    mw_http_response(
                                                    mw_http_response_ok(
                                                                        mw_http_message_body_json(
                                                                                                mw_body_json_dequeue_registration_response(p_response)                                                                                                                                            
                                                                                                )))) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": INFO: IUT successfully responsds to dequeue registration***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                }
                [] tc_ac.timeout {
                    log("*** " & testcasename() & ": INCONC: Expected message not received ***");
                    f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                }
            }
        }            
    } // End of group DequeueRegistration
}
+16 −5
Original line number Diff line number Diff line
@@ -2,6 +2,17 @@ module AtsESRP_Pics {

  type record of charstring request_uri_list;

  /**
  * @desc Does the IUT support LoST protocol?
  */
  modulepar boolean PICS_ESRP_LOST := true;

  /**
  * @desc Does the IUT support Dequeue Registration?
  */
  modulepar boolean PICS_ESRP_TARGET_DEQUEUE_REGISTRATION_SUPPORT := true;


  /**
   * @desc HTTP post URI for LIS protocol
   */
+16 −0
Original line number Diff line number Diff line
module AtsESRP_Pixits {
  
  import from XSD all;
  
  // Dequeue Registration  
  modulepar charstring PX_ESRP_DEQUEUE_REGISTRATION_URI := "/esrp";
  
  modulepar charstring PX_ESRP_DEQUEUE_REGISTRATION_QUEUE := "sip:queue@esinet.io";
  modulepar charstring PX_ESRP_DEQUEUE_REGISTRATION_DEQUEUER := "sip:target@esinet.io";
  modulepar integer     PX_ESRP_DEQUEUE_REGISTRATION_EXPIRATION := 3600;
  modulepar integer     PX_ESRP_DEQUEUE_REGISTRATION_PREFERENCE := 5;

  // Debug
  modulepar boolean PX_ADD_TC_NAME_HTTP_HEADER := false;

} // End of module AtsECRF_Pixits 
+3 −0
Original line number Diff line number Diff line
module AtsESRP_Templates {

}
 No newline at end of file
+136 −1162

File changed.

Preview size limit exceeded, changes collapsed.

Loading