def test_response_parsing(self): at = self.assertTrue aq = self.assertEqual r = Message.parse('SIP/2.0 200 OK\r\n\r\n') at(isinstance(r, Response)) aq(r.code, 200) aq(r.reason, 'OK') r = Message.parse('SIP/2.0 100 Trying\r\nTo: Bob <sip:[email protected]>\r\nCSeq: 314159 INVITE\r\nContent-Length: 0\r\n\r\n') aq(r.code, 100) aq(r.reason, 'Trying') aq(r.headers['t'].display_name, 'Bob') aq(str(r.headers['t'].uri), 'sip:[email protected]') aq(str(r.headers['t']), 'Bob <sip:[email protected]>') aq(r.headers['cseq'].number, 314159) aq(r.headers['cseq'].method, 'INVITE') aq(r.headers['content-length'], '0')
def test_response_parsing(self): at = self.assertTrue aq = self.assertEqual r = Message.parse('SIP/2.0 200 OK\r\n\r\n') at(isinstance(r, Response)) aq(r.code, 200) aq(r.reason, 'OK') r = Message.parse( 'SIP/2.0 100 Trying\r\nTo: Bob <sip:[email protected]>\r\nCSeq: 314159 INVITE\r\nContent-Length: 0\r\n\r\n' ) aq(r.code, 100) aq(r.reason, 'Trying') aq(r.headers['t'].display_name, 'Bob') aq(str(r.headers['t'].uri), 'sip:[email protected]') aq(str(r.headers['t']), 'Bob <sip:[email protected]>') aq(r.headers['cseq'].number, 314159) aq(r.headers['cseq'].method, 'INVITE') aq(r.headers['content-length'], '0')
def test_request_parsing(self): at = self.assertTrue aq = self.assertEqual r = Message.parse("INVITE sip:[email protected] SIP/2.0\r\n\r\n") at(isinstance(r, Request)) aq(r.method, "INVITE") aq(str(r.ruri), 'sip:[email protected]') r = Message.parse( "INVITE sip:[email protected];transport=TCP SIP/2.0\r\nMax-Forwards: 30\r\n\r\nabacaba" ) at(isinstance(r, Request)) aq(r.method, "INVITE") aq(str(r.ruri), 'sip:[email protected];transport=TCP') aq(r.content, 'abacaba') r = Message.parse( "REGISTER sip:tipmeet.com SIP/2.0\r\nContact: *\r\nExpires: 0\r\n\r\n" ) at(isinstance(r, Request)) aq(r.method, 'REGISTER') aq(r.ruri.host, 'tipmeet.com') aq(r.ruri.scheme, 'sip') aq(r.headers['contact'], '*') aq(r.headers['expires'], '0') r = Message.parse( 'PUBLISH sip:[email protected] SIP/2.0\r\nFrom: ivaxer <sip:[email protected]> ;tag=123\r\n\r\n' ) at(isinstance(r, Request)) aq(r.method, 'PUBLISH') aq(str(r.ruri), 'sip:[email protected]') aq(str(r.headers['from'].uri), 'sip:[email protected]') aq(r.headers['from'].display_name, 'ivaxer') aq(r.headers['from'].params['tag'], '123') r = Message.parse( 'ACK sip:[email protected]:5066;transport=TCP SIP/2.0\r\nVia: SIP/2.0/UDP server10.biloxi.com ;branch=z9hG4bKnashds8\r\nVia: SIP/2.0/TCP bigbox3.site3.atlanta.com ;branch=z9hG4bK77ef4c2312983.1\r\n\r\n' ) aq(r.method, 'ACK') aq(str(r.ruri), 'sip:[email protected]:5066;transport=TCP') aq(r.headers['via'][0].transport, 'UDP') aq(r.headers['via'][0].host, 'server10.biloxi.com') aq(r.headers['via'][1].transport, 'TCP') aq(r.headers['via'][1].host, 'bigbox3.site3.atlanta.com') r = Message.parse( 'NOTIFY sip:[email protected] SIP/2.0\r\nRecord-Route: <sip:server10.biloxi.com;lr>,\r\n\t<sip:bigbox3.site3.atlanta.com;lr>\r\n\r\n' ) aq(str(r.headers['record-route'][0].uri), 'sip:server10.biloxi.com;lr') aq(str(r.headers['record-route'][1].uri), 'sip:bigbox3.site3.atlanta.com;lr')
def test_request_parsing(self): at = self.assertTrue aq = self.assertEqual r = Message.parse("INVITE sip:[email protected] SIP/2.0\r\n\r\n") at(isinstance(r, Request)) aq(r.method, "INVITE") aq(str(r.ruri), 'sip:[email protected]') r = Message.parse("INVITE sip:[email protected];transport=TCP SIP/2.0\r\nMax-Forwards: 30\r\n\r\nabacaba") at(isinstance(r, Request)) aq(r.method, "INVITE") aq(str(r.ruri), 'sip:[email protected];transport=TCP') aq(r.content, 'abacaba') r = Message.parse("REGISTER sip:tipmeet.com SIP/2.0\r\nContact: *\r\nExpires: 0\r\n\r\n") at(isinstance(r, Request)) aq(r.method, 'REGISTER') aq(r.ruri.host, 'tipmeet.com') aq(r.ruri.scheme, 'sip') aq(r.headers['contact'], '*') aq(r.headers['expires'], '0') r = Message.parse('PUBLISH sip:[email protected] SIP/2.0\r\nFrom: ivaxer <sip:[email protected]> ;tag=123\r\n\r\n') at(isinstance(r, Request)) aq(r.method, 'PUBLISH') aq(str(r.ruri), 'sip:[email protected]') aq(str(r.headers['from'].uri), 'sip:[email protected]') aq(r.headers['from'].display_name, 'ivaxer') aq(r.headers['from'].params['tag'], '123') r = Message.parse('ACK sip:[email protected]:5066;transport=TCP SIP/2.0\r\nVia: SIP/2.0/UDP server10.biloxi.com ;branch=z9hG4bKnashds8\r\nVia: SIP/2.0/TCP bigbox3.site3.atlanta.com ;branch=z9hG4bK77ef4c2312983.1\r\n\r\n') aq(r.method, 'ACK') aq(str(r.ruri), 'sip:[email protected]:5066;transport=TCP') aq(r.headers['via'][0].transport, 'UDP') aq(r.headers['via'][0].host, 'server10.biloxi.com') aq(r.headers['via'][1].transport, 'TCP') aq(r.headers['via'][1].host, 'bigbox3.site3.atlanta.com') r = Message.parse('NOTIFY sip:[email protected] SIP/2.0\r\nRecord-Route: <sip:server10.biloxi.com;lr>,\r\n\t<sip:bigbox3.site3.atlanta.com;lr>\r\n\r\n') aq(str(r.headers['record-route'][0].uri), 'sip:server10.biloxi.com;lr') aq(str(r.headers['record-route'][1].uri), 'sip:bigbox3.site3.atlanta.com;lr')