From 5dc37b7886b896db5edeae968e133f7ab03d6193 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Wed, 14 Jul 2021 15:23:22 +0200 Subject: [PATCH] TT#116101 bin/generate_test_tt2.py improve subs rules * Makefile: add missing test_generate_test rule * remove yaml.dump and build directly the simple YAML output ourselfs. It was generating strange indentation even with indent=None with using [% %] for some cases Change-Id: Iacf927cf21b5d127c625168a049d6a1bd9606fc3 --- Makefile | 2 +- bin/generate_test_tt2.py | 167 ++++++++++++--- .../auth_fail/sipp_scenario00_test.yml.tt2 | 11 +- .../incoming_foreign_dom/scenario_ids.yml | 29 +++ .../incoming_foreign_dom/sipp_scenario00.msg | 138 +++++++++++++ .../sipp_scenario00_test.yml.tt2 | 51 +++++ .../sipp_scenario_responder00.msg | 119 +++++++++++ .../sipp_scenario_responder00_test.yml.tt2 | 41 ++++ tests/fixtures/incoming_hih/scenario_ids.yml | 48 +++++ .../fixtures/incoming_hih/sipp_scenario00.msg | 127 ++++++++++++ .../incoming_hih/sipp_scenario00_test.yml.tt2 | 45 ++++ .../sipp_scenario_responder01.msg | 122 +++++++++++ .../sipp_scenario_responder01_test.yml.tt2 | 44 ++++ .../invite_redirect_tel_uri/scenario_ids.yml | 55 +++++ .../sipp_scenario00.msg | 193 ++++++++++++++++++ .../sipp_scenario00_test.yml.tt2 | 58 ++++++ .../sipp_scenario_responder00.msg | 59 ++++++ .../sipp_scenario_responder00_test.yml.tt2 | 28 +++ .../sipp_scenario_responder01.msg | 134 ++++++++++++ .../sipp_scenario_responder01_test.yml.tt2 | 44 ++++ tests/fixtures/mix/scenario_ids.yml | 81 ++++++++ tests/fixtures/mix/sipp_scenario00.msg | 59 ++++++ .../fixtures/mix/sipp_scenario00_test.yml.tt2 | 15 ++ tests/fixtures/programs.py | 4 +- tests/test_generate_test_tt2.py | 126 +++++++++++- 25 files changed, 1750 insertions(+), 50 deletions(-) create mode 100644 tests/fixtures/incoming_foreign_dom/scenario_ids.yml create mode 100644 tests/fixtures/incoming_foreign_dom/sipp_scenario00.msg create mode 100644 tests/fixtures/incoming_foreign_dom/sipp_scenario00_test.yml.tt2 create mode 100644 tests/fixtures/incoming_foreign_dom/sipp_scenario_responder00.msg create mode 100644 tests/fixtures/incoming_foreign_dom/sipp_scenario_responder00_test.yml.tt2 create mode 100644 tests/fixtures/incoming_hih/scenario_ids.yml create mode 100644 tests/fixtures/incoming_hih/sipp_scenario00.msg create mode 100644 tests/fixtures/incoming_hih/sipp_scenario00_test.yml.tt2 create mode 100644 tests/fixtures/incoming_hih/sipp_scenario_responder01.msg create mode 100644 tests/fixtures/incoming_hih/sipp_scenario_responder01_test.yml.tt2 create mode 100644 tests/fixtures/invite_redirect_tel_uri/scenario_ids.yml create mode 100644 tests/fixtures/invite_redirect_tel_uri/sipp_scenario00.msg create mode 100644 tests/fixtures/invite_redirect_tel_uri/sipp_scenario00_test.yml.tt2 create mode 100644 tests/fixtures/invite_redirect_tel_uri/sipp_scenario_responder00.msg create mode 100644 tests/fixtures/invite_redirect_tel_uri/sipp_scenario_responder00_test.yml.tt2 create mode 100644 tests/fixtures/invite_redirect_tel_uri/sipp_scenario_responder01.msg create mode 100644 tests/fixtures/invite_redirect_tel_uri/sipp_scenario_responder01_test.yml.tt2 create mode 100644 tests/fixtures/mix/scenario_ids.yml create mode 100644 tests/fixtures/mix/sipp_scenario00.msg create mode 100644 tests/fixtures/mix/sipp_scenario00_test.yml.tt2 diff --git a/Makefile b/Makefile index a06c3bbe..9ae33d95 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,6 @@ test_generate_test_tt2: tests/test_generate_test_tt2.py pytest-3 --junitxml=${RESULTS}/$(@).xml $(<) # run this in parallel!! -j is your friend -test: $(TESTS) test_check test_detect_network +test: $(TESTS) test_check test_detect_network test_generate_test_tt2 .PHONY: all $(TESTS) diff --git a/bin/generate_test_tt2.py b/bin/generate_test_tt2.py index 775419b6..5ee5e111 100755 --- a/bin/generate_test_tt2.py +++ b/bin/generate_test_tt2.py @@ -18,18 +18,19 @@ # On Debian systems, the complete text of the GNU General # Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". # +import sys from pathlib import Path import os import logging import re import argparse import subprocess -from yaml import load, dump +from yaml import load try: - from yaml import CLoader as Loader, CDumper as Dumper + from yaml import CLoader as Loader except ImportError: - from yaml import Loader, Dumper + from yaml import Loader def load_yaml(filepath): @@ -69,7 +70,7 @@ def load_msg(filepath): def is_zero(matchobj): if matchobj.group(1) == "0": return ": 0" - return r": \\d+" + return r": \d+" class Generator: @@ -89,25 +90,105 @@ class Generator: def generate_rules(self, ids): rules = [] id_dom = ids["domains"][0] + server_ip = ids["server_ip"] - def add_sip_username(val, tt): + def sip_rule(subs, tt, field): + str_val = str(subs[field]) + if str_val.startswith("00"): + r = ( + r"(sip|tel):{}([^\d])".format(subs[field]), + r"\1:[% {}.{} %]\2".format(tt, field), + ) + rules.append(r) + logging.info("rule:[{0}]=>[{1}]".format(r[0], r[1])) + else: + rules.append( + ( + r"(sip|tel):(\\\+|00)?{}([^\d])".format(subs[field]), + r"\1:\2[% {}.{} %]\3".format(tt, field), + ) + ) + + def sdp_rule(val, tt): rules.append( - (r"]+)".format( + scen["ip"], scen["port"] + ), + r";socket=udp:[% {0}.ip %]:[% {0}.port %]\1".format(tt), ) + ) + sdp_rule(scen["ip"], f"{tt}.ip") + rules.append( + ( + r"^m=audio {} (.+)".format(scen["mport"]), + r"m=audio [% {}.mport %] \1".format(tt), + ) + ) + + # server_ip rules + rules.append( + ( + r";socket=(sip|udp):{}:5060".format(server_ip), + r";socket=\1:[% server_ip %]:5060", + ) + ) + rules.append( + (r"sip:([^@]+@){}".format(server_ip), r"sip:\1[% server_ip %]") + ) + rules.append((r"sip:{}".format(server_ip), f"sip:[% server_ip %]")) + sdp_rule(server_ip, "server_ip") + + # priority on full match + for idx, scen in enumerate(ids["scenarios"]): + add_sip_full(scen, f"scenarios.{idx}") + add_socket(scen, f"scenarios.{idx}") + for jdx, resp in enumerate(scen["responders"]): + add_sip_full(resp, f"scenarios.{idx}.responders.{jdx}") + add_socket(resp, f"scenarios.{idx}.responders.{jdx}") + for idx, scen in enumerate(ids["scenarios"]): + add_sip(scen, f"scenarios.{idx}") + for jdx, resp in enumerate(scen["responders"]): + add_sip(resp, f"scenarios.{idx}.responders.{jdx}") + for key in ids[id_dom]: + sip_rule(ids[id_dom][key], f"{id_dom}.{key}", "phone_number") return rules def __init__(self, _hdrs, _msg, _ids): @@ -133,10 +214,11 @@ class Generator: def subst_common(self, line, hdr): rules = [] if hdr is None: - pass + rules.append((r"^a=rtcp:\d+", r"a=rtcp:\\d+")) + rules.append((r"^m=audio \d+ (.+)", r"m=audio \\d+ \1")) elif hdr in ["from", "to"]: - rules.append((r";tag=[^;]+", r";tag=[\\w-]+")) - elif hdr == "www-authenticate": + rules.append((r";tag=[^;>]+", r";tag=[\\w-]+")) + elif hdr in ["www-authenticate", "proxy-authenticate"]: rules.append((r"nonce=\"[^\"]+", 'nonce="[^"]+')) elif hdr in ["server", "user-agent"]: rules.append( @@ -147,6 +229,14 @@ class Generator: ) elif hdr == "content-length": rules.append((r":\s+(\d+)", is_zero)) + elif hdr == "record-route": + rules.append((r";did=[^;>]+", r";did=[^;]+")) + rules.append((r";ftag=[^;>]+", r";ftag=[^;]+")) + rules.append((r";aset=[^;>]+", r";aset=\\d+")) + rules.append((r";vsf=[^;>]+", r";vsf=[^;]+")) + elif hdr == "contact": + rules.append((r"expires=[1-9]\d*", r"expires=\\d+")) + rules.append((r";ngcpct=[^;>]+", r";ngcpct=[^;]+")) for rule in rules: line = re.sub(rule[0], rule[1], line, flags=re.IGNORECASE) return line @@ -156,33 +246,50 @@ class Generator: line = re.sub(rule[0], rule[1], line) return line + @classmethod + def escape_line(self, line): + for char in ["*", "+", "?", "(", ")", "[", "]"]: + line = line.replace(f"{char}", r"\{}".format(char)) + return line + def process_msg(self, msg): res = [] for line in msg: + line = line.replace("\n", "") + # escape special characters + line = self.escape_line(line) ok, hdr = self.filter_hdr(line) if ok: continue - l_common = self.subst_common(line, hdr) - l_ids = self.subst_ids(l_common, hdr) - if line != l_ids: - logging.info("line:{} => {}".format(line, l_ids)) - l = l_ids.replace("\n", "") + l_ids = self.subst_ids(line, hdr) + l = self.subst_common(l_ids, hdr) + # remove empty lines if len(l) > 0: + if line != l: + logging.info("line:{} => {}".format(line, l)) res.append(l) return res - def __str__(self): - res = {"messages": []} + def run(self): + res = [] for msg in self.msgs: - res["messages"].append(self.process_msg(msg)) - return dump(res, Dumper=Dumper) + res.append(self.process_msg(msg)) + return res def main(args): msgs = load_msg(args.sipp_msg) ids = load_yaml(args.scen_ids) - g = Generator(Generator.get_filters(args), msgs, ids) - print(g) + gen = Generator(Generator.get_filters(args), msgs, ids) + print("messages:") + for msg in gen.run(): + sys.stdout.write("- - '") + sys.stdout.write(msg[0]) + sys.stdout.write("'\n") + for idx, line in enumerate(msg[1:]): + sys.stdout.write(" - '") + sys.stdout.write(line) + sys.stdout.write("'\n") if __name__ == "__main__": diff --git a/tests/fixtures/auth_fail/sipp_scenario00_test.yml.tt2 b/tests/fixtures/auth_fail/sipp_scenario00_test.yml.tt2 index cf8e5e78..93616700 100644 --- a/tests/fixtures/auth_fail/sipp_scenario00_test.yml.tt2 +++ b/tests/fixtures/auth_fail/sipp_scenario00_test.yml.tt2 @@ -1,36 +1,35 @@ messages: -- - SIP/2.0 401 Unauthorized +- - 'SIP/2.0 401 Unauthorized' - 'From: ;tag=[\w-]+' - 'To: ;tag=[\w-]+' - 'CSeq: 1 REGISTER' - 'WWW-Authenticate: Digest realm="auth-fail.scenarios.test", nonce="[^"]+"' - 'Server: Sipwise NGCP Proxy' - 'Content-Length: 0' -- - SIP/2.0 401 Unauthorized +- - 'SIP/2.0 401 Unauthorized' - 'From: ;tag=[\w-]+' - 'To: ;tag=[\w-]+' - 'CSeq: 2 REGISTER' - 'WWW-Authenticate: Digest realm="auth-fail.scenarios.test", nonce="[^"]+"' - 'Server: Sipwise NGCP Proxy' - 'Content-Length: 0' -- - SIP/2.0 401 Unauthorized +- - 'SIP/2.0 401 Unauthorized' - 'From: ;tag=[\w-]+' - 'To: ;tag=[\w-]+' - 'CSeq: 3 REGISTER' - 'WWW-Authenticate: Digest realm="auth-fail.scenarios.test", nonce="[^"]+"' - 'Server: Sipwise NGCP Proxy' - 'Content-Length: 0' -- - SIP/2.0 401 Unauthorized +- - 'SIP/2.0 401 Unauthorized' - 'From: ;tag=[\w-]+' - 'To: ;tag=[\w-]+' - 'CSeq: 4 REGISTER' - 'WWW-Authenticate: Digest realm="auth-fail.scenarios.test", nonce="[^"]+"' - 'Server: Sipwise NGCP Proxy' - 'Content-Length: 0' -- - SIP/2.0 403 Try again later +- - 'SIP/2.0 403 Try again later' - 'From: ;tag=[\w-]+' - 'To: ;tag=[\w-]+' - 'CSeq: 5 REGISTER' - 'Server: Sipwise NGCP LB' - 'Content-Length: 0' - diff --git a/tests/fixtures/incoming_foreign_dom/scenario_ids.yml b/tests/fixtures/incoming_foreign_dom/scenario_ids.yml new file mode 100644 index 00000000..39a83b25 --- /dev/null +++ b/tests/fixtures/incoming_foreign_dom/scenario_ids.yml @@ -0,0 +1,29 @@ +--- +customer_test: + id: '7' +domains: +- incoming_foreign_dom_scenarios_test +extra_info: {} +incoming_foreign_dom_scenarios_test: + testuser1003: + ac: '1' + cc: '43' + phone_number: '4311001' + sn: 1001 + uuid: ac5ec97a-82eb-4036-9171-430402ef901a +scenarios: +- devid: external + domain: incoming-foreign-dom.external.test + ip: 10.20.29.2 + mport: 45008 + port: 51604 + responders: + - domain: incoming-foreign-dom.scenarios.test + ip: 10.20.29.2 + mport: 45011 + port: 51605 + proto: udp + register: yes + username: testuser1003 + username: external +server_ip: 192.168.1.152 diff --git a/tests/fixtures/incoming_foreign_dom/sipp_scenario00.msg b/tests/fixtures/incoming_foreign_dom/sipp_scenario00.msg new file mode 100644 index 00000000..dd6a47c5 --- /dev/null +++ b/tests/fixtures/incoming_foreign_dom/sipp_scenario00.msg @@ -0,0 +1,138 @@ +----------------------------------------------- 2021-07-15 08:51:02.428206 +UDP message sent (590 bytes): + +INVITE sip:4311001@incoming-foreign-dom.scenarios.test SIP/2.0 +Via: SIP/2.0/UDP 10.20.29.2:51604;branch=z9hG4bK-42789-1-0 +From: ;tag=42789SIPpTag001 +To: +Call-ID: NGCP%incoming_foreign_dom%///1-42789@10.20.29.2 +CSeq: 1 INVITE +Contact: +Max-Forwards: 70 +Content-Type: application/sdp +Content-Length: 144 + +v=0 +o=user1 53655765 2353687637 IN IP4 10.20.29.2 +s=- +c=IN IP4 10.20.29.2 +t=0 0 +m=audio 45008 RTP/AVP 8 +a=rtpmap:8 PCMA/8000 +a=ptime:50 + +----------------------------------------------- 2021-07-15 08:51:02.428580 +UDP message received [348] bytes : + +SIP/2.0 100 Trying +Via: SIP/2.0/UDP 10.20.29.2:51604;branch=z9hG4bK-42789-1-0;rport=51604 +From: ;tag=42789SIPpTag001 +To: +Call-ID: NGCP%incoming_foreign_dom%///1-42789@10.20.29.2 +CSeq: 1 INVITE +Server: Sipwise NGCP LB 9.X +Content-Length: 0 + + +----------------------------------------------- 2021-07-15 08:51:02.465579 +UDP message received [355] bytes : + +SIP/2.0 101 Connecting +Via: SIP/2.0/UDP 10.20.29.2:51604;rport=51604;branch=z9hG4bK-42789-1-0 +From: ;tag=42789SIPpTag001 +To: +Call-ID: NGCP%incoming_foreign_dom%///1-42789@10.20.29.2 +CSeq: 1 INVITE +Server: Sipwise NGCP Proxy 9.X +Content-Length: 0 + + +----------------------------------------------- 2021-07-15 08:51:02.976069 +UDP message received [826] bytes : + +SIP/2.0 180 Ringing +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 10.20.29.2:51604;rport=51604;branch=z9hG4bK-42789-1-0 +From: ;tag=42789SIPpTag001 +To: ;tag=272DD5B6-60EFDAD6000CC9AB-C33E0700 +Call-ID: NGCP%incoming_foreign_dom%///1-42789@10.20.29.2 +CSeq: 1 INVITE +Content-Length: 0 +Contact: + + +----------------------------------------------- 2021-07-15 08:51:03.535318 +UDP message received [1048] bytes : + +SIP/2.0 200 OK +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 10.20.29.2:51604;rport=51604;branch=z9hG4bK-42789-1-0 +From: ;tag=42789SIPpTag001 +To: ;tag=272DD5B6-60EFDAD6000CC9AB-C33E0700 +Call-ID: NGCP%incoming_foreign_dom%///1-42789@10.20.29.2 +CSeq: 1 INVITE +Content-Type: application/sdp +Content-Length: 194 +Contact: + +v=0 +o=user1 53655765 2353687637 IN IP4 192.168.1.152 +s=- +c=IN IP4 192.168.1.152 +t=0 0 +m=audio 30020 RTP/AVP 8 +a=direction:both +a=rtpmap:8 PCMA/8000 +a=sendrecv +a=rtcp:30021 +a=ptime:50 + +----------------------------------------------- 2021-07-15 08:51:03.535591 +UDP message sent (816 bytes): + +ACK sip:ngcp-lb@192.168.1.152:5060;ngcpct=7369703a3132372e302e302e313a353038303b707278726f7574653d31 SIP/2.0 +Via: SIP/2.0/UDP 10.20.29.2:51604;branch=z9hG4bK-42789-1-6 +From: ;tag=42789SIPpTag001 +To: ;tag=272DD5B6-60EFDAD6000CC9AB-C33E0700 +Call-ID: NGCP%incoming_foreign_dom%///1-42789@10.20.29.2 +Route: , , +CSeq: 1 ACK +Contact: +Max-Forwards: 70 +Content-Length: 0 + + +----------------------------------------------- 2021-07-15 08:51:05.046181 +UDP message sent (817 bytes): + +BYE sip:ngcp-lb@192.168.1.152:5060;ngcpct=7369703a3132372e302e302e313a353038303b707278726f7574653d31 SIP/2.0 +Via: SIP/2.0/UDP 10.20.29.2:51604;branch=z9hG4bK-42789-1-10 +From: ;tag=42789SIPpTag001 +To: ;tag=272DD5B6-60EFDAD6000CC9AB-C33E0700 +Call-ID: NGCP%incoming_foreign_dom%///1-42789@10.20.29.2 +CSeq: 2 BYE +Contact: +Route: , , +Max-Forwards: 70 +Content-Length: 0 + + +----------------------------------------------- 2021-07-15 08:51:05.311928 +UDP message received [656] bytes : + +SIP/2.0 200 OK +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 10.20.29.2:51604;rport=51604;branch=z9hG4bK-42789-1-10 +From: ;tag=42789SIPpTag001 +To: ;tag=272DD5B6-60EFDAD6000CC9AB-C33E0700 +Call-ID: NGCP%incoming_foreign_dom%///1-42789@10.20.29.2 +CSeq: 2 BYE +Content-Length: 0 + + diff --git a/tests/fixtures/incoming_foreign_dom/sipp_scenario00_test.yml.tt2 b/tests/fixtures/incoming_foreign_dom/sipp_scenario00_test.yml.tt2 new file mode 100644 index 00000000..af6df5e2 --- /dev/null +++ b/tests/fixtures/incoming_foreign_dom/sipp_scenario00_test.yml.tt2 @@ -0,0 +1,51 @@ +messages: +- - 'SIP/2.0 100 Trying' + - 'From: ;tag=[\w-]+' + - 'To: ' + - 'CSeq: 1 INVITE' + - 'Server: Sipwise NGCP LB' + - 'Content-Length: 0' +- - 'SIP/2.0 101 Connecting' + - 'From: ;tag=[\w-]+' + - 'To: ' + - 'CSeq: 1 INVITE' + - 'Server: Sipwise NGCP Proxy' + - 'Content-Length: 0' +- - 'SIP/2.0 180 Ringing' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 1 INVITE' + - 'Content-Length: 0' + - 'Contact: ' +- - 'SIP/2.0 200 OK' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 1 INVITE' + - 'Content-Type: application/sdp' + - 'Content-Length: \d+' + - 'Contact: ' + - 'v=0' + - 'o=user1 \d+ \d+ IN IP4 [% server_ip %]' + - 's=-' + - 'c=IN IP4 [% server_ip %]' + - 't=0 0' + - 'm=audio \d+ RTP/AVP 8' + - 'a=direction:both' + - 'a=rtpmap:8 PCMA/8000' + - 'a=sendrecv' + - 'a=rtcp:\d+' + - 'a=ptime:50' +- - 'SIP/2.0 200 OK' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 2 BYE' + - 'Content-Length: 0' diff --git a/tests/fixtures/incoming_foreign_dom/sipp_scenario_responder00.msg b/tests/fixtures/incoming_foreign_dom/sipp_scenario_responder00.msg new file mode 100644 index 00000000..a5ec9485 --- /dev/null +++ b/tests/fixtures/incoming_foreign_dom/sipp_scenario_responder00.msg @@ -0,0 +1,119 @@ +----------------------------------------------- 2021-07-15 08:51:02.872542 +UDP message received [1329] bytes : + +INVITE sip:testuser1003@10.20.29.2:51605 SIP/2.0 +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bKc63a.dad31646d9243069d41eaf18e0ea40c9.0 +Via: SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bKc63a.c704fdbf31527c59c4c4b721bf9db25d.0 +Via: SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bK7Xluyaom;rport=5080 +From: ;tag=36A623DE-60EFDAD6000CCE2D-E96AC700 +To: +CSeq: 10 INVITE +Call-ID: NGCP%incoming_foreign_dom%///1-42789@10.20.29.2_b2b-1 +Max-Forwards: 69 +P-Asserted-Identity: +Content-Type: application/sdp +Content-Length: 194 +Contact: + +v=0 +o=user1 53655765 2353687637 IN IP4 192.168.1.152 +s=- +c=IN IP4 192.168.1.152 +t=0 0 +m=audio 30000 RTP/AVP 8 +a=rtpmap:8 PCMA/8000 +a=sendrecv +a=rtcp:30001 +a=ptime:50 +a=direction:both + +----------------------------------------------- 2021-07-15 08:51:02.876292 +UDP message sent (606 bytes): + +SIP/2.0 180 Ringing +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bKc63a.dad31646d9243069d41eaf18e0ea40c9.0, SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bKc63a.c704fdbf31527c59c4c4b721bf9db25d.0, SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bK7Xluyaom;rport=5080 +From: ;tag=36A623DE-60EFDAD6000CCE2D-E96AC700 +To: ;tag=42769SIPpTag011 +Call-ID: NGCP%incoming_foreign_dom%///1-42789@10.20.29.2_b2b-1 +CSeq: 10 INVITE +Contact: +Content-Length: 0 + + +----------------------------------------------- 2021-07-15 08:51:03.393142 +UDP message sent (1099 bytes): + +SIP/2.0 200 OK +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bKc63a.dad31646d9243069d41eaf18e0ea40c9.0, SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bKc63a.c704fdbf31527c59c4c4b721bf9db25d.0, SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bK7Xluyaom;rport=5080 +From: ;tag=36A623DE-60EFDAD6000CCE2D-E96AC700 +To: ;tag=42769SIPpTag011 +Call-ID: NGCP%incoming_foreign_dom%///1-42789@10.20.29.2_b2b-1 +CSeq: 10 INVITE +Record-Route: , , +Contact: +Content-Type: application/sdp +Content-Length: 144 + +v=0 +o=user1 53655765 2353687637 IN IP4 10.20.29.2 +s=- +c=IN IP4 10.20.29.2 +t=0 0 +m=audio 45011 RTP/AVP 8 +a=rtpmap:8 PCMA/8000 +a=ptime:50 + +----------------------------------------------- 2021-07-15 08:51:03.680095 +UDP message received [1032] bytes : + +ACK sip:10.20.29.2:51605;transport=UDP SIP/2.0 +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bKc63a.e3e6fa03bdec818d57a5e28017afd15b.0 +Via: SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bKc63a.b15de8a4e9cf8bebad5dd15718a014f8.0 +Via: SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bKxpnpVa0t;rport=5080 +From: ;tag=36A623DE-60EFDAD6000CCE2D-E96AC700 +To: ;tag=42769SIPpTag011 +CSeq: 10 ACK +Call-ID: NGCP%incoming_foreign_dom%///1-42789@10.20.29.2_b2b-1 +Max-Forwards: 68 +Content-Length: 0 +Contact: + + +----------------------------------------------- 2021-07-15 08:51:05.191460 +UDP message received [1017] bytes : + +BYE sip:10.20.29.2:51605;transport=UDP SIP/2.0 +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bKd63a.294ccd7e93a7535d7a8eed15a443369f.0 +Via: SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bKd63a.f704b8bdd7cf6848e455cb233b0b8dec.0 +Via: SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bKiz33EaxZ;rport=5080 +From: ;tag=36A623DE-60EFDAD6000CCE2D-E96AC700 +To: ;tag=42769SIPpTag011 +CSeq: 11 BYE +Call-ID: NGCP%incoming_foreign_dom%///1-42789@10.20.29.2_b2b-1 +Max-Forwards: 68 +P-Asserted-Identity: +Content-Length: 0 + + +----------------------------------------------- 2021-07-15 08:51:05.191665 +UDP message sent (602 bytes): + +SIP/2.0 200 OK +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bKd63a.294ccd7e93a7535d7a8eed15a443369f.0, SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bKd63a.f704b8bdd7cf6848e455cb233b0b8dec.0, SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bKiz33EaxZ;rport=5080 +From: ;tag=36A623DE-60EFDAD6000CCE2D-E96AC700 +To: ;tag=42769SIPpTag011 +Call-ID: NGCP%incoming_foreign_dom%///1-42789@10.20.29.2_b2b-1 +CSeq: 11 BYE +Contact: +Content-Length: 0 + + diff --git a/tests/fixtures/incoming_foreign_dom/sipp_scenario_responder00_test.yml.tt2 b/tests/fixtures/incoming_foreign_dom/sipp_scenario_responder00_test.yml.tt2 new file mode 100644 index 00000000..f6dc7ce5 --- /dev/null +++ b/tests/fixtures/incoming_foreign_dom/sipp_scenario_responder00_test.yml.tt2 @@ -0,0 +1,41 @@ +messages: +- - 'INVITE sip:[% scenarios.0.responders.0.username %]@[% scenarios.0.responders.0.ip %]:[% scenarios.0.responders.0.port %] SIP/2.0' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ' + - 'CSeq: 10 INVITE' + - 'P-Asserted-Identity: ' + - 'Content-Type: application/sdp' + - 'Content-Length: \d+' + - 'Contact: ' + - 'v=0' + - 'o=user1 \d+ \d+ IN IP4 [% server_ip %]' + - 's=-' + - 'c=IN IP4 [% server_ip %]' + - 't=0 0' + - 'm=audio \d+ RTP/AVP 8' + - 'a=rtpmap:8 PCMA/8000' + - 'a=sendrecv' + - 'a=rtcp:\d+' + - 'a=ptime:50' + - 'a=direction:both' +- - 'ACK sip:[% scenarios.0.responders.0.ip %]:[% scenarios.0.responders.0.port %];transport=UDP SIP/2.0' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 10 ACK' + - 'Content-Length: 0' + - 'Contact: ' +- - 'BYE sip:[% scenarios.0.responders.0.ip %]:[% scenarios.0.responders.0.port %];transport=UDP SIP/2.0' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 11 BYE' + - 'P-Asserted-Identity: ' + - 'Content-Length: 0' diff --git a/tests/fixtures/incoming_hih/scenario_ids.yml b/tests/fixtures/incoming_hih/scenario_ids.yml new file mode 100644 index 00000000..2e5928f3 --- /dev/null +++ b/tests/fixtures/incoming_hih/scenario_ids.yml @@ -0,0 +1,48 @@ +--- +customer_test: + id: "7" +domains: + - incoming_hih_scenarios_test +extra_info: {} +incoming_hih_scenarios_test: + testuser1002: + ac: "1" + cc: "43" + phone_number: "4311000" + sn: 1000 + uuid: 23fca2a7-eafd-40c1-82b7-f36208838cff + testuser1003: + ac: "1" + cc: "43" + phone_number: "4311001" + sn: 1001 + uuid: e8ce3151-f4d4-46e4-9e6a-90f785864033 +peer_incoming_hih_host0: + id: "71" + ip: 172.30.1.2 + mport: 46003 + port: 52602 +scenarios: + - devid: "004321001" + domain: incoming-hih.host0.peer.scenarios.test + ip: 172.30.1.2 + mport: 46003 + peer: peer_incoming_hih_host0 + port: 52602 + responders: + - domain: incoming-hih.scenarios.test + ip: 10.20.29.2 + mport: 45003 + port: 51602 + proto: udp + register: no + username: testuser1003 + - domain: incoming-hih.scenarios.test + ip: 10.20.29.2 + mport: 45006 + port: 51603 + proto: udp + register: yes + username: testuser1002 + username: "004321001" +server_ip: 192.168.1.152 diff --git a/tests/fixtures/incoming_hih/sipp_scenario00.msg b/tests/fixtures/incoming_hih/sipp_scenario00.msg new file mode 100644 index 00000000..c10ac076 --- /dev/null +++ b/tests/fixtures/incoming_hih/sipp_scenario00.msg @@ -0,0 +1,127 @@ +----------------------------------------------- 2021-07-15 18:07:54.574155 +UDP message sent (760 bytes): + +INVITE sip:4311001@incoming-hih.scenarios.test SIP/2.0 +Via: SIP/2.0/UDP 172.30.1.2:52602;branch=z9hG4bK-445952-1-0 +From: ;tag=445952SIPpTag001 +To: +Call-ID: NGCP%incoming_hih%///1-445952@172.30.1.2 +CSeq: 1 INVITE +Contact: +History-Info: ;index=1 +History-Info: ;index=1.1 +Max-Forwards: 70 +Content-Type: application/sdp +Content-Length: 144 + +v=0 +o=user1 53655765 2353687637 IN IP4 172.30.1.2 +s=- +c=IN IP4 172.30.1.2 +t=0 0 +m=audio 46003 RTP/AVP 8 +a=rtpmap:8 PCMA/8000 +a=ptime:50 + +----------------------------------------------- 2021-07-15 18:07:54.582804 +UDP message received [340] bytes : + +SIP/2.0 100 Trying +Via: SIP/2.0/UDP 172.30.1.2:52602;branch=z9hG4bK-445952-1-0;rport=52602 +From: ;tag=445952SIPpTag001 +To: +Call-ID: NGCP%incoming_hih%///1-445952@172.30.1.2 +CSeq: 1 INVITE +Server: Sipwise NGCP LB 9.X +Content-Length: 0 + + +----------------------------------------------- 2021-07-15 18:07:56.332690 +UDP message received [769] bytes : + +SIP/2.0 180 Ringing +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 172.30.1.2:52602;rport=52602;branch=z9hG4bK-445952-1-0 +From: ;tag=445952SIPpTag001 +To: ;tag=7DFA4E86-60F05D5B00013184-C33E0700 +Call-ID: NGCP%incoming_hih%///1-445952@172.30.1.2 +CSeq: 1 INVITE +Content-Length: 0 +Contact: + + +----------------------------------------------- 2021-07-15 18:07:57.005211 +UDP message received [991] bytes : + +SIP/2.0 200 OK +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 172.30.1.2:52602;rport=52602;branch=z9hG4bK-445952-1-0 +From: ;tag=445952SIPpTag001 +To: ;tag=7DFA4E86-60F05D5B00013184-C33E0700 +Call-ID: NGCP%incoming_hih%///1-445952@172.30.1.2 +CSeq: 1 INVITE +Content-Type: application/sdp +Content-Length: 194 +Contact: + +v=0 +o=user1 53655765 2353687637 IN IP4 192.168.1.152 +s=- +c=IN IP4 192.168.1.152 +t=0 0 +m=audio 30154 RTP/AVP 8 +a=rtpmap:8 PCMA/8000 +a=sendrecv +a=rtcp:30155 +a=ptime:50 +a=direction:both + +----------------------------------------------- 2021-07-15 18:07:57.005538 +UDP message sent (760 bytes): + +ACK sip:ngcp-lb@192.168.1.152:5060;ngcpct=7369703a3132372e302e302e313a353038303b707278726f7574653d31 SIP/2.0 +Via: SIP/2.0/UDP 172.30.1.2:52602;branch=z9hG4bK-445952-1-5 +From: ;tag=445952SIPpTag001 +To: ;tag=7DFA4E86-60F05D5B00013184-C33E0700 +Call-ID: NGCP%incoming_hih%///1-445952@172.30.1.2 +Route: , , +CSeq: 1 ACK +Contact: +Max-Forwards: 70 +Content-Length: 0 + + +----------------------------------------------- 2021-07-15 18:07:58.519503 +UDP message sent (760 bytes): + +BYE sip:ngcp-lb@192.168.1.152:5060;ngcpct=7369703a3132372e302e302e313a353038303b707278726f7574653d31 SIP/2.0 +Via: SIP/2.0/UDP 172.30.1.2:52602;branch=z9hG4bK-445952-1-9 +From: ;tag=445952SIPpTag001 +To: ;tag=7DFA4E86-60F05D5B00013184-C33E0700 +Call-ID: NGCP%incoming_hih%///1-445952@172.30.1.2 +CSeq: 2 BYE +Contact: +Route: , , +Max-Forwards: 70 +Content-Length: 0 + + +----------------------------------------------- 2021-07-15 18:07:58.919636 +UDP message received [639] bytes : + +SIP/2.0 200 OK +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 172.30.1.2:52602;rport=52602;branch=z9hG4bK-445952-1-9 +From: ;tag=445952SIPpTag001 +To: ;tag=7DFA4E86-60F05D5B00013184-C33E0700 +Call-ID: NGCP%incoming_hih%///1-445952@172.30.1.2 +CSeq: 2 BYE +Content-Length: 0 + + diff --git a/tests/fixtures/incoming_hih/sipp_scenario00_test.yml.tt2 b/tests/fixtures/incoming_hih/sipp_scenario00_test.yml.tt2 new file mode 100644 index 00000000..f7fe4ad0 --- /dev/null +++ b/tests/fixtures/incoming_hih/sipp_scenario00_test.yml.tt2 @@ -0,0 +1,45 @@ +messages: +- - 'SIP/2.0 100 Trying' + - 'From: ;tag=[\w-]+' + - 'To: ' + - 'CSeq: 1 INVITE' + - 'Server: Sipwise NGCP LB' + - 'Content-Length: 0' +- - 'SIP/2.0 180 Ringing' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 1 INVITE' + - 'Content-Length: 0' + - 'Contact: ' +- - 'SIP/2.0 200 OK' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 1 INVITE' + - 'Content-Type: application/sdp' + - 'Content-Length: \d+' + - 'Contact: ' + - 'v=0' + - 'o=user1 \d+ \d+ IN IP4 [% server_ip %]' + - 's=-' + - 'c=IN IP4 [% server_ip %]' + - 't=0 0' + - 'm=audio \d+ RTP/AVP 8' + - 'a=rtpmap:8 PCMA/8000' + - 'a=sendrecv' + - 'a=rtcp:\d+' + - 'a=ptime:50' + - 'a=direction:both' +- - 'SIP/2.0 200 OK' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 2 BYE' + - 'Content-Length: 0' diff --git a/tests/fixtures/incoming_hih/sipp_scenario_responder01.msg b/tests/fixtures/incoming_hih/sipp_scenario_responder01.msg new file mode 100644 index 00000000..91bf375d --- /dev/null +++ b/tests/fixtures/incoming_hih/sipp_scenario_responder01.msg @@ -0,0 +1,122 @@ +----------------------------------------------- 2021-07-15 18:07:56.121117 +UDP message received [1602] bytes : + +INVITE sip:testuser1002@10.20.29.2:51603;cause=302 SIP/2.0 +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bK467f.0f93f15a9f0fd946ceb67be665d40e96.0 +Via: SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bK467f.2bae458c4adab3696bf3c8b719279a54.0 +Via: SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bKrxc~warC;rport=5080 +From: ;tag=429E5A36-60F05D5C000060E1-E96AC700 +To: +CSeq: 10 INVITE +Call-ID: NGCP%incoming_hih%///1-445952@172.30.1.2_b2b-1 +Max-Forwards: 69 +History-Info: ;index=1 +History-Info: ;index=1.1 +History-Info: ;index=1.1.1 +P-Asserted-Identity: +Content-Type: application/sdp +Content-Length: 194 +Contact: + +v=0 +o=user1 53655765 2353687637 IN IP4 192.168.1.152 +s=- +c=IN IP4 192.168.1.152 +t=0 0 +m=audio 30136 RTP/AVP 8 +a=rtpmap:8 PCMA/8000 +a=sendrecv +a=rtcp:30137 +a=ptime:50 +a=direction:both + +----------------------------------------------- 2021-07-15 18:07:56.121512 +UDP message sent (586 bytes): + +SIP/2.0 180 Ringing +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bK467f.0f93f15a9f0fd946ceb67be665d40e96.0, SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bK467f.2bae458c4adab3696bf3c8b719279a54.0, SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bKrxc~warC;rport=5080 +From: ;tag=429E5A36-60F05D5C000060E1-E96AC700 +To: ;tag=445932SIPpTag011 +Call-ID: NGCP%incoming_hih%///1-445952@172.30.1.2_b2b-1 +CSeq: 10 INVITE +Contact: +Content-Length: 0 + + +----------------------------------------------- 2021-07-15 18:07:56.635454 +UDP message sent (1077 bytes): + +SIP/2.0 200 OK +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bK467f.0f93f15a9f0fd946ceb67be665d40e96.0, SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bK467f.2bae458c4adab3696bf3c8b719279a54.0, SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bKrxc~warC;rport=5080 +From: ;tag=429E5A36-60F05D5C000060E1-E96AC700 +To: ;tag=445932SIPpTag011 +Call-ID: NGCP%incoming_hih%///1-445952@172.30.1.2_b2b-1 +CSeq: 10 INVITE +Record-Route: , , +Contact: +Content-Type: application/sdp +Content-Length: 144 + +v=0 +o=user1 53655765 2353687637 IN IP4 10.20.29.2 +s=- +c=IN IP4 10.20.29.2 +t=0 0 +m=audio 45006 RTP/AVP 8 +a=rtpmap:8 PCMA/8000 +a=ptime:50 + +----------------------------------------------- 2021-07-15 18:07:57.190124 +UDP message received [1012] bytes : + +ACK sip:10.20.29.2:51603;transport=UDP SIP/2.0 +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bK467f.d686a83f8f593d099bf370a05d5401fd.0 +Via: SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bK467f.290ecd974b940cb69561e51783d97e63.0 +Via: SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bKikhEvaYG;rport=5080 +From: ;tag=429E5A36-60F05D5C000060E1-E96AC700 +To: ;tag=445932SIPpTag011 +CSeq: 10 ACK +Call-ID: NGCP%incoming_hih%///1-445952@172.30.1.2_b2b-1 +Max-Forwards: 68 +Content-Length: 0 +Contact: + + +----------------------------------------------- 2021-07-15 18:07:58.786292 +UDP message received [991] bytes : + +BYE sip:10.20.29.2:51603;transport=UDP SIP/2.0 +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bK567f.f0abce14d389c1e60e149ff153fef7fc.0 +Via: SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bK567f.8a85f33f024324b9038056f3e50757ba.0 +Via: SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bKtTK.6a~2;rport=5080 +From: ;tag=429E5A36-60F05D5C000060E1-E96AC700 +To: ;tag=445932SIPpTag011 +CSeq: 11 BYE +Call-ID: NGCP%incoming_hih%///1-445952@172.30.1.2_b2b-1 +Max-Forwards: 68 +P-Asserted-Identity: +Content-Length: 0 + + +----------------------------------------------- 2021-07-15 18:07:58.786634 +UDP message sent (582 bytes): + +SIP/2.0 200 OK +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bK567f.f0abce14d389c1e60e149ff153fef7fc.0, SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bK567f.8a85f33f024324b9038056f3e50757ba.0, SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bKtTK.6a~2;rport=5080 +From: ;tag=429E5A36-60F05D5C000060E1-E96AC700 +To: ;tag=445932SIPpTag011 +Call-ID: NGCP%incoming_hih%///1-445952@172.30.1.2_b2b-1 +CSeq: 11 BYE +Contact: +Content-Length: 0 + + diff --git a/tests/fixtures/incoming_hih/sipp_scenario_responder01_test.yml.tt2 b/tests/fixtures/incoming_hih/sipp_scenario_responder01_test.yml.tt2 new file mode 100644 index 00000000..47dd41dc --- /dev/null +++ b/tests/fixtures/incoming_hih/sipp_scenario_responder01_test.yml.tt2 @@ -0,0 +1,44 @@ +messages: +- - 'INVITE sip:[% scenarios.0.responders.1.username %]@[% scenarios.0.responders.1.ip %]:[% scenarios.0.responders.1.port %];cause=302 SIP/2.0' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ' + - 'CSeq: 10 INVITE' + - 'History-Info: ;index=1' + - 'History-Info: ;index=1.1' + - 'History-Info: ;index=1.1.1' + - 'P-Asserted-Identity: ' + - 'Content-Type: application/sdp' + - 'Content-Length: \d+' + - 'Contact: ' + - 'v=0' + - 'o=user1 \d+ \d+ IN IP4 [% server_ip %]' + - 's=-' + - 'c=IN IP4 [% server_ip %]' + - 't=0 0' + - 'm=audio \d+ RTP/AVP 8' + - 'a=rtpmap:8 PCMA/8000' + - 'a=sendrecv' + - 'a=rtcp:\d+' + - 'a=ptime:50' + - 'a=direction:both' +- - 'ACK sip:[% scenarios.0.responders.1.ip %]:[% scenarios.0.responders.1.port %];transport=UDP SIP/2.0' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 10 ACK' + - 'Content-Length: 0' + - 'Contact: ' +- - 'BYE sip:[% scenarios.0.responders.1.ip %]:[% scenarios.0.responders.1.port %];transport=UDP SIP/2.0' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 11 BYE' + - 'P-Asserted-Identity: ' + - 'Content-Length: 0' diff --git a/tests/fixtures/invite_redirect_tel_uri/scenario_ids.yml b/tests/fixtures/invite_redirect_tel_uri/scenario_ids.yml new file mode 100644 index 00000000..b35cf6f3 --- /dev/null +++ b/tests/fixtures/invite_redirect_tel_uri/scenario_ids.yml @@ -0,0 +1,55 @@ +--- +customer_test: + id: '7' +domains: +- invite_redirect_tel_uri_scenarios_test +extra_info: {} +invite_redirect_tel_uri_scenarios_test: + testuser1000: + ac: '1' + cc: '43' + phone_number: '4311129' + sn: 1129 + uuid: f47f015d-5d94-478e-b5f6-e78eb51a5833 + testuser1001: + ac: '1' + cc: '43' + phone_number: '4311130' + sn: 1130 + uuid: d2fc87e1-6553-42a5-94df-580429a63a92 + testuser1002: + ac: '1' + cc: '43' + phone_number: '4311131' + sn: 1131 + uuid: 01776d5c-4192-438a-a661-6e5dfc165811 +scenarios: +- devid: testuser1000 + domain: invite-redirect-tel-uri.scenarios.test + ip: 10.20.30.1 + mport: 46077 + port: 52633 + responders: + - domain: invite-redirect-tel-uri.scenarios.test + ip: 10.20.30.1 + mport: 46080 + port: 52634 + proto: udp + register: yes + username: testuser1001 + - domain: invite-redirect-tel-uri.scenarios.test + ip: 10.20.30.1 + mport: 46083 + port: 52635 + proto: udp + register: yes + username: testuser1002 + - domain: invite-redirect-tel-uri.scenarios.test + ip: 10.20.30.1 + mport: 46086 + port: 52636 + proto: udp + register: no + username: testuser1000 + username: testuser1000 +server_ip: 192.168.1.152 diff --git a/tests/fixtures/invite_redirect_tel_uri/sipp_scenario00.msg b/tests/fixtures/invite_redirect_tel_uri/sipp_scenario00.msg new file mode 100644 index 00000000..ccf385ff --- /dev/null +++ b/tests/fixtures/invite_redirect_tel_uri/sipp_scenario00.msg @@ -0,0 +1,193 @@ +----------------------------------------------- 2021-07-05 18:05:28.222319 +UDP message sent (646 bytes): + +INVITE sip:testuser1001@invite-redirect-tel-uri.scenarios.test SIP/2.0 +Via: SIP/2.0/UDP 10.20.30.1:52633;branch=z9hG4bK-65445-1-0 +From: ;tag=65445SIPpTag001 +To: +Diversion: ;reason=unconditional;privacy=off;counter=1 +P-Asserted-Identity: +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1 +CSeq: 1 INVITE +Contact: +Max-Forwards: 70 +Content-Type: application/sdp +Content-Length: 144 + +v=0 +o=user1 53655765 2353687637 IN IP4 10.20.30.1 +s=- +c=IN IP4 10.20.30.1 +t=0 0 +m=audio 46077 RTP/AVP 8 +a=rtpmap:8 PCMA/8000 +a=ptime:50 + +----------------------------------------------- 2021-07-05 18:05:28.223193 +UDP message received [281] bytes : + +SIP/2.0 100 Trying +Via: SIP/2.0/UDP 10.20.30.1:52633;branch=z9hG4bK-65445-1-0;rport=52633 +From: ;tag=65445SIPpTag001 +To: +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1 +CSeq: 1 INVITE +Server: Sipwise NGCP LB 9.X +Content-Length: 0 + + +----------------------------------------------- 2021-07-05 18:05:28.362496 +UDP message received [470] bytes : + +SIP/2.0 407 Proxy Authentication Required +Via: SIP/2.0/UDP 10.20.30.1:52633;rport=52633;branch=z9hG4bK-65445-1-0 +From: ;tag=65445SIPpTag001 +To: ;tag=95c37a12bff1a2c36d72bf8333176544.78550000 +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1 +CSeq: 1 INVITE +Proxy-Authenticate: Digest realm="invite-redirect-tel-uri.scenarios.test", nonce="YOMu9GDjLcjdbPZCCRRK37E3AHH865R4" +Server: Sipwise NGCP Proxy 9.X +Content-Length: 0 + + +----------------------------------------------- 2021-07-05 18:05:28.362816 +UDP message sent (452 bytes): + +ACK sip:testuser1001@invite-redirect-tel-uri.scenarios.test:5060 SIP/2.0 +Via: SIP/2.0/UDP 10.20.30.1:52633;rport=52633;branch=z9hG4bK-65445-1-0 +From: ;tag=65445SIPpTag001 +To: ;tag=95c37a12bff1a2c36d72bf8333176544.78550000 +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1 +CSeq: 1 ACK +Contact: +Max-Forwards: 70 +Content-Length: 0 + + +----------------------------------------------- 2021-07-05 18:05:28.869286 +UDP message sent (874 bytes): + +INVITE sip:testuser1001@invite-redirect-tel-uri.scenarios.test SIP/2.0 +Via: SIP/2.0/UDP 10.20.30.1:52633;branch=z9hG4bK-65445-1-5 +From: ;tag=65445SIPpTag001 +To: +Diversion: ;reason=unconditional;privacy=off;counter=1 +P-Asserted-Identity: +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1 +CSeq: 2 INVITE +Contact: +Max-Forwards: 70 +Proxy-Authorization: Digest username="testuser1000",realm="invite-redirect-tel-uri.scenarios.test",uri="sip:192.168.1.152:5060",nonce="YOMu9GDjLcjdbPZCCRRK37E3AHH865R4",response="8376a2cb472c33d21fc80f766d62e3f6",algorithm=MD5 +Content-Type: application/sdp +Content-Length: 144 + +v=0 +o=user1 53655765 2353687637 IN IP4 10.20.30.1 +s=- +c=IN IP4 10.20.30.1 +t=0 0 +m=audio 46077 RTP/AVP 8 +a=rtpmap:8 PCMA/8000 +a=ptime:50 + +----------------------------------------------- 2021-07-05 18:05:28.871797 +UDP message received [281] bytes : + +SIP/2.0 100 Trying +Via: SIP/2.0/UDP 10.20.30.1:52633;branch=z9hG4bK-65445-1-5;rport=52633 +From: ;tag=65445SIPpTag001 +To: +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1 +CSeq: 2 INVITE +Server: Sipwise NGCP LB 9.X +Content-Length: 0 + + +----------------------------------------------- 2021-07-05 18:05:31.648035 +UDP message received [922] bytes : + +SIP/2.0 180 Ringing +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 10.20.30.1:52633;rport=52633;branch=z9hG4bK-65445-1-5 +From: ;tag=65445SIPpTag001 +To: ;tag=3D64D403-60E32DCB00028282-9950C700 +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1 +CSeq: 2 INVITE +Content-Length: 0 +Contact: + + +----------------------------------------------- 2021-07-05 18:05:32.282912 +UDP message received [1144] bytes : + +SIP/2.0 200 OK +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 10.20.30.1:52633;rport=52633;branch=z9hG4bK-65445-1-5 +From: ;tag=65445SIPpTag001 +To: ;tag=3D64D403-60E32DCB00028282-9950C700 +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1 +CSeq: 2 INVITE +Content-Type: application/sdp +Content-Length: 194 +Contact: + +v=0 +o=user1 53655765 2353687637 IN IP4 192.168.1.152 +s=- +c=IN IP4 192.168.1.152 +t=0 0 +m=audio 31498 RTP/AVP 8 +a=direction:both +a=rtpmap:8 PCMA/8000 +a=sendrecv +a=rtcp:31499 +a=ptime:50 + +----------------------------------------------- 2021-07-05 18:05:32.283356 +UDP message sent (916 bytes): + +ACK sip:ngcp-lb@192.168.1.152:5060;ngcpct=7369703a3132372e302e302e313a353038303b707278726f7574653d31 SIP/2.0 +Via: SIP/2.0/UDP 10.20.30.1:52633;branch=z9hG4bK-65445-1-9 +From: ;tag=65445SIPpTag001 +To: ;tag=3D64D403-60E32DCB00028282-9950C700 +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1 +Route: , , +CSeq: 2 ACK +Contact: +Max-Forwards: 70 +Content-Length: 0 + + +----------------------------------------------- 2021-07-05 18:05:33.800329 +UDP message sent (871 bytes): + +BYE sip:ngcp-lb@192.168.1.152:5060;ngcpct=7369703a3132372e302e302e313a353038303b707278726f7574653d31 SIP/2.0 +Via: SIP/2.0/UDP 10.20.30.1:52633;branch=z9hG4bK-65445-1-13 +From: ;tag=65445SIPpTag001 +To: ;tag=3D64D403-60E32DCB00028282-9950C700 +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1 +CSeq: 3 BYE +Route: , , +Max-Forwards: 70 +Content-Length: 0 + + +----------------------------------------------- 2021-07-05 18:05:34.280748 +UDP message received [735] bytes : + +SIP/2.0 200 OK +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 10.20.30.1:52633;rport=52633;branch=z9hG4bK-65445-1-13 +From: ;tag=65445SIPpTag001 +To: ;tag=3D64D403-60E32DCB00028282-9950C700 +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1 +CSeq: 3 BYE +Content-Length: 0 + + diff --git a/tests/fixtures/invite_redirect_tel_uri/sipp_scenario00_test.yml.tt2 b/tests/fixtures/invite_redirect_tel_uri/sipp_scenario00_test.yml.tt2 new file mode 100644 index 00000000..c76944ff --- /dev/null +++ b/tests/fixtures/invite_redirect_tel_uri/sipp_scenario00_test.yml.tt2 @@ -0,0 +1,58 @@ +messages: +- - 'SIP/2.0 100 Trying' + - 'From: ;tag=[\w-]+' + - 'To: ' + - 'CSeq: 1 INVITE' + - 'Server: Sipwise NGCP LB' + - 'Content-Length: 0' +- - 'SIP/2.0 407 Proxy Authentication Required' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 1 INVITE' + - 'Proxy-Authenticate: Digest realm="invite-redirect-tel-uri.scenarios.test", nonce="[^"]+"' + - 'Server: Sipwise NGCP Proxy' + - 'Content-Length: 0' +- - 'SIP/2.0 100 Trying' + - 'From: ;tag=[\w-]+' + - 'To: ' + - 'CSeq: 2 INVITE' + - 'Server: Sipwise NGCP LB' + - 'Content-Length: 0' +- - 'SIP/2.0 180 Ringing' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 2 INVITE' + - 'Content-Length: 0' + - 'Contact: ' +- - 'SIP/2.0 200 OK' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 2 INVITE' + - 'Content-Type: application/sdp' + - 'Content-Length: \d+' + - 'Contact: ' + - 'v=0' + - 'o=user1 \d+ \d+ IN IP4 [% server_ip %]' + - 's=-' + - 'c=IN IP4 [% server_ip %]' + - 't=0 0' + - 'm=audio \d+ RTP/AVP 8' + - 'a=direction:both' + - 'a=rtpmap:8 PCMA/8000' + - 'a=sendrecv' + - 'a=rtcp:\d+' + - 'a=ptime:50' +- - 'SIP/2.0 200 OK' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 3 BYE' + - 'Content-Length: 0' diff --git a/tests/fixtures/invite_redirect_tel_uri/sipp_scenario_responder00.msg b/tests/fixtures/invite_redirect_tel_uri/sipp_scenario_responder00.msg new file mode 100644 index 00000000..43e91c01 --- /dev/null +++ b/tests/fixtures/invite_redirect_tel_uri/sipp_scenario_responder00.msg @@ -0,0 +1,59 @@ +----------------------------------------------- 2021-07-05 18:05:29.946856 +UDP message received [1341] bytes : + +INVITE sip:testuser1001@10.20.30.1:52634 SIP/2.0 +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bKca9b.e7fdf4aae72d511626ce9347414fc4e8.0 +Via: SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bKca9b.ce87f0bbfca37d50bdf5d834794573b9.0 +Via: SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bKD0a~Oaib;rport=5080 +From: ;tag=24430ECE-60E32DC9000C8803-9B7C7700 +To: +CSeq: 10 INVITE +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1_b2b-1 +Max-Forwards: 69 +P-Asserted-Identity: +Content-Type: application/sdp +Content-Length: 194 +Contact: + +v=0 +o=user1 53655765 2353687637 IN IP4 192.168.1.152 +s=- +c=IN IP4 192.168.1.152 +t=0 0 +m=audio 31486 RTP/AVP 8 +a=rtpmap:8 PCMA/8000 +a=sendrecv +a=rtcp:31487 +a=ptime:50 +a=direction:both + +----------------------------------------------- 2021-07-05 18:05:29.948518 +UDP message sent (739 bytes): + +SIP/2.0 302 Moved Temporarily +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bKca9b.e7fdf4aae72d511626ce9347414fc4e8.0, SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bKca9b.ce87f0bbfca37d50bdf5d834794573b9.0, SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bKD0a~Oaib;rport=5080 +From: ;tag=24430ECE-60E32DC9000C8803-9B7C7700 +To: ;tag=65405SIPpTag001 +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1_b2b-1 +CSeq: 10 INVITE +Contact: +Diversion: +Content-Length: 0 + + +----------------------------------------------- 2021-07-05 18:05:29.949358 +UDP message received [435] bytes : + +ACK sip:testuser1001@10.20.30.1:52634 SIP/2.0 +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bKca9b.e7fdf4aae72d511626ce9347414fc4e8.0 +From: ;tag=24430ECE-60E32DC9000C8803-9B7C7700 +To: ;tag=65405SIPpTag001 +CSeq: 10 ACK +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1_b2b-1 +Max-Forwards: 69 +Content-Length: 0 + + diff --git a/tests/fixtures/invite_redirect_tel_uri/sipp_scenario_responder00_test.yml.tt2 b/tests/fixtures/invite_redirect_tel_uri/sipp_scenario_responder00_test.yml.tt2 new file mode 100644 index 00000000..e015a951 --- /dev/null +++ b/tests/fixtures/invite_redirect_tel_uri/sipp_scenario_responder00_test.yml.tt2 @@ -0,0 +1,28 @@ +messages: +- - 'INVITE sip:[% scenarios.0.responders.0.username %]@[% scenarios.0.responders.0.ip %]:[% scenarios.0.responders.0.port %] SIP/2.0' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ' + - 'CSeq: 10 INVITE' + - 'P-Asserted-Identity: ' + - 'Content-Type: application/sdp' + - 'Content-Length: \d+' + - 'Contact: ' + - 'v=0' + - 'o=user1 \d+ \d+ IN IP4 [% server_ip %]' + - 's=-' + - 'c=IN IP4 [% server_ip %]' + - 't=0 0' + - 'm=audio \d+ RTP/AVP 8' + - 'a=rtpmap:8 PCMA/8000' + - 'a=sendrecv' + - 'a=rtcp:\d+' + - 'a=ptime:50' + - 'a=direction:both' +- - 'ACK sip:[% scenarios.0.responders.0.username %]@[% scenarios.0.responders.0.ip %]:[% scenarios.0.responders.0.port %] SIP/2.0' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 10 ACK' + - 'Content-Length: 0' diff --git a/tests/fixtures/invite_redirect_tel_uri/sipp_scenario_responder01.msg b/tests/fixtures/invite_redirect_tel_uri/sipp_scenario_responder01.msg new file mode 100644 index 00000000..5a29797d --- /dev/null +++ b/tests/fixtures/invite_redirect_tel_uri/sipp_scenario_responder01.msg @@ -0,0 +1,134 @@ +----------------------------------------------- 2021-07-05 18:05:31.436441 +UDP message received [1670] bytes : + +INVITE sip:testuser1002@10.20.30.1:52635;cause=302 SIP/2.0 +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bKca9b.ec6553e1ad578512fc6a44a1bf056a20.0 +Via: SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bKca9b.7ae42c07adc509182ee36f867ff88d09.0 +Via: SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bKG8rLJapY;rport=5080 +From: ;tag=4763A163-60E32DCB0002874A-9B7C7700 +To: +CSeq: 10 INVITE +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1_b2b-1 +Max-Forwards: 69 +P-Asserted-Identity: +Diversion: ;privacy=off;counter=1 +History-Info: ;index=1 +History-Info: ;index=1.1 +Content-Type: application/sdp +Content-Length: 194 +Contact: + +v=0 +o=user1 53655765 2353687637 IN IP4 192.168.1.152 +s=- +c=IN IP4 192.168.1.152 +t=0 0 +m=audio 31512 RTP/AVP 8 +a=rtpmap:8 PCMA/8000 +a=sendrecv +a=rtcp:31513 +a=ptime:50 +a=direction:both + +----------------------------------------------- 2021-07-05 18:05:31.548769 +UDP message sent (558 bytes): + +SIP/2.0 100 Trying +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bKca9b.ec6553e1ad578512fc6a44a1bf056a20.0, SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bKca9b.7ae42c07adc509182ee36f867ff88d09.0, SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bKG8rLJapY;rport=5080 +From: ;tag=4763A163-60E32DCB0002874A-9B7C7700 +To: ;user=phone +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1_b2b-1 +CSeq: 10 INVITE +Content-Length: 0 + + +----------------------------------------------- 2021-07-05 18:05:31.550168 +UDP message sent (615 bytes): + +SIP/2.0 180 Ringing +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bKca9b.ec6553e1ad578512fc6a44a1bf056a20.0, SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bKca9b.7ae42c07adc509182ee36f867ff88d09.0, SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bKG8rLJapY;rport=5080 +From: ;tag=4763A163-60E32DCB0002874A-9B7C7700 +To: ;tag=65425SIPpTag011 +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1_b2b-1 +CSeq: 10 INVITE +Contact: +Content-Length: 0 + + +----------------------------------------------- 2021-07-05 18:05:32.056630 +UDP message sent (1108 bytes): + +SIP/2.0 200 OK +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bKca9b.ec6553e1ad578512fc6a44a1bf056a20.0, SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bKca9b.7ae42c07adc509182ee36f867ff88d09.0, SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bKG8rLJapY;rport=5080 +From: ;tag=4763A163-60E32DCB0002874A-9B7C7700 +To: ;tag=65425SIPpTag011 +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1_b2b-1 +CSeq: 10 INVITE +Record-Route: , , +Contact: +Content-Type: application/sdp +Content-Length: 144 + +v=0 +o=user1 53655765 2353687637 IN IP4 10.20.30.1 +s=- +c=IN IP4 10.20.30.1 +t=0 0 +m=audio 46083 RTP/AVP 8 +a=rtpmap:8 PCMA/8000 +a=ptime:50 + +----------------------------------------------- 2021-07-05 18:05:32.618617 +UDP message received [1041] bytes : + +ACK sip:10.20.30.1:52635;transport=UDP SIP/2.0 +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bKca9b.dc25baea3a62cf0ced02f5cfc9a7ab6a.0 +Via: SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bKca9b.b213844a5a541e06971186ca81f8ce59.0 +Via: SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bKXLpXEanH;rport=5080 +From: ;tag=4763A163-60E32DCB0002874A-9B7C7700 +To: ;tag=65425SIPpTag011 +CSeq: 10 ACK +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1_b2b-1 +Max-Forwards: 68 +Content-Length: 0 +Contact: + + +----------------------------------------------- 2021-07-05 18:05:34.045208 +UDP message received [1029] bytes : + +BYE sip:10.20.30.1:52635;transport=UDP SIP/2.0 +Record-Route: +Record-Route: +Record-Route: +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bKda9b.c12395e5b61ad9b4626f6cc655868382.0 +Via: SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bKda9b.9d544f1e365d8cc5462a5fee442bf7c6.0 +Via: SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bK4M5Fpa4G;rport=5080 +From: ;tag=4763A163-60E32DCB0002874A-9B7C7700 +To: ;tag=65425SIPpTag011 +CSeq: 11 BYE +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1_b2b-1 +Max-Forwards: 68 +P-Asserted-Identity: +Content-Length: 0 + + +----------------------------------------------- 2021-07-05 18:05:34.046472 +UDP message sent (611 bytes): + +SIP/2.0 200 OK +Via: SIP/2.0/UDP 192.168.1.152;branch=z9hG4bKda9b.c12395e5b61ad9b4626f6cc655868382.0, SIP/2.0/UDP 127.0.0.1:5062;rport=5062;branch=z9hG4bKda9b.9d544f1e365d8cc5462a5fee442bf7c6.0, SIP/2.0/UDP 127.0.0.1:5080;received=127.0.0.1;branch=z9hG4bK4M5Fpa4G;rport=5080 +From: ;tag=4763A163-60E32DCB0002874A-9B7C7700 +To: ;tag=65425SIPpTag011 +Call-ID: NGCP%invite_redirect_tel_uri%///1-65445@10.20.30.1_b2b-1 +CSeq: 11 BYE +Contact: +Content-Length: 0 + + diff --git a/tests/fixtures/invite_redirect_tel_uri/sipp_scenario_responder01_test.yml.tt2 b/tests/fixtures/invite_redirect_tel_uri/sipp_scenario_responder01_test.yml.tt2 new file mode 100644 index 00000000..142f49f8 --- /dev/null +++ b/tests/fixtures/invite_redirect_tel_uri/sipp_scenario_responder01_test.yml.tt2 @@ -0,0 +1,44 @@ +messages: +- - 'INVITE sip:[% scenarios.0.responders.1.username %]@[% scenarios.0.responders.1.ip %]:[% scenarios.0.responders.1.port %];cause=302 SIP/2.0' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ' + - 'CSeq: 10 INVITE' + - 'P-Asserted-Identity: ' + - 'Diversion: ;privacy=off;counter=1' + - 'History-Info: ;index=1' + - 'History-Info: ;index=1.1' + - 'Content-Type: application/sdp' + - 'Content-Length: \d+' + - 'Contact: ' + - 'v=0' + - 'o=user1 \d+ \d+ IN IP4 [% server_ip %]' + - 's=-' + - 'c=IN IP4 [% server_ip %]' + - 't=0 0' + - 'm=audio \d+ RTP/AVP 8' + - 'a=rtpmap:8 PCMA/8000' + - 'a=sendrecv' + - 'a=rtcp:\d+' + - 'a=ptime:50' + - 'a=direction:both' +- - 'ACK sip:[% scenarios.0.responders.1.ip %]:[% scenarios.0.responders.1.port %];transport=UDP SIP/2.0' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 10 ACK' + - 'Content-Length: 0' + - 'Contact: ' +- - 'BYE sip:[% scenarios.0.responders.1.ip %]:[% scenarios.0.responders.1.port %];transport=UDP SIP/2.0' + - 'Record-Route: ' + - 'Record-Route: ' + - 'Record-Route: ' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 11 BYE' + - 'P-Asserted-Identity: ' + - 'Content-Length: 0' diff --git a/tests/fixtures/mix/scenario_ids.yml b/tests/fixtures/mix/scenario_ids.yml new file mode 100644 index 00000000..7f5fbd74 --- /dev/null +++ b/tests/fixtures/mix/scenario_ids.yml @@ -0,0 +1,81 @@ +--- +customer_test: + id: "7" +domains: + - invite_callforward_scenarios_test +extra_info: {} +invite_callforward_scenarios_test: + testuser1001: + ac: "1" + cc: "43" + phone_number: "4311048" + sn: 1048 + uuid: d34d9fff-2116-45a5-9271-4b5860a4d4b4 + testuser1002: + ac: "1" + cc: "43" + phone_number: "4311049" + sn: 1049 + uuid: 9f6e11aa-98e0-41e5-b1f4-a06666a76f87 + testuser1003: + ac: "1" + cc: "43" + phone_number: "4311050" + sn: 1050 + uuid: c5c2ae9f-6a3f-499c-bb4a-8f5fbcd14ea3 + testuser1004: + ac: "1" + cc: "43" + phone_number: "4311051" + sn: 1051 + uuid: 01531a99-323e-4045-86a7-b86390e000ac + testuser1005: + ac: "1" + cc: "43" + phone_number: "4311052" + sn: 1052 + uuid: f3054009-078f-4f40-b43d-e74ac3886037 +scenarios: + - devid: testuser1002 + domain: invite-callforward.scenarios.test + ip: 10.20.30.1 + mport: 45126 + port: 51650 + responders: + - domain: invite-callforward.scenarios.test + ip: 10.20.30.1 + mport: 45129 + port: 51651 + proto: udp + register: no + username: testuser1003 + - domain: invite-callforward.scenarios.test + ip: 10.20.30.1 + mport: 45132 + port: 51652 + proto: udp + register: yes + username: testuser1003 + username: testuser1002 + - devid: testuser1002 + domain: invite-callforward.scenarios.test + ip: 10.20.30.1 + mport: 45135 + port: 51653 + responders: + - domain: invite-callforward.scenarios.test + ip: 10.20.30.1 + mport: 45138 + port: 51654 + proto: udp + register: yes + username: testuser1004 + - domain: invite-callforward.scenarios.test + ip: 10.20.30.1 + mport: 45141 + port: 51655 + proto: udp + register: yes + username: testuser1005 + username: testuser1002 +server_ip: 192.168.1.152 diff --git a/tests/fixtures/mix/sipp_scenario00.msg b/tests/fixtures/mix/sipp_scenario00.msg new file mode 100644 index 00000000..d8efc155 --- /dev/null +++ b/tests/fixtures/mix/sipp_scenario00.msg @@ -0,0 +1,59 @@ +----------------------------------------------- 2021-07-05 18:08:30.957826 +UDP message sent (400 bytes): + +REGISTER sip:testuser1003@invite-callforward.scenarios.test SIP/2.0 +Via: SIP/2.0/UDP 10.20.30.1:51652;branch=z9hG4bK-70263-1-0 +From: ;tag=70263SIPpTag001 +To: +Call-ID: NGCP%register%///1-70263@10.20.30.1 +CSeq: 1 REGISTER +Contact: +Expires: 600 +Max-Forwards: 70 +Content-Length: 0 + + +----------------------------------------------- 2021-07-05 18:08:31.040076 +UDP message received [479] bytes : + +SIP/2.0 401 Unauthorized +Via: SIP/2.0/UDP 10.20.30.1:51652;rport=51652;branch=z9hG4bK-70263-1-0 +From: ;tag=70263SIPpTag001 +To: ;tag=95c37a12bff1a2c36d72bf8333176544.78550000 +Call-ID: NGCP%register%///1-70263@10.20.30.1 +CSeq: 1 REGISTER +WWW-Authenticate: Digest realm="invite-callforward.scenarios.test", nonce="YOMvq2DjLn/NHP53+e8jHZxrkjA933pD" +Server: Sipwise NGCP Proxy 9.X +Content-Length: 0 + + +----------------------------------------------- 2021-07-05 18:08:31.040570 +UDP message sent (607 bytes): + +REGISTER sip:testuser1003@invite-callforward.scenarios.test SIP/2.0 +Via: SIP/2.0/UDP 10.20.30.1:51652;branch=z9hG4bK-70263-1-3 +From: ;tag=70263SIPpTag001 +To: +Call-ID: NGCP%register%///1-70263@10.20.30.1 +CSeq: 2 REGISTER +Authorization: Digest username="testuser1003",realm="invite-callforward.scenarios.test",uri="sip:192.168.1.152:5060",nonce="YOMvq2DjLn/NHP53+e8jHZxrkjA933pD",response="dab2606a154300beba3e1e251e665be7",algorithm=MD5 +Contact: +Expires: 600 +Max-Forwards: 70 +Content-Length: 0 + + +----------------------------------------------- 2021-07-05 18:08:31.273159 +UDP message received [459] bytes : + +SIP/2.0 200 OK +Via: SIP/2.0/UDP 10.20.30.1:51652;rport=51652;branch=z9hG4bK-70263-1-3 +From: ;tag=70263SIPpTag001 +To: ;tag=95c37a12bff1a2c36d72bf8333176544.78550000 +Call-ID: NGCP%register%///1-70263@10.20.30.1 +CSeq: 2 REGISTER +Contact: ;expires=600;received="sip:10.20.30.1:51652" +Server: Sipwise NGCP Proxy 9.X +Content-Length: 0 + + diff --git a/tests/fixtures/mix/sipp_scenario00_test.yml.tt2 b/tests/fixtures/mix/sipp_scenario00_test.yml.tt2 new file mode 100644 index 00000000..c4d14c09 --- /dev/null +++ b/tests/fixtures/mix/sipp_scenario00_test.yml.tt2 @@ -0,0 +1,15 @@ +messages: +- - 'SIP/2.0 401 Unauthorized' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 1 REGISTER' + - 'WWW-Authenticate: Digest realm="invite-callforward.scenarios.test", nonce="[^"]+"' + - 'Server: Sipwise NGCP Proxy' + - 'Content-Length: 0' +- - 'SIP/2.0 200 OK' + - 'From: ;tag=[\w-]+' + - 'To: ;tag=[\w-]+' + - 'CSeq: 2 REGISTER' + - 'Contact: ;expires=\d+;received="sip:[% scenarios.0.responders.1.ip %]:[% scenarios.0.responders.1.port %]"' + - 'Server: Sipwise NGCP Proxy' + - 'Content-Length: 0' diff --git a/tests/fixtures/programs.py b/tests/fixtures/programs.py index 6a363c10..7ccbc2ba 100644 --- a/tests/fixtures/programs.py +++ b/tests/fixtures/programs.py @@ -99,11 +99,11 @@ def generate_test_tt2(*args): @pytest.fixture() def generate_test_tt2_file(tmpdir, *args): - fout = tmpdir.join("sip_messages00_test.yml.tt2") + fout = tmpdir.join("sipp_test.yml.tt2") ferr = tmpdir.join("stderr.txt") def run(*args): - cmd = ["./bin/generate_test_tt2.py"] + list(args) + cmd = ["./bin/generate_test_tt2.py", "--verbose"] + list(args) with open(fout, "wb") as fo, open(ferr, "wb") as fe: with subprocess.Popen( cmd, stdout=fo, stderr=fe, encoding="utf-8" diff --git a/tests/test_generate_test_tt2.py b/tests/test_generate_test_tt2.py index 9fb43c8b..ef114c10 100644 --- a/tests/test_generate_test_tt2.py +++ b/tests/test_generate_test_tt2.py @@ -34,9 +34,9 @@ from generate_test_tt2 import Generator # noqa Args = namedtuple( "GenratorArgs", ["scen_ids", "sipp_msg", "filter", "filter_common"] ) -IDS_FILE = "tests/fixtures/auth_fail/scenario_ids.yml" -MSG_FILE = "tests/fixtures/auth_fail/sipp_scenario00.msg" -TT2_FILE = "tests/fixtures/auth_fail/sipp_scenario00_test.yml.tt2" +IDS_FILE = "tests/fixtures/{}/scenario_ids.yml" +MSG_FILE = "tests/fixtures/{}/sipp_scenario{}.msg" +TT2_FILE = "tests/fixtures/{}/sipp_scenario{}_test.yml.tt2" def check_filecontent(a, b): @@ -50,7 +50,7 @@ def check_filecontent(a, b): def test_load_msg(): - res = load_msg(MSG_FILE) + res = load_msg(MSG_FILE.format("auth_fail", "00")) for i in range(len(res)): print("res[{}][0]:{}".format(i, res[i][0])) @@ -78,8 +78,8 @@ def test_get_header(): def test_filter_hdr(): - msgs = load_msg(MSG_FILE) - ids = load_yaml(IDS_FILE) + msgs = load_msg(MSG_FILE.format("auth_fail", "00")) + ids = load_yaml(IDS_FILE.format("auth_fail", "00")) g = Generator(Generator.common_hdrs, msgs, ids) assert g.filter_hdr( "ViA: SIP/2.0/UDP 10.20.29.2:51602;" @@ -90,8 +90,8 @@ def test_filter_hdr(): def test_process_msg(): - msgs = load_msg(MSG_FILE) - ids = load_yaml(IDS_FILE) + msgs = load_msg(MSG_FILE.format("auth_fail", "00")) + ids = load_yaml(IDS_FILE.format("auth_fail", "00")) g = Generator(Generator.common_hdrs, msgs, ids) res = g.process_msg(msgs[0]) assert len(res) == 7 @@ -132,9 +132,113 @@ def test_get_filters(generate_test_tt2): ) -def test_ok(generate_test_tt2_file, caplog): +def test_ok_auth_fail(generate_test_tt2_file, caplog): caplog.set_level(logging.DEBUG) - res = generate_test_tt2_file(IDS_FILE, MSG_FILE) + res = generate_test_tt2_file( + IDS_FILE.format("auth_fail"), MSG_FILE.format("auth_fail", "00") + ) + + assert check_filecontent(TT2_FILE.format("auth_fail", "00"), res.out_file) + assert res.returncode == 0 + + +def test_ok_incoming_foreign_dom(generate_test_tt2_file, caplog): + caplog.set_level(logging.DEBUG) + res = generate_test_tt2_file( + IDS_FILE.format("incoming_foreign_dom"), + MSG_FILE.format("incoming_foreign_dom", "00"), + ) + + assert check_filecontent( + TT2_FILE.format("incoming_foreign_dom", "00"), res.out_file + ) + assert res.returncode == 0 + + +def test_ok_incoming_foreign_dom_resp(generate_test_tt2_file, caplog): + caplog.set_level(logging.DEBUG) + res = generate_test_tt2_file( + IDS_FILE.format("incoming_foreign_dom"), + MSG_FILE.format("incoming_foreign_dom", "_responder00"), + ) + + assert check_filecontent( + TT2_FILE.format("incoming_foreign_dom", "_responder00"), res.out_file + ) + assert res.returncode == 0 + + +def test_ok_invite_redirect_tel_uri(generate_test_tt2_file, caplog): + caplog.set_level(logging.DEBUG) + res = generate_test_tt2_file( + IDS_FILE.format("invite_redirect_tel_uri"), + MSG_FILE.format("invite_redirect_tel_uri", "00"), + ) + + assert check_filecontent( + TT2_FILE.format("invite_redirect_tel_uri", "00"), res.out_file + ) + assert res.returncode == 0 + + +def test_invite_redirect_tel_uri_resp(generate_test_tt2_file, caplog): + caplog.set_level(logging.DEBUG) + res = generate_test_tt2_file( + IDS_FILE.format("invite_redirect_tel_uri"), + MSG_FILE.format("invite_redirect_tel_uri", "_responder00"), + ) + + assert check_filecontent( + TT2_FILE.format("invite_redirect_tel_uri", "_responder00"), + res.out_file, + ) + assert res.returncode == 0 + + res = generate_test_tt2_file( + IDS_FILE.format("invite_redirect_tel_uri"), + MSG_FILE.format("invite_redirect_tel_uri", "_responder01"), + ) + + assert check_filecontent( + TT2_FILE.format("invite_redirect_tel_uri", "_responder01"), + res.out_file, + ) + assert res.returncode == 0 + + +def test_ok_incoming_hih(generate_test_tt2_file, caplog): + caplog.set_level(logging.DEBUG) + res = generate_test_tt2_file( + IDS_FILE.format("incoming_hih"), + MSG_FILE.format("incoming_hih", "00"), + ) + + assert check_filecontent( + TT2_FILE.format("incoming_hih", "00"), res.out_file + ) + assert res.returncode == 0 + + +def test_incoming_hih_resp(generate_test_tt2_file, caplog): + caplog.set_level(logging.DEBUG) + res = generate_test_tt2_file( + IDS_FILE.format("incoming_hih"), + MSG_FILE.format("incoming_hih", "_responder01"), + ) + + assert check_filecontent( + TT2_FILE.format("incoming_hih", "_responder01"), + res.out_file, + ) + assert res.returncode == 0 + + +def test_mix(generate_test_tt2_file, caplog): + caplog.set_level(logging.DEBUG) + res = generate_test_tt2_file( + IDS_FILE.format("mix"), + MSG_FILE.format("mix", "00"), + ) - assert check_filecontent(TT2_FILE, res.out_file) + assert check_filecontent(TT2_FILE.format("mix", "00"), res.out_file) assert res.returncode == 0