mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2026-10-04 02:04:22 +00:00
added test: call from authenticated device
This commit is contained in:
+2
-2
@@ -13,8 +13,8 @@
|
|||||||
"authCallback": {
|
"authCallback": {
|
||||||
"uri": "http://example.com/auth",
|
"uri": "http://example.com/auth",
|
||||||
"auth": {
|
"auth": {
|
||||||
"username": "foo",
|
"user": "foo",
|
||||||
"password": "bar"
|
"pass": "bar"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"trunks": {
|
"trunks": {
|
||||||
|
|||||||
@@ -12,10 +12,10 @@
|
|||||||
"level": "debug"
|
"level": "debug"
|
||||||
},
|
},
|
||||||
"authCallback": {
|
"authCallback": {
|
||||||
"uri": "http://example.com/auth",
|
"uri": "http://127.0.0.1:4000/auth",
|
||||||
"auth": {
|
"auth": {
|
||||||
"username": "foo",
|
"user": "foo",
|
||||||
"password": "bar"
|
"pass ": "bar"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"trunks": {
|
"trunks": {
|
||||||
|
|||||||
+1
-14
@@ -4,7 +4,7 @@ const rtpengine = new Client();
|
|||||||
const offer = rtpengine.offer.bind(rtpengine, config.get('rtpengine'));
|
const offer = rtpengine.offer.bind(rtpengine, config.get('rtpengine'));
|
||||||
const answer = rtpengine.answer.bind(rtpengine, config.get('rtpengine'));
|
const answer = rtpengine.answer.bind(rtpengine, config.get('rtpengine'));
|
||||||
const del = rtpengine.delete.bind(rtpengine, config.get('rtpengine'));
|
const del = rtpengine.delete.bind(rtpengine, config.get('rtpengine'));
|
||||||
const {getAppserver, isWSS} = require('./utils');
|
const {getAppserver, isWSS, makeRtpEngineOpts} = require('./utils');
|
||||||
|
|
||||||
module.exports = handler;
|
module.exports = handler;
|
||||||
|
|
||||||
@@ -60,16 +60,3 @@ function setHandlers(logger, uas, uac, rtpEngineResource) {
|
|||||||
|
|
||||||
//TODO: handle re-INVITEs, REFER, INFO
|
//TODO: handle re-INVITEs, REFER, INFO
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeRtpEngineOpts(req, srcIsUsingSrtp, dstIsUsingSrtp) {
|
|
||||||
const from = req.getParsedHeader('from');
|
|
||||||
const common = {'call-id': req.get('Call-ID'), 'from-tag': from.params.tag};
|
|
||||||
const rtpCharacteristics = config.get('transcoding.rtpCharacteristics');
|
|
||||||
const srtpCharacteristics = config.get('transcoding.srtpCharacteristics');
|
|
||||||
return {
|
|
||||||
common,
|
|
||||||
offer: Object.assign({'sdp': req.body, 'replace': ['origin', 'session-connection']}, common,
|
|
||||||
dstIsUsingSrtp ? srtpCharacteristics : rtpCharacteristics),
|
|
||||||
answer: Object.assign({}, common, srcIsUsingSrtp ? srtpCharacteristics : rtpCharacteristics)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|||||||
+1
-3
@@ -9,6 +9,4 @@ function auth(req, res, next) {
|
|||||||
authenticator(req, res, next);
|
authenticator(req, res, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = { auth };
|
||||||
auth
|
|
||||||
};
|
|
||||||
|
|||||||
+15
-1
@@ -20,8 +20,22 @@ function getAppserver() {
|
|||||||
return config.get('trunks.appserver')[ idx++ % len];
|
return config.get('trunks.appserver')[ idx++ % len];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function makeRtpEngineOpts(req, srcIsUsingSrtp, dstIsUsingSrtp) {
|
||||||
|
const from = req.getParsedHeader('from');
|
||||||
|
const common = {'call-id': req.get('Call-ID'), 'from-tag': from.params.tag};
|
||||||
|
const rtpCharacteristics = config.get('transcoding.rtpCharacteristics');
|
||||||
|
const srtpCharacteristics = config.get('transcoding.srtpCharacteristics');
|
||||||
|
return {
|
||||||
|
common,
|
||||||
|
offer: Object.assign({'sdp': req.body, 'replace': ['origin', 'session-connection']}, common,
|
||||||
|
dstIsUsingSrtp ? srtpCharacteristics : rtpCharacteristics),
|
||||||
|
answer: Object.assign({}, common, srcIsUsingSrtp ? srtpCharacteristics : rtpCharacteristics)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
fromInboundTrunk,
|
fromInboundTrunk,
|
||||||
isWSS,
|
isWSS,
|
||||||
getAppserver
|
getAppserver,
|
||||||
|
makeRtpEngineOpts
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"config": "^3.2.2",
|
"config": "^3.2.2",
|
||||||
"drachtio-http-authenticator": "0.0.3",
|
"drachtio-http-authenticator": "0.0.5",
|
||||||
"drachtio-srf": "^4.4.14",
|
"drachtio-srf": "^4.4.14",
|
||||||
"pino": "^5.13.2",
|
"pino": "^5.13.2",
|
||||||
"rtpengine-client": "0.0.8"
|
"rtpengine-client": "0.0.8"
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ services:
|
|||||||
auth-server:
|
auth-server:
|
||||||
image: jambonz/customer-auth-server:latest
|
image: jambonz/customer-auth-server:latest
|
||||||
command: npm start
|
command: npm start
|
||||||
|
ports:
|
||||||
|
- "4000:4000/tcp"
|
||||||
env_file: docker.env
|
env_file: docker.env
|
||||||
networks:
|
networks:
|
||||||
sbc-inbound:
|
sbc-inbound:
|
||||||
|
|||||||
+1
-2
@@ -1,4 +1,3 @@
|
|||||||
require('./docker_start');
|
require('./docker_start');
|
||||||
require('./carrier-origination');
|
require('./sip-tests');
|
||||||
//require('./device-origination');
|
|
||||||
require('./docker_stop');
|
require('./docker_stop');
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
CSeq: 1 INVITE
|
CSeq: 1 INVITE
|
||||||
Contact: sip:sipp@[local_ip]:[local_port]
|
Contact: sip:sipp@[local_ip]:[local_port]
|
||||||
Max-Forwards: 70
|
Max-Forwards: 70
|
||||||
Subject: Performance Test
|
Subject: uac-pcap-carrier-success
|
||||||
Content-Type: application/sdp
|
Content-Type: application/sdp
|
||||||
Content-Length: [len]
|
Content-Length: [len]
|
||||||
|
|
||||||
@@ -73,9 +73,8 @@
|
|||||||
To: [service] <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
|
To: [service] <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
|
||||||
Call-ID: [call_id]
|
Call-ID: [call_id]
|
||||||
CSeq: 1 ACK
|
CSeq: 1 ACK
|
||||||
Contact: sip:sipp@[local_ip]:[local_port]
|
|
||||||
Max-Forwards: 70
|
Max-Forwards: 70
|
||||||
Subject: Performance Test
|
Subject: uac-pcap-carrier-success
|
||||||
Content-Length: 0
|
Content-Length: 0
|
||||||
|
|
||||||
]]>
|
]]>
|
||||||
@@ -101,9 +100,7 @@
|
|||||||
To: [service] <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
|
To: [service] <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
|
||||||
Call-ID: [call_id]
|
Call-ID: [call_id]
|
||||||
CSeq: 2 BYE
|
CSeq: 2 BYE
|
||||||
Contact: sip:sipp@[local_ip]:[local_port]
|
Subject: uac-pcap-carrier-success
|
||||||
Max-Forwards: 70
|
|
||||||
Subject: Performance Test
|
|
||||||
Content-Length: 0
|
Content-Length: 0
|
||||||
|
|
||||||
]]>
|
]]>
|
||||||
|
|||||||
@@ -0,0 +1,165 @@
|
|||||||
|
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||||
|
<!DOCTYPE scenario SYSTEM "sipp.dtd">
|
||||||
|
|
||||||
|
<!-- This program is free software; you can redistribute it and/or -->
|
||||||
|
<!-- modify it under the terms of the GNU General Public License as -->
|
||||||
|
<!-- published by the Free Software Foundation; either version 2 of the -->
|
||||||
|
<!-- License, or (at your option) any later version. -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- This program is distributed in the hope that it will be useful, -->
|
||||||
|
<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
|
||||||
|
<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
|
||||||
|
<!-- GNU General Public License for more details. -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- You should have received a copy of the GNU General Public License -->
|
||||||
|
<!-- along with this program; if not, write to the -->
|
||||||
|
<!-- Free Software Foundation, Inc., -->
|
||||||
|
<!-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- Sipp 'uac' scenario with pcap (rtp) play -->
|
||||||
|
<!-- -->
|
||||||
|
|
||||||
|
<scenario name="UAC with media">
|
||||||
|
<!-- In client mode (sipp placing calls), the Call-ID MUST be -->
|
||||||
|
<!-- generated by sipp. To do so, use [call_id] keyword. -->
|
||||||
|
<send retrans="500">
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
INVITE sip:[service]@jambonz.org SIP/2.0
|
||||||
|
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
|
||||||
|
From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag09[call_number]
|
||||||
|
To: [service] <sip:[service]@[remote_ip]:[remote_port]>
|
||||||
|
Call-ID: [call_id]
|
||||||
|
CSeq: 1 INVITE
|
||||||
|
Contact: sip:sipp@[local_ip]:[local_port]
|
||||||
|
Max-Forwards: 70
|
||||||
|
Subject: uac-pcap-device-success
|
||||||
|
Content-Type: application/sdp
|
||||||
|
Content-Length: [len]
|
||||||
|
|
||||||
|
v=0
|
||||||
|
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
|
||||||
|
s=-
|
||||||
|
c=IN IP[local_ip_type] [local_ip]
|
||||||
|
t=0 0
|
||||||
|
m=audio [auto_media_port] RTP/AVP 8 101
|
||||||
|
a=rtpmap:8 PCMA/8000
|
||||||
|
a=rtpmap:101 telephone-event/8000
|
||||||
|
a=fmtp:101 0-11,16
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</send>
|
||||||
|
|
||||||
|
<recv response="100" optional="true">
|
||||||
|
</recv>
|
||||||
|
|
||||||
|
<recv response="401" auth="true">
|
||||||
|
</recv>
|
||||||
|
|
||||||
|
<send>
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
ACK sip:[service]@jambonz.org SIP/2.0
|
||||||
|
[last_Via]
|
||||||
|
From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag09[call_number]
|
||||||
|
To: [service] <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
|
||||||
|
Call-ID: [call_id]
|
||||||
|
CSeq: 1 ACK
|
||||||
|
Subject: uac-pcap-device-success
|
||||||
|
Content-Length: 0
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</send>
|
||||||
|
|
||||||
|
<send retrans="500">
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
INVITE sip:[service]@jambonz.org SIP/2.0
|
||||||
|
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
|
||||||
|
From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag09[call_number]
|
||||||
|
To: [service] <sip:[service]@[remote_ip]:[remote_port]>
|
||||||
|
Call-ID: [call_id]
|
||||||
|
CSeq: 2 INVITE
|
||||||
|
[authentication username=john password=1234]
|
||||||
|
Contact: sip:sipp@[local_ip]:[local_port]
|
||||||
|
Max-Forwards: 70
|
||||||
|
Subject: uac-pcap-device-success
|
||||||
|
Content-Type: application/sdp
|
||||||
|
Content-Length: [len]
|
||||||
|
|
||||||
|
v=0
|
||||||
|
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
|
||||||
|
s=-
|
||||||
|
c=IN IP[local_ip_type] [local_ip]
|
||||||
|
t=0 0
|
||||||
|
m=audio [auto_media_port] RTP/AVP 8 101
|
||||||
|
a=rtpmap:8 PCMA/8000
|
||||||
|
a=rtpmap:101 telephone-event/8000
|
||||||
|
a=fmtp:101 0-11,16
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</send>
|
||||||
|
|
||||||
|
<recv response="100" optional="true">
|
||||||
|
</recv>
|
||||||
|
|
||||||
|
<recv response="180" optional="true">
|
||||||
|
</recv>
|
||||||
|
|
||||||
|
<recv response="200" rtd="true" crlf="true">
|
||||||
|
</recv>
|
||||||
|
|
||||||
|
<!-- Packet lost can be simulated in any send/recv message by -->
|
||||||
|
<!-- by adding the 'lost = "10"'. Value can be [1-100] percent. -->
|
||||||
|
<send>
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
ACK sip:[service]@jambonz.org SIP/2.0
|
||||||
|
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
|
||||||
|
From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag09[call_number]
|
||||||
|
To: [service] <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
|
||||||
|
Call-ID: [call_id]
|
||||||
|
CSeq: 2 ACK
|
||||||
|
Subject: uac-pcap-device-success
|
||||||
|
Content-Length: 0
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</send>
|
||||||
|
|
||||||
|
<!-- Play a pre-recorded PCAP file (RTP stream) -->
|
||||||
|
<nop>
|
||||||
|
<action>
|
||||||
|
<exec play_pcap_audio="pcap/g711a.pcap"/>
|
||||||
|
</action>
|
||||||
|
</nop>
|
||||||
|
|
||||||
|
<!-- Pause briefly -->
|
||||||
|
<pause milliseconds="3000"/>
|
||||||
|
|
||||||
|
<!-- The 'crlf' option inserts a blank line in the statistics report. -->
|
||||||
|
<send retrans="500">
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
|
BYE sip:[service]@jambonz.org SIP/2.0
|
||||||
|
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
|
||||||
|
From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag09[call_number]
|
||||||
|
To: [service] <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
|
||||||
|
Call-ID: [call_id]
|
||||||
|
CSeq: 3 BYE
|
||||||
|
Max-Forwards: 70
|
||||||
|
Subject: uac-pcap-device-success
|
||||||
|
Content-Length: 0
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</send>
|
||||||
|
|
||||||
|
<recv response="200" crlf="true">
|
||||||
|
</recv>
|
||||||
|
|
||||||
|
<!-- definition of the response time repartition table (unit is ms) -->
|
||||||
|
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
|
||||||
|
|
||||||
|
<!-- definition of the call length repartition table (unit is ms) -->
|
||||||
|
<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
|
||||||
|
|
||||||
|
</scenario>
|
||||||
@@ -15,8 +15,7 @@ function connect(connectable) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
test('incoming call from carrier', (t) => {
|
test('incoming call tests', (t) => {
|
||||||
clearModule('../app');
|
|
||||||
const {srf} = require('../app');
|
const {srf} = require('../app');
|
||||||
|
|
||||||
connect(srf)
|
connect(srf)
|
||||||
@@ -24,15 +23,22 @@ test('incoming call from carrier', (t) => {
|
|||||||
return sippUac('uac-pcap-carrier-success.xml', '172.38.0.20');
|
return sippUac('uac-pcap-carrier-success.xml', '172.38.0.20');
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
t.pass('successfully connected incoming call from carrier');
|
return t.pass('incoming call from carrier completed successfully');
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return sippUac('uac-pcap-device-success.xml', '172.38.0.30');
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return t.pass('incoming call from authenticated device completed successfully');
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
srf.disconnect();
|
srf.disconnect();
|
||||||
t.end();
|
t.end();
|
||||||
return;
|
return;
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
if (srf) srf.disconnect();
|
|
||||||
console.log(`error received: ${err}`);
|
console.log(`error received: ${err}`);
|
||||||
|
if (srf) srf.disconnect();
|
||||||
t.error(err);
|
t.error(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
+2
-1
@@ -1,5 +1,5 @@
|
|||||||
const { spawn } = require('child_process');
|
const { spawn } = require('child_process');
|
||||||
//const debug = require('debug')('test:sipp');
|
const debug = require('debug')('test:sipp');
|
||||||
let network;
|
let network;
|
||||||
const obj = {};
|
const obj = {};
|
||||||
let output = '';
|
let output = '';
|
||||||
@@ -39,6 +39,7 @@ obj.sippUac = (file, bindAddress) => {
|
|||||||
|
|
||||||
if (bindAddress) args.splice(5, 0, '--ip', bindAddress);
|
if (bindAddress) args.splice(5, 0, '--ip', bindAddress);
|
||||||
|
|
||||||
|
//console.log(args.join(' '));
|
||||||
clearOutput();
|
clearOutput();
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user