Skip to content

Commit

Permalink
pjsip/stir_shaken: Add test for invalid or missing callerid.
Browse files Browse the repository at this point in the history
  • Loading branch information
gtjoseph authored and github-actions[bot] committed Feb 19, 2025
1 parent 6715e8a commit 0631c83
Show file tree
Hide file tree
Showing 10 changed files with 208 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[default]
exten => _X.,1,Answer()
same => n,UserEvent(TestResult, result: ${STIR_SHAKEN(0,verify_result)})
same => n,Hangup()
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[system]
type=system
timer_t1=100
timer_b=6400

[transport-udp]
type=transport
protocol=udp
bind=127.0.0.1:5060

[sipp]
type=endpoint
context=default
allow=!all,ulaw
send_pai = yes
direct_media = no
connected_line_method = update
send_connected_line = no
send_diversion = no
trust_id_inbound = true
trust_id_outbound = true
identify_by = ip
stir_shaken_profile=from-sipp

[sipp]
type = identify
endpoint=sipp
match=127.0.0.4

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

[verification]
load_system_certs = no
ca_file=<<astetcdir>>/stir/astdev-ca.crt
curl_timeout=2
max_iat_age=60
max_date_header_age=60
max_cache_entry_age = 300
max_cache_size=666
failure_action = continue
x5u_deny=0.0.0.0/0.0.0.0
x5u_permit = 127.0.0.0/8
relax_x5u_path_restrictions = yes
relax_x5u_port_scheme_restrictions = yes

[attestation]
global_disable = no
check_tn_cert_public_url = no

[from-sipp]
type = profile
endpoint_behavior = verify
failure_action = continue_return_reason
send_mky = no
use_rfc9410_responses = no
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<scenario name="INVITE to echo with SDP in initial INVITE">

<send retrans="0">
<![CDATA[
INVITE sip:[dest]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:Anonymous@anonymous.invalid:[local_port]>;tag=[call_number]
To: <sip:[dest]@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 1 INVITE
Max-Forwards: 70
Contact: <sip:[service]@[local_ip]:[local_port]>
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, PRACK, REGISTER, REFER, MESSAGE
User-Agent: Test
Content-Type: application/sdp
Content-Length: [len]
v=0
o=- 20110306451 20110306451 IN IP[media_ip_type] [media_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 18 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:18 annexb=no
a=fmtp:101 0-16
a=ptime:20
a=sendrecv
]]>
</send>

<recv response="100"
optional="true">
</recv>

<recv response="180"
optional="true">
</recv>

<recv response="183"
optional="true">
</recv>

<recv response="200" rtd="true"/>


<send>
<![CDATA[
ACK sip:[dest]@[remote_ip]:[remote_port] SIP/2.0
[last_Via:]
[last_From:]
[last_To:]
[last_Call-ID:]
CSeq: 1 ACK
[last_Contact:]
[last_Allow:]
Content-Length: 0
]]>
</send>


<recv request="BYE"/>

<send>
<![CDATA[
SIP/2.0 200 OK
[last_Via:]
[last_From:]
[last_To:]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:test@[local_ip]:[local_port];transport=[transport]>
Content-Length: 0
]]>
</send>

</scenario>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
testinfo:
summary: 'Tests invalid_or_no_callerid'
description: |
'Run a single instance of Asterisk and send an INVITE with
no PAI or RPID and with an anonymized From header.
Asterisk will test this with the STIR_SHAKEN dialplan
function, ensuring that "invalid_or_no_callerid" is the result.'
test-modules:
test-object:
config-section: test-object-config
typename: sipp.SIPpTestCase
modules:
-
config-section: 'ami-config'
typename: 'ami.AMIEventModule'
-
config-section: 'http-server'
typename: 'http_static_server.HTTPStaticServer'
-
config-section: 'hangup-monitor'
typename: 'pluggable_modules.HangupMonitor'

test-object-config:
memcheck-delay-stop: 7
asterisk-instances: 1
test-iterations:
-
scenarios:
- { 'key-args': {'scenario': 'invite.xml', '-p': '5060', '-i': '127.0.0.4', '-timeout': '20s', '-mi': '127.0.0.4', '-s': 'sipp'},
'ordered-args': ['-timeout_error', '-key', 'dest', '18005556666'] }

hangup-monitor:
ids: [ '1', ]

http-server:
port: 8087
root-directory: 'tests/channels/pjsip/stir_shaken/webroot'


ami-config:
-
type: 'headermatch'
id: '0'
conditions:
match:
Event: 'UserEvent'
UserEvent: 'TestResult'
requirements:
match:
result: 'invalid_or_no_callerid'
count: '1'

properties:
dependencies:
- asterisk : 'res_pjsip'
- asterisk : 'res_stir_shaken'
tags:
- pjsip
- stir_shaken
1 change: 1 addition & 0 deletions tests/channels/pjsip/stir_shaken/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ tests:
- test: 'stir_shaken_sig_fail'
- test: 'stir_shaken_acl_fail'
- test: 'stir_shaken_fail_return_reason'
- test: 'stir_shaken_anon_callerid'

0 comments on commit 0631c83

Please sign in to comment.