1 | module Simple_Testcases |
---|
2 | { |
---|
3 | import from TestSystem all; |
---|
4 | import from LibSip_SIPTypesAndValues all; |
---|
5 | import from LibSip_SDPTypes all; |
---|
6 | import from SipIsup_ISUP_MsgTypes all; |
---|
7 | |
---|
8 | const charstring c_CRLF := oct2char('0D'O) & oct2char('0A'O); |
---|
9 | |
---|
10 | template SipUrl m_simpleUrl (charstring user, charstring host, integer p) := { |
---|
11 | scheme := "sip", |
---|
12 | userInfo := { |
---|
13 | userOrTelephoneSubscriber := user, |
---|
14 | password := omit |
---|
15 | }, |
---|
16 | hostPort := { |
---|
17 | host := host, |
---|
18 | portField := p |
---|
19 | }, |
---|
20 | urlParameters := *, |
---|
21 | headers := * |
---|
22 | } |
---|
23 | |
---|
24 | // testing SipUrl |
---|
25 | testcase TC_SIMPLE_0001() runs on SipTest system SipTest { |
---|
26 | |
---|
27 | // Preamble |
---|
28 | connect (self:testPort, self:testPort); |
---|
29 | |
---|
30 | // Test Body |
---|
31 | testPort.send ("sip:user;par=u%40example.net@host:42"); |
---|
32 | |
---|
33 | alt { |
---|
34 | [] testPort.receive (m_simpleUrl ("user;par=u%40example.net", "host", 42)) { |
---|
35 | setverdict (pass); |
---|
36 | } |
---|
37 | [] testPort.receive (SipUrl: ?) { |
---|
38 | setverdict (fail); |
---|
39 | } |
---|
40 | } |
---|
41 | |
---|
42 | } |
---|
43 | |
---|
44 | // testing MessageHeader |
---|
45 | testcase TC_SIMPLE_0002() runs on SipTest system SipTest { |
---|
46 | |
---|
47 | // Preamble |
---|
48 | connect (self:testPort, self:testPort); |
---|
49 | |
---|
50 | // Test Body |
---|
51 | testPort.send ( "From: Caller <sip:caller@host:42>;tag=123" & c_CRLF & |
---|
52 | "Via: SIP/2.0/UDP grabu.com, SIP/2.0/UDP etsi.org" & c_CRLF & |
---|
53 | "Via: SIP/2.0/UDP pouic-pouic.com" & c_CRLF & |
---|
54 | "Pouet: blah blah" & c_CRLF & |
---|
55 | "Via: SIP/2.0/UDP tutu.com" & c_CRLF & |
---|
56 | "Call-ID: a84b4c76e66710" & c_CRLF & |
---|
57 | "CSeq: 1 INVITE" & c_CRLF & |
---|
58 | "Content-Length: 0" & c_CRLF & |
---|
59 | "Content-Type: text/xml" & c_CRLF & |
---|
60 | "To: User <sip:user@host:42>;test=5" & c_CRLF & |
---|
61 | "Contact: User <sip:user@etsi.org:42;test=5?par1=2&par2=30>, <http://www.etsi.org>, tel:5678" & c_CRLF & |
---|
62 | "Contact: User3 <sip:user3@etsi.org>" & c_CRLF & |
---|
63 | "Accept: text/*;abc=5;def , image/*" & c_CRLF & |
---|
64 | "Accept: audio/*;abc=5;def" & c_CRLF & |
---|
65 | "Accept-Language: en-us, en-uk, CZ;condition=2;template=abc" & c_CRLF & |
---|
66 | "Max-Forwards: 5" & c_CRLF & |
---|
67 | "Accept-Encoding: gzip;def=2 , *" & c_CRLF & |
---|
68 | "Alert-Info: <sip:etsi.org>, <tel:123456>" & c_CRLF & |
---|
69 | "Allow: INVITE, ACK, BYE , CANCEL" & c_CRLF & |
---|
70 | "Authentication-Info: qop = auth, cnonce=""abc"",nc=00000021" & c_CRLF & |
---|
71 | "Authorization: digest username = ""test"", cnonce=""abc"",nc=00000021" & c_CRLF & |
---|
72 | "Authorization: digest username = ""test2"", cnonce=""bcd"",nc=00000031" & c_CRLF & |
---|
73 | "Call-Info: <sip:etsi.org>;purpose = info, <tel:123456>" & c_CRLF & |
---|
74 | "Content-Disposition: session;param1=1; param2=""25&""" & c_CRLF & |
---|
75 | "Content-Encoding: gzip" & c_CRLF & |
---|
76 | "Content-Language: fr, en-us, en-uk" & c_CRLF & |
---|
77 | "Date : Sat, 13 Nov 2010 23:29:00 GMT" & c_CRLF & |
---|
78 | "Error-Info: <sip:etsi.org>, <tel:123456>;par1=5" & c_CRLF & |
---|
79 | "Expires: 45" & c_CRLF & |
---|
80 | "In-Reply-To: a84b4c76e66610, a84b4c76e66620, a84b4c76e66630" & c_CRLF & |
---|
81 | "MIME-Version: 5.25" & c_CRLF & |
---|
82 | "Min-Expires: 10" & c_CRLF & |
---|
83 | "Organization: ETSI Einstein Building" & c_CRLF & |
---|
84 | "Priority: normal" & c_CRLF & |
---|
85 | "Proxy-Authenticate: digest qop = auth, cnonce=""abc"",nc=00000021" & c_CRLF & |
---|
86 | "Proxy-Authorization: digest username = ""test"", cnonce=""abc"",nc=00000021" & c_CRLF & |
---|
87 | "Proxy-Require: abc, data" & c_CRLF & |
---|
88 | "Record-Route: <sip:etsi.org>, <tel:123456>" & c_CRLF & |
---|
89 | "Record-Route: <sip:elvior.ee>, <tel:99123456>" & c_CRLF & |
---|
90 | "Reply-To: User <sip:user@host:42>;test=5" & c_CRLF & |
---|
91 | "Retry-After: 5 (this is a comment)" & c_CRLF & |
---|
92 | "Require: good_feedback, warp_speed" & c_CRLF & |
---|
93 | "Require: something_else" & c_CRLF & |
---|
94 | "Route: <sip:etsi.org>, <tel:123456>" & c_CRLF & |
---|
95 | "Server: server1 server2 server4 server8" & c_CRLF & |
---|
96 | "Subject: some subject" & c_CRLF & |
---|
97 | "Supported: feature1, feature2, feature3" & c_CRLF & |
---|
98 | "Timestamp: 55.0" & c_CRLF & |
---|
99 | "UnSupported: fancy_feature1, fancy_feature2" & c_CRLF & |
---|
100 | "User-Agent: server3 server5" & c_CRLF & |
---|
101 | "Warning: 0001 etsi.org:42 ""This is an important warning""" & c_CRLF & |
---|
102 | "WWW-Authenticate: digest qop = auth, cnonce=""abc"",nc=00000021" & c_CRLF & |
---|
103 | "Pouet: blah blah again" & c_CRLF & |
---|
104 | " on multiple lines" & c_CRLF |
---|
105 | ); |
---|
106 | |
---|
107 | alt { |
---|
108 | [] testPort.receive (MessageHeader: ?) { |
---|
109 | setverdict (inconc); |
---|
110 | } |
---|
111 | } |
---|
112 | |
---|
113 | } |
---|
114 | |
---|
115 | // simplest SDP message |
---|
116 | // (example taken from RFC 4566) |
---|
117 | testcase TC_SIMPLE_0003() runs on SipTest system SipTest { |
---|
118 | // Preamble |
---|
119 | connect (self:testPort, self:testPort); |
---|
120 | |
---|
121 | // Test Body |
---|
122 | testPort.send ( |
---|
123 | "v=0" & c_CRLF & |
---|
124 | "o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5" & c_CRLF & |
---|
125 | "s=SDP Seminar" & c_CRLF |
---|
126 | ); |
---|
127 | |
---|
128 | alt { |
---|
129 | [] testPort.receive (SDP_Message: ?) { |
---|
130 | setverdict (inconc); |
---|
131 | } |
---|
132 | [] testPort.receive { |
---|
133 | setverdict (fail); |
---|
134 | } |
---|
135 | } |
---|
136 | } |
---|
137 | |
---|
138 | // more complex SDP message |
---|
139 | testcase TC_SIMPLE_0004() runs on SipTest system SipTest { |
---|
140 | // Preamble |
---|
141 | connect (self:testPort, self:testPort); |
---|
142 | |
---|
143 | // Test Body |
---|
144 | testPort.send ( |
---|
145 | "v=0" & c_CRLF & |
---|
146 | "o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5" & c_CRLF & |
---|
147 | "s=SDP Seminar" & c_CRLF & |
---|
148 | "i=A Seminar on the session description protocol" & c_CRLF & |
---|
149 | "u=http://www.example.com/seminars/sdp.pdf" & c_CRLF & |
---|
150 | "e=j.doe@example.com (Jane Doe)" & c_CRLF & |
---|
151 | "c=IN IP4 224.2.17.12/127" & c_CRLF & |
---|
152 | "t=2873397496 2873404696" & c_CRLF & |
---|
153 | "a=blah:BLAHBLAH" & c_CRLF & |
---|
154 | "a=truc" & c_CRLF & |
---|
155 | "a=cat:blah.blah.blah" & c_CRLF & |
---|
156 | "a=keywds:blah blih bloh" & c_CRLF & |
---|
157 | "a=tool:some useless tool" & c_CRLF & |
---|
158 | "a=ptime:3254235" & c_CRLF & |
---|
159 | "a=maxptime:13254235" & c_CRLF & |
---|
160 | "a=rtpmap:99 h263-1998/90000" & c_CRLF & |
---|
161 | "a=recvonly" & c_CRLF & |
---|
162 | "a=sendrecv" & c_CRLF & |
---|
163 | "a=sendonly" & c_CRLF & |
---|
164 | "a=inactive" & c_CRLF & |
---|
165 | "a=orient:landscape" & c_CRLF & |
---|
166 | "a=type:meeting" & c_CRLF & |
---|
167 | "a=charset:ISO-8859-1" & c_CRLF & |
---|
168 | "a=sdplang:fr" & c_CRLF & |
---|
169 | "a=lang:en" & c_CRLF & |
---|
170 | "a=framerate:25.0" & c_CRLF & |
---|
171 | "a=quality:8" & c_CRLF & |
---|
172 | "a=fmtp:100 98/98" & c_CRLF & |
---|
173 | "a=curr:qos local send" & c_CRLF & |
---|
174 | "a=des:blah failure remote none" & c_CRLF & |
---|
175 | "a=conf:truc e2e sendrecv" & c_CRLF & |
---|
176 | "m=blah 49170/234 RTP/AVP/FOO/BAR 0 1 hello world" & c_CRLF & |
---|
177 | "i=I like to blah blah blah blah" & c_CRLF & |
---|
178 | "c=IN IP4 192.168.0.42" & c_CRLF & |
---|
179 | "c=IN IP4 224.2.17.12/127" & c_CRLF & |
---|
180 | "c=IN IP4 224.2.2.1/3/34" & c_CRLF & |
---|
181 | "c=IN IP4 foo.bar.com" & c_CRLF & |
---|
182 | "c=IN IP6 fe80::204:00ff:fe09:3424" & c_CRLF & |
---|
183 | "c=IN IP6 ff0a::42/456" & c_CRLF & |
---|
184 | "b=foo:1234" & c_CRLF & |
---|
185 | // "b=blah:567890" & c_CRLF & // FIXME: multiple bandwith fields allowed by the BNF but not by the types |
---|
186 | "k=prompt" & c_CRLF & |
---|
187 | "a=quality:8" & c_CRLF & |
---|
188 | "a=fmtp:100 98/98" & c_CRLF & |
---|
189 | "m=audio 49170 RTP/AVP 0" & c_CRLF & |
---|
190 | "m=video 51372 RTP/AVP 99" & c_CRLF & |
---|
191 | "a=rtpmap:99 h263-1998/90000" & c_CRLF |
---|
192 | ); |
---|
193 | |
---|
194 | alt { |
---|
195 | [] testPort.receive (SDP_Message: ?) { |
---|
196 | setverdict (inconc); |
---|
197 | } |
---|
198 | [] testPort.receive { |
---|
199 | setverdict (fail); |
---|
200 | } |
---|
201 | } |
---|
202 | } |
---|
203 | |
---|
204 | // long SDP message |
---|
205 | testcase TC_SIMPLE_0005() runs on SipTest system SipTest { |
---|
206 | // Preamble |
---|
207 | connect (self:testPort, self:testPort); |
---|
208 | |
---|
209 | // Test Body |
---|
210 | testPort.send ( |
---|
211 | "v=0" & c_CRLF & |
---|
212 | "o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5" & c_CRLF & |
---|
213 | "s=SDP Seminar" & c_CRLF & |
---|
214 | "i=A Seminar on the session description protocol" & c_CRLF & |
---|
215 | "u=http://www.example.com/seminars/sdp.pdf" & c_CRLF & |
---|
216 | "e=j.doe@example.com (Jane Doe)" & c_CRLF & |
---|
217 | "e=ublah@blah.com (Blah blaH)" & c_CRLF & |
---|
218 | "e=ublah2@blahblah.com (Blah 2 Blah Blah)" & c_CRLF & |
---|
219 | "e=reverse order <in.the@other.order.com>" & c_CRLF & |
---|
220 | "e=without@dispname.com" & c_CRLF & |
---|
221 | "p=044934-3454" & c_CRLF & |
---|
222 | "p=+33 2 99 84 71 71 (fax)" & c_CRLF & |
---|
223 | "p=in reverse order <+33 2 99 84 13 37>" & c_CRLF & |
---|
224 | "c=IN IP4 224.2.17.12/1/27" & c_CRLF & |
---|
225 | "b=X-YZ:128" & c_CRLF & |
---|
226 | "b=blah:42" & c_CRLF & |
---|
227 | "t=2873397496 2873404696" & c_CRLF & |
---|
228 | "t=42 1337" & c_CRLF & |
---|
229 | "r=1 2" & c_CRLF & |
---|
230 | "r=1 23 456 7890" & c_CRLF & |
---|
231 | "z=1231241314 234234s 1234234902394 -234245d" & c_CRLF & |
---|
232 | "k=clear:blah! blah!" & c_CRLF & |
---|
233 | "a=recvonly" & c_CRLF & |
---|
234 | "m=audio 49170 RTP/AVP 0" & c_CRLF & |
---|
235 | "m=video 51372 RTP/AVP 99" & c_CRLF & |
---|
236 | "a=rtpmap:99 h263-1998/90000" & c_CRLF |
---|
237 | ); |
---|
238 | |
---|
239 | alt { |
---|
240 | [] testPort.receive (SDP_Message: ?) { |
---|
241 | setverdict (inconc); |
---|
242 | } |
---|
243 | [] testPort.receive { |
---|
244 | setverdict (fail); |
---|
245 | } |
---|
246 | } |
---|
247 | } |
---|
248 | |
---|
249 | // SDP message with an IPv6 connection address |
---|
250 | testcase TC_SIMPLE_0006() runs on SipTest system SipTest { |
---|
251 | // Preamble |
---|
252 | connect (self:testPort, self:testPort); |
---|
253 | |
---|
254 | // Test Body |
---|
255 | testPort.send ( |
---|
256 | "v=0" & c_CRLF & |
---|
257 | "o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5" & c_CRLF & |
---|
258 | "s=SDP Seminar" & c_CRLF & |
---|
259 | "c=IN IP6 ff08::232:ff:fe00:1337/24" & c_CRLF |
---|
260 | ); |
---|
261 | |
---|
262 | alt { |
---|
263 | [] testPort.receive (SDP_Message: ?) { |
---|
264 | setverdict (inconc); |
---|
265 | } |
---|
266 | [] testPort.receive { |
---|
267 | setverdict (fail); |
---|
268 | } |
---|
269 | } |
---|
270 | } |
---|
271 | |
---|
272 | |
---|
273 | // ISUP Initial Address message |
---|
274 | testcase TC_SIMPLE_0007() runs on SipTest system SipTest { |
---|
275 | // Preamble |
---|
276 | connect (self:testPort, self:testPort); |
---|
277 | |
---|
278 | // Test Body |
---|
279 | testPort.send ('010061000A03020B090490006956210037F60A070311843301332500'O); |
---|
280 | |
---|
281 | alt { |
---|
282 | [] testPort.receive (ISUP_BICC_MSG: ?) { |
---|
283 | setverdict (inconc); |
---|
284 | } |
---|
285 | [] testPort.receive { |
---|
286 | setverdict (fail); |
---|
287 | } |
---|
288 | } |
---|
289 | } |
---|
290 | } |
---|