mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2025-12-19 04:37:43 +00:00
start of test cases
This commit is contained in:
9
.travis.yml
Normal file
9
.travis.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
sudo: required
|
||||
language: node_js
|
||||
node_js:
|
||||
- "lts/*"
|
||||
services:
|
||||
- docker
|
||||
script:
|
||||
- npm test
|
||||
|
||||
13
app.js
13
app.js
@@ -11,9 +11,18 @@ if (process.env.NODE_ENV === 'test') {
|
||||
logger.child = () => {return {info: noop, error: noop, debug: noop};};
|
||||
}
|
||||
|
||||
srf.listen(config.get('drachtio'));
|
||||
// config dictates whether to use outbound or inbound connections
|
||||
if (config.has('drachtio.host')) {
|
||||
srf.connect(config.get('drachtio'));
|
||||
srf.on('connect', (err, hp) => {
|
||||
logger.info(`connected to drachtio listening on ${hp}`);
|
||||
});
|
||||
}
|
||||
else {
|
||||
srf.listen(config.get('drachtio'));
|
||||
}
|
||||
|
||||
srf.request('invite', auth);
|
||||
srf.use('invite', auth);
|
||||
srf.invite(require('./lib/invite')({logger}));
|
||||
|
||||
module.exports = {srf};
|
||||
|
||||
@@ -4,7 +4,43 @@
|
||||
"port": 9060,
|
||||
"secret": "cymru"
|
||||
},
|
||||
"rtpengine": {
|
||||
"host": "127.0.0.1",
|
||||
"port": 12222
|
||||
},
|
||||
"logging": {
|
||||
"level": "info"
|
||||
"level": "debug"
|
||||
},
|
||||
"authCallback": {
|
||||
"uri": "http://example.com/auth",
|
||||
"auth": {
|
||||
"username": "foo",
|
||||
"password": "bar"
|
||||
}
|
||||
},
|
||||
"trunks": {
|
||||
"inbound": [
|
||||
{
|
||||
"name": "carrier1",
|
||||
"host": ["172.38.0.20"]
|
||||
}
|
||||
],
|
||||
"appserver": ["sip:172.38.0.11"]
|
||||
},
|
||||
"transcoding": {
|
||||
"rtpCharacteristics" : {
|
||||
"transport protocol": "RTP/AVP",
|
||||
"DTLS": "off",
|
||||
"SDES": "off",
|
||||
"ICE": "remove",
|
||||
"rtcp-mux": ["demux"]
|
||||
},
|
||||
"srtpCharacteristics": {
|
||||
"transport-protocol": "UDP/TLS/RTP/SAVPF",
|
||||
"ICE": "force",
|
||||
"SDES": "off",
|
||||
"flags": ["generate mid", "SDES-no"],
|
||||
"rtcp-mux": ["require"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,7 @@ function handler({logger}) {
|
||||
throw new Error(`failed allocating rtpengine endpoint: ${JSON.stringify(response)}`);
|
||||
}
|
||||
|
||||
const {uas, uac} = await srf.createB2BUA(req, res, {
|
||||
proxy: uri,
|
||||
const {uas, uac} = await srf.createB2BUA(req, res, uri, {
|
||||
localSdpB: response.sdp,
|
||||
localSdpA: (sdp, res) => {
|
||||
const opts = Object.assign({sdp, 'to-tag': res.getParsedHeader('To').params.tag},
|
||||
|
||||
@@ -3,7 +3,9 @@ const config = require('config');
|
||||
const authenticator = require('drachtio-http-authenticator')(config.get('authCallback'));
|
||||
|
||||
function auth(req, res, next) {
|
||||
if (fromInboundTrunk) return next();
|
||||
if (fromInboundTrunk) {
|
||||
return next();
|
||||
}
|
||||
authenticator(req, res, next);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,23 +15,21 @@ function connect(connectable) {
|
||||
});
|
||||
}
|
||||
|
||||
test('invite handler', (t) => {
|
||||
test('incoming call from carrier', (t) => {
|
||||
clearModule('../app');
|
||||
const {srf, disconnectMs} = require('../app');
|
||||
const {srf} = require('../app');
|
||||
|
||||
connect(srf)
|
||||
.then(() => {
|
||||
return sippUac('uac-pcap.xml');
|
||||
return sippUac('uac-pcap-carrier-success.xml', '172.38.0.20');
|
||||
})
|
||||
.then(() => {
|
||||
t.pass('successfully connected call');
|
||||
if (srf.locals.lb) srf.locals.lb.disconnect();
|
||||
t.pass('successfully connected incoming call from carrier');
|
||||
srf.disconnect();
|
||||
t.end();
|
||||
return;
|
||||
})
|
||||
.catch((err) => {
|
||||
if (srf.locals.lb) srf.locals.lb.disconnect();
|
||||
if (srf) srf.disconnect();
|
||||
console.log(`error received: ${err}`);
|
||||
t.error(err);
|
||||
@@ -8,25 +8,46 @@ networks:
|
||||
- subnet: 172.38.0.0/16
|
||||
|
||||
services:
|
||||
drachtio:
|
||||
sbc:
|
||||
image: drachtio/drachtio-server:latest
|
||||
command: drachtio --contact "sip:*;transport=udp" --loglevel debug --sofia-loglevel 9
|
||||
container_name: drachtio
|
||||
ports:
|
||||
- "9060:9022/tcp"
|
||||
networks:
|
||||
sbc-inbound:
|
||||
ipv4_address: 172.38.0.10
|
||||
|
||||
|
||||
|
||||
sipp-uas:
|
||||
appserver:
|
||||
image: drachtio/sipp:latest
|
||||
command: sipp -sf /tmp/uas.xml
|
||||
container_name: sipp-uas.local
|
||||
volumes:
|
||||
- ./scenarios:/tmp
|
||||
tty: true
|
||||
networks:
|
||||
sbc-inbound:
|
||||
ipv4_address: 172.38.0.11
|
||||
|
||||
auth-server:
|
||||
image: jambonz/customer-auth-server:latest
|
||||
command: npm start
|
||||
env_file: docker.env
|
||||
networks:
|
||||
sbc-inbound:
|
||||
ipv4_address: 172.38.0.12
|
||||
|
||||
redis:
|
||||
image: redis:5-alpine
|
||||
ports:
|
||||
- "16379:6379/tcp"
|
||||
networks:
|
||||
sbc-inbound:
|
||||
ipv4_address: 172.38.0.13
|
||||
|
||||
rtpengine:
|
||||
image: drachtio/rtpengine:latest
|
||||
ports:
|
||||
- "12222:22222/udp"
|
||||
networks:
|
||||
sbc-inbound:
|
||||
ipv4_address: 172.38.0.14
|
||||
|
||||
|
||||
2
test/docker.env
Normal file
2
test/docker.env
Normal file
@@ -0,0 +1,2 @@
|
||||
# tip: to minify json into a single string as below, see https://codebeautify.org/jsonminifier
|
||||
NODE_CONFIG={"server":{"port":4000,"path":"/auth","auth":{"users":{"foo":"bar"}}},"credentials":{"jambonz.org":[{"username":"john","password":"1234"},{"username":"jane","password":"5678"}]}}
|
||||
@@ -1,3 +1,4 @@
|
||||
require('./docker_start');
|
||||
require('./sip-tests');
|
||||
require('./carrier-origination');
|
||||
//require('./device-origination');
|
||||
require('./docker_stop');
|
||||
|
||||
@@ -88,9 +88,8 @@
|
||||
</action>
|
||||
</nop>
|
||||
|
||||
<!-- Pause 8 seconds, which is approximately the duration of the -->
|
||||
<!-- PCAP file -->
|
||||
<pause milliseconds="4000"/>
|
||||
<!-- Pause briefly -->
|
||||
<pause milliseconds="3000"/>
|
||||
|
||||
<!-- The 'crlf' option inserts a blank line in the statistics report. -->
|
||||
<send retrans="500">
|
||||
@@ -24,7 +24,7 @@ obj.output = () => {
|
||||
return output;
|
||||
};
|
||||
|
||||
obj.sippUac = (file) => {
|
||||
obj.sippUac = (file, bindAddress) => {
|
||||
const cmd = 'docker';
|
||||
const args = [
|
||||
'run', '-ti', '--rm', '--net', `${network}`,
|
||||
@@ -34,9 +34,11 @@ obj.sippUac = (file) => {
|
||||
'-sleep', '250ms',
|
||||
'-nostdin',
|
||||
'-cid_str', `%u-%p@%s-${idx++}`,
|
||||
'drachtio'
|
||||
'sbc'
|
||||
];
|
||||
|
||||
if (bindAddress) args.splice(args.length - 2, 0, '-i', bindAddress);
|
||||
|
||||
clearOutput();
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
Reference in New Issue
Block a user