smalltalk
/
osmo-st-all
Archived
1
0
Fork 0

invite: Begin to handle the incoming INVITE from the network

Add a new test, inject a SIP Invite. Verify that the SIPUserAgent
rejects the invite.
This commit is contained in:
Holger Hans Peter Freyther 2014-05-27 10:44:30 +02:00
parent 15f1f07631
commit a819a8b877
4 changed files with 99 additions and 0 deletions

View File

@ -0,0 +1,81 @@
"
(C) 2011,2014 by Holger Hans Peter Freyther
All Rights Reserved
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"
TestCase subclass: SIPInviteTest [
| sent transport agent dialog |
<category: 'OsmoSIP-Callagent-Tests'>
<comment: 'Test incoming SIP INVITES. This should create a
new dialog/transaction and a SIPCall based on that. The call
can be accepted or rejected.'>
createInvite [
^(WriteStream on: String new)
nextPutAll: 'INVITE sip:+99915123456@10.23.43.2 SIP/2.0'; cr; nl;
nextPutAll: 'Max-Forwards: 19'; cr; nl;
nextPutAll: 'Via: SIP/2.0/UDP 10.23.43.1:5060;rport;branch=z9hG4bK1675813621'; cr; nl;
nextPutAll: 'From: "00331234567" <sip:00331234567@10.23.43.1>;tag=807191241'; cr; nl;
nextPutAll: 'To: <sip:+99915123456@10.23.43.2>'; cr; nl;
nextPutAll: 'Call-ID: 726660594@10.23.43.1'; cr; nl;
nextPutAll: 'CSeq: 3 INVITE'; cr; nl;
nextPutAll: 'User-Agent: BLOAT/4.3.0'; cr; nl;
nextPutAll: 'Contact: <sip:00331234567@10.23.43.1:5060>'; cr; nl;
nextPutAll: 'Allow: ACK, INVITE, BYE, CANCEL, REGISTER, REFER, OPTIONS, INFO'; cr; nl;
nextPutAll: 'Content-Type: application/sdp'; cr; nl;
nextPutAll: 'Content-Length: 189'; cr; nl;
cr; nl;
nextPutAll: 'v=0'; cr; nl;
nextPutAll: 'o=yate 1401116278 1401116278 IN IP4 10.23.42.1'; cr; nl;
nextPutAll: 's=SIP Call'; cr; nl;
nextPutAll: 'c=IN IP4 10.23.42.1'; cr; nl;
nextPutAll: 't=0 0'; cr; nl;
nextPutAll: 'm=audio 16576 RTP/AVP 8 101'; cr; nl;
nextPutAll: 'a=rtpmap:8 PCMA/8000'; cr; nl;
nextPutAll: 'a=rtpmap:101 telephone-event/8000'; cr; nl;
cr; nl;
contents
]
setUp [
sent := OrderedCollection new.
transport := SIPTransportMock new
onData: [:datagram | sent add: datagram];
yourself.
agent := SIPUserAgent createOn: transport.
agent
username: 'st';
password: 'st'.
dialog := SIPDialog fromUser: 'sip:st@127.0.0.1' host: '127.0.0.1' port: 5060.
dialog identity: agent mainIdentity.
]
testRejectCall [
| msg |
"Inject the invite"
transport inject: self createInvite.
"Check the reject"
self assert: sent size equals: 1.
msg := SIPParser parse: sent first data.
self assert: msg code equals: '603'.
self assert: msg phrase equals: 'Not Found'.
self assert: agent dialogs isEmpty.
]
]

View File

@ -45,3 +45,12 @@ SIPOptionsRequest extend [
dialog: aDialog.
]
]
SIPInviteRequest extend [
sipDispatchNewDialog: aDialog on: aUserAgent [
<category: 'OsmoSIP-Callagent'>
aUserAgent
newInvite: self
dialog: aDialog.
]
]

View File

@ -192,4 +192,11 @@ SIPUserAgentBase subclass: SIPUserAgent [
mainIdentity [
^mainIdentity
]
newInvite: anInvite dialog: aDialog [
"We have a new INVITE. The code should now ask someone if the
To person is known. For now just return the user is not be found
here."
^self respondWith: 603 phrase: 'Not Found' on: anInvite dialog: aDialog
]
]

View File

@ -68,6 +68,7 @@
<sunit>Osmo.SIPCallAgentTest</sunit>
<sunit>Osmo.SIPDigestTest</sunit>
<sunit>Osmo.SIPRegisterTransactionTest</sunit>
<sunit>Osmo.SIPInviteTest</sunit>
<filein>grammar/SIPGrammarTest.st</filein>
<filein>callagent/tests/SIPParserTest.st</filein>
<filein>callagent/tests/Tests.st</filein>
@ -75,5 +76,6 @@
<filein>callagent/tests/SIPDigestTest.st</filein>
<filein>callagent/tests/SIPTransportMock.st</filein>
<filein>callagent/tests/SIPRegisterTransactionTest.st</filein>
<filein>callagent/tests/SIPInviteTest.st</filein>
</test>
</package>