module Simple_Testcases { import from TestSystem all; import from LibSip_SIPTypesAndValues all; import from LibSip_SDPTypes all; import from SipIsup_ISUP_MsgTypes all; const charstring c_CRLF := oct2char('0D'O) & oct2char('0A'O); template SipUrl m_simpleUrl (charstring user, charstring host, integer p) := { scheme := "sip", userInfo := { userOrTelephoneSubscriber := user, password := omit }, hostPort := { host := host, portField := p }, urlParameters := *, headers := * } // testing SipUrl testcase TC_SIMPLE_0001() runs on SipTest system SipTest { // Preamble connect (self:testPort, self:testPort); // Test Body testPort.send ("sip:user;par=u%40example.net@host:42"); alt { [] testPort.receive (m_simpleUrl ("user;par=u%40example.net", "host", 42)) { setverdict (pass); } [] testPort.receive (SipUrl: ?) { setverdict (fail); } } } // testing MessageHeader testcase TC_SIMPLE_0002() runs on SipTest system SipTest { // Preamble connect (self:testPort, self:testPort); // Test Body testPort.send ( "From: Caller ;tag=123" & c_CRLF & "Via: SIP/2.0/UDP grabu.com, SIP/2.0/UDP etsi.org" & c_CRLF & "Via: SIP/2.0/UDP pouic-pouic.com" & c_CRLF & "Pouet: blah blah" & c_CRLF & "Via: SIP/2.0/UDP tutu.com" & c_CRLF & "Call-ID: a84b4c76e66710" & c_CRLF & "CSeq: 1 INVITE" & c_CRLF & "Content-Length: 0" & c_CRLF & "Content-Type: text/xml" & c_CRLF & "To: User ;test=5" & c_CRLF & "Contact: User , , tel:5678" & c_CRLF & "Contact: User3 " & c_CRLF & "Accept: text/*;abc=5;def , image/*" & c_CRLF & "Accept: audio/*;abc=5;def" & c_CRLF & "Accept-Language: en-us, en-uk, CZ;condition=2;template=abc" & c_CRLF & "Max-Forwards: 5" & c_CRLF & "Accept-Encoding: gzip;def=2 , *" & c_CRLF & "Alert-Info: , " & c_CRLF & "Allow: INVITE, ACK, BYE , CANCEL" & c_CRLF & "Authentication-Info: qop = auth, cnonce=""abc"",nc=00000021" & c_CRLF & "Authorization: digest username = ""test"", cnonce=""abc"",nc=00000021" & c_CRLF & "Authorization: digest username = ""test2"", cnonce=""bcd"",nc=00000031" & c_CRLF & "Call-Info: ;purpose = info, " & c_CRLF & "Content-Disposition: session;param1=1; param2=""25&""" & c_CRLF & "Content-Encoding: gzip" & c_CRLF & "Content-Language: fr, en-us, en-uk" & c_CRLF & "Date : Sat, 13 Nov 2010 23:29:00 GMT" & c_CRLF & "Error-Info: , ;par1=5" & c_CRLF & "Expires: 45" & c_CRLF & "In-Reply-To: a84b4c76e66610, a84b4c76e66620, a84b4c76e66630" & c_CRLF & "MIME-Version: 5.25" & c_CRLF & "Min-Expires: 10" & c_CRLF & "Organization: ETSI Einstein Building" & c_CRLF & "Priority: normal" & c_CRLF & "Proxy-Authenticate: digest qop = auth, cnonce=""abc"",nc=00000021" & c_CRLF & "Proxy-Authorization: digest username = ""test"", cnonce=""abc"",nc=00000021" & c_CRLF & "Proxy-Require: abc, data" & c_CRLF & "Record-Route: , " & c_CRLF & "Record-Route: , " & c_CRLF & "Reply-To: User ;test=5" & c_CRLF & "Retry-After: 5 (this is a comment)" & c_CRLF & "Require: good_feedback, warp_speed" & c_CRLF & "Require: something_else" & c_CRLF & "Route: , " & c_CRLF & "Server: server1 server2 server4 server8" & c_CRLF & "Subject: some subject" & c_CRLF & "Supported: feature1, feature2, feature3" & c_CRLF & "Timestamp: 55.0" & c_CRLF & "UnSupported: fancy_feature1, fancy_feature2" & c_CRLF & "User-Agent: server3 server5" & c_CRLF & "Warning: 0001 etsi.org:42 ""This is an important warning""" & c_CRLF & "WWW-Authenticate: digest qop = auth, cnonce=""abc"",nc=00000021" & c_CRLF & "Pouet: blah blah again" & c_CRLF & " on multiple lines" & c_CRLF ); alt { [] testPort.receive (MessageHeader: ?) { setverdict (inconc); } } } // simplest SDP message // (example taken from RFC 4566) testcase TC_SIMPLE_0003() runs on SipTest system SipTest { // Preamble connect (self:testPort, self:testPort); // Test Body testPort.send ( "v=0" & c_CRLF & "o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5" & c_CRLF & "s=SDP Seminar" & c_CRLF ); alt { [] testPort.receive (SDP_Message: ?) { setverdict (inconc); } [] testPort.receive { setverdict (fail); } } } // more complex SDP message testcase TC_SIMPLE_0004() runs on SipTest system SipTest { // Preamble connect (self:testPort, self:testPort); // Test Body testPort.send ( "v=0" & c_CRLF & "o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5" & c_CRLF & "s=SDP Seminar" & c_CRLF & "i=A Seminar on the session description protocol" & c_CRLF & "u=http://www.example.com/seminars/sdp.pdf" & c_CRLF & "e=j.doe@example.com (Jane Doe)" & c_CRLF & "c=IN IP4 224.2.17.12/127" & c_CRLF & "t=2873397496 2873404696" & c_CRLF & "a=blah:BLAHBLAH" & c_CRLF & "a=truc" & c_CRLF & "a=cat:blah.blah.blah" & c_CRLF & "a=keywds:blah blih bloh" & c_CRLF & "a=tool:some useless tool" & c_CRLF & "a=ptime:3254235" & c_CRLF & "a=maxptime:13254235" & c_CRLF & "a=rtpmap:99 h263-1998/90000" & c_CRLF & "a=recvonly" & c_CRLF & "a=sendrecv" & c_CRLF & "a=sendonly" & c_CRLF & "a=inactive" & c_CRLF & "a=orient:landscape" & c_CRLF & "a=type:meeting" & c_CRLF & "a=charset:ISO-8859-1" & c_CRLF & "a=sdplang:fr" & c_CRLF & "a=lang:en" & c_CRLF & "a=framerate:25.0" & c_CRLF & "a=quality:8" & c_CRLF & "a=fmtp:100 98/98" & c_CRLF & "a=curr:qos local send" & c_CRLF & "a=des:blah failure remote none" & c_CRLF & "a=conf:truc e2e sendrecv" & c_CRLF & "m=blah 49170/234 RTP/AVP/FOO/BAR 0 1 hello world" & c_CRLF & "i=I like to blah blah blah blah" & c_CRLF & "c=IN IP4 192.168.0.42" & c_CRLF & "c=IN IP4 224.2.17.12/127" & c_CRLF & "c=IN IP4 224.2.2.1/3/34" & c_CRLF & "c=IN IP4 foo.bar.com" & c_CRLF & "c=IN IP6 fe80::204:00ff:fe09:3424" & c_CRLF & "c=IN IP6 ff0a::42/456" & c_CRLF & "b=foo:1234" & c_CRLF & // "b=blah:567890" & c_CRLF & // FIXME: multiple bandwith fields allowed by the BNF but not by the types "k=prompt" & c_CRLF & "a=quality:8" & c_CRLF & "a=fmtp:100 98/98" & c_CRLF & "m=audio 49170 RTP/AVP 0" & c_CRLF & "m=video 51372 RTP/AVP 99" & c_CRLF & "a=rtpmap:99 h263-1998/90000" & c_CRLF ); alt { [] testPort.receive (SDP_Message: ?) { setverdict (inconc); } [] testPort.receive { setverdict (fail); } } } // long SDP message testcase TC_SIMPLE_0005() runs on SipTest system SipTest { // Preamble connect (self:testPort, self:testPort); // Test Body testPort.send ( "v=0" & c_CRLF & "o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5" & c_CRLF & "s=SDP Seminar" & c_CRLF & "i=A Seminar on the session description protocol" & c_CRLF & "u=http://www.example.com/seminars/sdp.pdf" & c_CRLF & "e=j.doe@example.com (Jane Doe)" & c_CRLF & "e=ublah@blah.com (Blah blaH)" & c_CRLF & "e=ublah2@blahblah.com (Blah 2 Blah Blah)" & c_CRLF & "e=reverse order " & c_CRLF & "e=without@dispname.com" & c_CRLF & "p=044934-3454" & c_CRLF & "p=+33 2 99 84 71 71 (fax)" & c_CRLF & "p=in reverse order <+33 2 99 84 13 37>" & c_CRLF & "c=IN IP4 224.2.17.12/1/27" & c_CRLF & "b=X-YZ:128" & c_CRLF & "b=blah:42" & c_CRLF & "t=2873397496 2873404696" & c_CRLF & "t=42 1337" & c_CRLF & "r=1 2" & c_CRLF & "r=1 23 456 7890" & c_CRLF & "z=1231241314 234234s 1234234902394 -234245d" & c_CRLF & "k=clear:blah! blah!" & c_CRLF & "a=recvonly" & c_CRLF & "m=audio 49170 RTP/AVP 0" & c_CRLF & "m=video 51372 RTP/AVP 99" & c_CRLF & "a=rtpmap:99 h263-1998/90000" & c_CRLF ); alt { [] testPort.receive (SDP_Message: ?) { setverdict (inconc); } [] testPort.receive { setverdict (fail); } } } // SDP message with an IPv6 connection address testcase TC_SIMPLE_0006() runs on SipTest system SipTest { // Preamble connect (self:testPort, self:testPort); // Test Body testPort.send ( "v=0" & c_CRLF & "o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5" & c_CRLF & "s=SDP Seminar" & c_CRLF & "c=IN IP6 ff08::232:ff:fe00:1337/24" & c_CRLF ); alt { [] testPort.receive (SDP_Message: ?) { setverdict (inconc); } [] testPort.receive { setverdict (fail); } } } // ISUP Initial Address message testcase TC_SIMPLE_0007() runs on SipTest system SipTest { // Preamble connect (self:testPort, self:testPort); // Test Body testPort.send ('010061000A03020B090490006956210037F60A070311843301332500'O); alt { [] testPort.receive (ISUP_BICC_MSG: ?) { setverdict (inconc); } [] testPort.receive { setverdict (fail); } } } }