From de97a5d8ac50642fa10ac96eddaef0d65ffe42a8 Mon Sep 17 00:00:00 2001 From: George Joseph Date: Wed, 5 Feb 2025 11:23:50 -0700 Subject: [PATCH] pjsip/stir_shaken: Add test for invalid or missing callerid. --- .../configs/ast1/extensions.conf | 4 + .../configs/ast1/pjsip.conf | 29 +++++++ .../configs/ast1/stir_shaken.conf | 25 ++++++ .../files/ast1/astetcdir/stir/SPAST1-cert.pem | 1 + .../files/ast1/astetcdir/stir/SPAST1-key.pem | 1 + .../files/ast1/astetcdir/stir/astdev-ca.crt | 1 + .../keys/stir_shaken/cache/.gitkeep | 0 .../stir_shaken_anon_callerid/sipp/invite.xml | 86 +++++++++++++++++++ .../test-config.yaml | 60 +++++++++++++ tests/channels/pjsip/stir_shaken/tests.yaml | 1 + 10 files changed, 208 insertions(+) create mode 100644 tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/configs/ast1/extensions.conf create mode 100644 tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/configs/ast1/pjsip.conf create mode 100644 tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/configs/ast1/stir_shaken.conf create mode 120000 tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/files/ast1/astetcdir/stir/SPAST1-cert.pem create mode 120000 tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/files/ast1/astetcdir/stir/SPAST1-key.pem create mode 120000 tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/files/ast1/astetcdir/stir/astdev-ca.crt create mode 100644 tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/files/ast1/astvarlibdir/keys/stir_shaken/cache/.gitkeep create mode 100644 tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/sipp/invite.xml create mode 100644 tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/test-config.yaml diff --git a/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/configs/ast1/extensions.conf b/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/configs/ast1/extensions.conf new file mode 100644 index 000000000..2ce88a757 --- /dev/null +++ b/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/configs/ast1/extensions.conf @@ -0,0 +1,4 @@ +[default] +exten => _X.,1,Answer() + same => n,UserEvent(TestResult, result: ${STIR_SHAKEN(0,verify_result)}) + same => n,Hangup() diff --git a/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/configs/ast1/pjsip.conf b/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/configs/ast1/pjsip.conf new file mode 100644 index 000000000..9bf9b7a0e --- /dev/null +++ b/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/configs/ast1/pjsip.conf @@ -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 + diff --git a/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/configs/ast1/stir_shaken.conf b/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/configs/ast1/stir_shaken.conf new file mode 100644 index 000000000..e4e6e2f37 --- /dev/null +++ b/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/configs/ast1/stir_shaken.conf @@ -0,0 +1,25 @@ + +[verification] +load_system_certs = no +ca_file=<>/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 diff --git a/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/files/ast1/astetcdir/stir/SPAST1-cert.pem b/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/files/ast1/astetcdir/stir/SPAST1-cert.pem new file mode 120000 index 000000000..1ed2770ab --- /dev/null +++ b/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/files/ast1/astetcdir/stir/SPAST1-cert.pem @@ -0,0 +1 @@ +../../../../../keys/SPAST1/SPAST1-cert.pem \ No newline at end of file diff --git a/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/files/ast1/astetcdir/stir/SPAST1-key.pem b/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/files/ast1/astetcdir/stir/SPAST1-key.pem new file mode 120000 index 000000000..00badbfbf --- /dev/null +++ b/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/files/ast1/astetcdir/stir/SPAST1-key.pem @@ -0,0 +1 @@ +../../../../../keys/SPAST1/SPAST1-key.pem \ No newline at end of file diff --git a/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/files/ast1/astetcdir/stir/astdev-ca.crt b/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/files/ast1/astetcdir/stir/astdev-ca.crt new file mode 120000 index 000000000..dbc156d62 --- /dev/null +++ b/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/files/ast1/astetcdir/stir/astdev-ca.crt @@ -0,0 +1 @@ +../../../../../keys/astdev-ca.crt \ No newline at end of file diff --git a/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/files/ast1/astvarlibdir/keys/stir_shaken/cache/.gitkeep b/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/files/ast1/astvarlibdir/keys/stir_shaken/cache/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/sipp/invite.xml b/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/sipp/invite.xml new file mode 100644 index 000000000..a61334021 --- /dev/null +++ b/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/sipp/invite.xml @@ -0,0 +1,86 @@ + + + + + + ;tag=[call_number] + To: + Call-ID: [call_id] + CSeq: 1 INVITE + Max-Forwards: 70 + Contact: + 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 + ]]> + + + + + + + + + + + + + + + + + + + + + + + + Content-Length: 0 + + ]]> + + + diff --git a/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/test-config.yaml b/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/test-config.yaml new file mode 100644 index 000000000..002e77bcb --- /dev/null +++ b/tests/channels/pjsip/stir_shaken/stir_shaken_anon_callerid/test-config.yaml @@ -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 diff --git a/tests/channels/pjsip/stir_shaken/tests.yaml b/tests/channels/pjsip/stir_shaken/tests.yaml index 480bcfa34..497c67082 100644 --- a/tests/channels/pjsip/stir_shaken/tests.yaml +++ b/tests/channels/pjsip/stir_shaken/tests.yaml @@ -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'