Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
callback(err) ;
}) ;
}, (err) => {
if (err) { return reject(err); }
resolve() ;
});
});
}
// disconnect the 2 apps
function disconnect(agents) {
agents.forEach((app) => {app.disconnect();}) ;
clearRequire('./../app');
}
test.skip('Mrf#connect using Promise', (t) => {
t.timeoutAfter(1000);
const srf = new Srf();
srf.connect(config.get('drachtio-uac')) ;
const mrf = new Mrf(srf) ;
connect([srf])
.then(() => {
t.ok(mrf.localAddresses.constructor.name === 'Array', 'mrf.localAddresses is an array');
return mrf.connect(config.get('freeswitch-uac'));
})
.then((mediaserver) => {
t.ok(mediaserver.conn.socket.constructor.name === 'Socket', 'socket connected');
t.ok(mediaserver.srf instanceof Srf, 'mediaserver.srf is an Srf');
t.ok(mediaserver instanceof MediaServer,
t.end() ;
return ;
})
.catch((err) => {
console.error(err);
t.fail(err);
ep.destroy() ;
dlg.destroy() ;
ms.disconnect() ;
disconnect([srf, uac]);
t.end() ;
});
}
});
test.skip('fork audio', (t) => {
t.timeoutAfter(15000);
if (process.env.CI === 'travis') {
t.pass('stubbed out for travis');
t.end();
return;
}
const uac = require('./scripts/call-generator')(config.get('call-generator')) ;
const srf = new Srf();
const mrf = new Mrf(srf) ;
let ms, ep, dlg ;
srf.connect(config.get('drachtio-sut')) ;
connect([srf, uac])
connect([srf])
.then(() => {
return mrf.connect(config.get('freeswitch-uac-fail'));
})
.then((mediaserver) => {
return t.fail('should not have succeeded');
})
.catch((err) => {
t.ok(err.code === 'ECONNREFUSED', 'Promise rejects with connection refused error');
disconnect([srf]);
t.end() ;
});
}) ;
test.skip('Mrf#connect using callback', (t) => {
t.timeoutAfter(1000);
const srf = new Srf();
srf.connect(config.get('drachtio-uac')) ;
const mrf = new Mrf(srf) ;
connect([srf])
.then(() => {
t.ok(mrf.localAddresses.constructor.name === 'Array', 'mrf.localAddresses is an array');
return mrf.connect(config.get('freeswitch-uac'), (err, mediaserver) => {
if (err) return t.fail(err);
t.ok(mediaserver.conn.socket.constructor.name === 'Socket', 'socket connected');
t.ok(mediaserver.srf instanceof Srf, 'mediaserver.srf is an Srf');
t.ok(mediaserver instanceof MediaServer,
})
subscriber.outStream.once('data', function(packet) {
subscriber.inStream.write({
cmd: 'puback'
, messageId: packet.messageId
})
t.notEqual(packet.messageId, 42, 'messageId must differ')
delete packet.messageId
t.deepEqual(packet, expected, 'packet must match')
t.end()
})
})
})
test.skip('subscribe QoS 1 not clean', function(t) {
var broker = aedes()
, publisher
, subscriber = connect(setup(broker), { clean: false, clientId: 'abcde' })
, expected = {
cmd: 'publish'
, topic: 'hello'
, payload: new Buffer('world')
, qos: 1
, dup: false
, length: 14
, retain: false
}
subscriber.inStream.write({
cmd: 'subscribe'
, messageId: 24
t.ok(mediaserver.hasCapability(['ipv4', 'udp']), 'mediaserver has ipv4 udp');
t.ok(mediaserver.hasCapability(['ipv4', 'dtls']), 'mediaserver has ipv4 dtls');
t.ok(!mediaserver.hasCapability(['ipv6', 'udp']), 'mediaserver does not have ipv6 udp');
t.ok(!mediaserver.hasCapability(['ipv6', 'dtls']), 'mediaserver does not have ipv6 dtls');
mediaserver.disconnect() ;
t.ok(mediaserver.conn.socket === null, 'Mrf#disconnect closes socket');
disconnect([srf]);
t.end() ;
return;
})
.catch((err) => {
t.fail(err);
});
}) ;
test.skip('Mrf#connect rejects Promise with error when attempting connection to non-listening port', (t) => {
t.timeoutAfter(1000);
const srf = new Srf();
srf.connect(config.get('drachtio-uac')) ;
const mrf = new Mrf(srf) ;
connect([srf])
.then(() => {
return mrf.connect(config.get('freeswitch-uac-fail'));
})
.then((mediaserver) => {
return t.fail('should not have succeeded');
})
.catch((err) => {
t.ok(err.code === 'ECONNREFUSED', 'Promise rejects with connection refused error');
disconnect([srf]);