diff --git a/README b/README index 5e676b01..dcf1d1b7 100644 --- a/README +++ b/README @@ -201,6 +201,9 @@ scenario.yml file syntax: If password_wrong: yes then the caller is going to use 'wrongpass' as password. + If devid: 1 (it must be an alias_number of the subscriber) then that value will be + used as username part of SIP and for auth + If defined, we can set kamailio's modules level debug as desired. Example: @@ -242,6 +245,12 @@ scenario.yml file syntax: cc: 43 ac: 1 sn: 1002 + alias_numbers: + - cc: 34 + ac: 96 + sn: 5712045 + is_devid: 1 + devid_alias: 899898989898 testuser1001: customer: 'customer.test' password: testuser @@ -276,7 +285,13 @@ scenario.yml file syntax: domain: spce.test register: yes proto: tcp - - ip: 127.0.2.1 --> sipp_scenario_responder02.xml + - ip: 127.126.0.2 --> sipp_scenario_responder02.xml + devid: 34965712045 + username: testuser1002 + domain: spce.test + register: yes + proto: tcp + - ip: 127.0.2.1 --> sipp_scenario_responder03.xml number: 004321001 username: 004321001 domain: spce.test diff --git a/bin/create_subscribers.pl b/bin/create_subscribers.pl index f03b9eb0..63874de1 100755 --- a/bin/create_subscribers.pl +++ b/bin/create_subscribers.pl @@ -79,7 +79,9 @@ sub get_data { my $alias = { cc => $_->{cc}, ac => $_->{ac}, - sn => $_->{sn} + sn => $_->{sn}, + is_devid => $_->{is_devid}, + devid_alias => $_->{devid_alias} }; push(@aliases, $alias); } diff --git a/bin/scenario.pl b/bin/scenario.pl index 149e0e36..65985dbd 100755 --- a/bin/scenario.pl +++ b/bin/scenario.pl @@ -73,6 +73,18 @@ sub new_csv return $r; } +sub check_devid +{ + my ($data_sub, $devid) = @_; + foreach (@{$data_sub->{alias_numbers}}) { + if ($devid eq $_->{cc}.$_->{ac}.$_->{sn}) { + die("devid:$devid not defined as is_devid") unless $_->{is_devid}; + return 1; + } + } + die("devid:$devid is not an alias_number"); +} + sub get_subs_info { my ($data_sub, $data, $presence) = @_; @@ -84,7 +96,15 @@ sub get_subs_info my $username = $data->{username}; my $subs = $data_sub->{$domain}->{$username}; $data->{password} = $subs->{password}; - eval { $data->{number} = $subs->{cc}.$subs->{ac}.$subs->{sn}; } unless defined($presence); + if(defined($data->{devid})) { + $_->{auth_username} = $data->{devid}; + $_->{number} = $data->{devid}; + check_devid($subs, $data->{devid}); + } else { + $data->{devid} = $data->{username}; + $data->{auth_username} = $data->{username}; + eval { $data->{number} = $subs->{cc}.$subs->{ac}.$subs->{sn}; } unless defined($presence); + } $data->{'pbx_extension'} = $subs->{'pbx_extension'}; } else @@ -128,8 +148,8 @@ sub generate { $_->{password} = "wrongpass"; } - my $auth = "[authentication username=$_->{username} password=$_->{password}]"; - my $csv_data = [$_->{username}, $auth, $_->{domain}, $test_uuid, $_->{'pbx_extension'}]; + my $auth = "[authentication username=$_->{auth_username} password=$_->{password}]"; + my $csv_data = [$_->{devid}, $auth, $_->{domain}, $test_uuid, $_->{'pbx_extension'}]; $csv->{caller}->print($io_caller, $csv_data); $csv_data = ["sipp_scenario".sprintf("%02i", $id).".xml", $_->{proto}, $_->{ip}]; $csv->{scenario}->print($io_scenario, $csv_data); @@ -148,8 +168,8 @@ sub generate $_->{peer_host} = "" unless defined($_->{peer_host}); # by default proto is udp $_->{proto} = "udp" unless defined($_->{proto}); - $auth = "[authentication username=$_->{username} password=$_->{password}]"; - $csv_data = [$_->{username}, $_->{number}, $auth, $_->{domain}, $test_uuid, $_->{'pbx_extension'}]; + $auth = "[authentication username=$_->{auth_username} password=$_->{password}]"; + $csv_data = [$_->{devid}, $_->{number}, $auth, $_->{domain}, $test_uuid, $_->{'pbx_extension'}]; $csv->{callee}->print($io_callee, $csv_data); $csv_data = ["sipp_scenario_responder".sprintf("%02i", $res_id).".xml", $_->{proto}, $_->{ip}, $_->{peer_host}, $_->{foreign}, $_->{register}, $_->{username}."@".$_->{domain}]; $csv->{scenario}->print($io_scenario, $csv_data);