Skip to content

Commit

Permalink
Add inv_brkn1, a test case where Bob is sending us broken SDP
Browse files Browse the repository at this point in the history
in 183 session progress response to the INVITE.
  • Loading branch information
sobomax committed Jul 29, 2024
1 parent 21d49e8 commit d41d741
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 6 deletions.
4 changes: 4 additions & 0 deletions functions
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ then
BOB_TIMEOUT=90
TEST_SET="${TEST_SET},11,12,13,14,reinv_brkn1,reinv_brkn2,reinv_bad_ack"
fi
if [ "${MM_TYPE}" = "b2bua" ]
then
TEST_SET="${TEST_SET},inv_brkn1"
fi

#if [ "${MM_TYPE}" != "opensips" -o "${MM_BRANCH}" = "1.11" ]
#then
Expand Down
3 changes: 2 additions & 1 deletion lib/alice_testcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@
from ..test_cases.reinv_adelay import a_test_reinv_adelay
from ..test_cases.reinv_frombob import a_test_reinv_frombob
from ..test_cases.reinv_bad_ack import a_test_reinv_bad_ack
from ..test_cases.inv_brkn1 import a_test_inv_brkn1

ALL_TESTS = (a_test1, a_test2, a_test3, a_test4, a_test5, a_test6, a_test7, \
a_test8, a_test9, a_test10, a_test11, a_test12, a_test13, a_test14, \
a_test_early_cancel, a_test_early_cancel_lost100, a_test_reinvite, \
a_test_reinv_fail, a_test_reinv_brkn1, a_test_reinv_brkn2, \
a_test_reinv_onhold, a_test_reinv_adelay, a_test_reinv_frombob, \
a_test_reinv_bad_ack)
a_test_reinv_bad_ack, a_test_inv_brkn1)

class a_cfg(object):
test_class = None
Expand Down
3 changes: 2 additions & 1 deletion lib/bob_testcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@
from ..test_cases.reinv_adelay import b_test_reinv_adelay
from ..test_cases.reinv_frombob import b_test_reinv_frombob
from ..test_cases.reinv_bad_ack import b_test_reinv_bad_ack
from ..test_cases.inv_brkn1 import b_test_inv_brkn1

ALL_TESTS = (b_test1, b_test2, b_test3, b_test4, b_test5, b_test6, b_test7, \
b_test8, b_test9, b_test10, b_test11, b_test12, b_test13, b_test14, \
b_test_early_cancel, b_test_early_cancel_lost100, b_test_reinvite, \
b_test_reinv_fail, b_test_reinv_brkn1, b_test_reinv_brkn2, \
b_test_reinv_onhold, b_test_reinv_adelay, b_test_reinv_frombob, \
b_test_reinv_bad_ack)
b_test_reinv_bad_ack, b_test_inv_brkn1)

class STMHooks(object):
lossemul = 0
Expand Down
8 changes: 4 additions & 4 deletions rtpproxy.b2bua.output
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
nsess_created=46 nsess_destroyed=42 nsess_timeout=4 nsess_complete=30 nsess_nortp=26 nsess_owrtp=0 nsess_nortcp=26 nsess_owrtcp=0
ncmds_rcvd=167 ncmds_succd=162 ncmds_errs=4 ncmds_repld=166
nsess_created=46 nsess_destroyed=46 nsess_timeout=8 nsess_complete=30 nsess_nortp=30 nsess_owrtp=0 nsess_nortcp=30 nsess_owrtcp=0
ncmds_rcvd=173 ncmds_succd=164 ncmds_errs=8 ncmds_repld=172
nsess_created=48 nsess_destroyed=44 nsess_timeout=4 nsess_complete=30 nsess_nortp=26 nsess_owrtp=0 nsess_nortcp=26 nsess_owrtcp=0
ncmds_rcvd=171 ncmds_succd=166 ncmds_errs=4 ncmds_repld=170
nsess_created=48 nsess_destroyed=48 nsess_timeout=8 nsess_complete=30 nsess_nortp=30 nsess_owrtp=0 nsess_nortcp=30 nsess_owrtcp=0
ncmds_rcvd=177 ncmds_succd=168 ncmds_errs=8 ncmds_repld=176
MEMDEB(rtpproxy): all clear
75 changes: 75 additions & 0 deletions test_cases/inv_brkn1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright (c) 2016 Sippy Software, Inc. All rights reserved.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from .t2 import a_test2 as a_test_inv, b_test2 as b_test_inv

from sippy.CCEvents import CCEventTry, CCEventRing, CCEventFail, CCEventDisconnect

def cripple_body(self, sdp_body):
sdp_body = sdp_body.getCopy()
for sect in sdp_body.content.sections:
if sect.m_header.transport.lower() not in ('udp', 'udptl', 'rtp/avp'):
continue
sect.c_header = None
if sect.m_header.port + self.p_incr <= 0:
self.p_incr = -self.p_incr
sect.m_header.port += self.p_incr
self.p_incr = -self.p_incr
sdp_body.content.o_header.version += 1
return sdp_body

class a_test_inv_brkn1(a_test_inv):
cld = 'bob_inv_brkn1'
cli = 'alice_inv_brkn1'

def alldone(self, ua):
if self.disconnect_done and self.nerrs == 0:
self.rval = 0
self.tccfg.done_cb(self)

def recvEvent(self, event, ua):
if isinstance(event, CCEventTry):
return (super().recvEvent(event, ua))
if isinstance(event, CCEventRing) and event.getData()[0] == 100:
return (super().recvEvent(event, ua))
if self.connect_done or not isinstance(event, (CCEventFail, CCEventDisconnect)):
self.nerrs += 1
raise ValueError(f'{self.failed_msg()}: INVITE has NOT failed with {event}')
return (super().recvEvent(event, ua))

class b_test_inv_brkn1(b_test_inv):
cli = 'bob_inv_brkn1'
p_incr = -10

def ring(self, ua):
if self.connect_done or self.disconnect_done:
return
self.body = cripple_body(self, self.body)
super().ring(ua)

def alldone(self, ua):
if self.ring_done and not self.connect_done and self.disconnect_done and self.nerrs == 0:
self.rval = 0
self.tccfg.done_cb(self)

0 comments on commit d41d741

Please sign in to comment.