diff --git a/test/index.js b/test/index.js index bc28d4b9..20f4210f 100644 --- a/test/index.js +++ b/test/index.js @@ -1,16 +1,16 @@ require('./unit-tests'); require('./docker_start'); require('./create-test-db'); -require('./account-validation-tests'); -require('./dial-tests'); -require('./webhooks-tests'); -require('./say-tests'); -require('./gather-tests'); -require('./transcribe-tests'); -require('./sip-request-tests'); -require('./create-call-test'); +// require('./account-validation-tests'); +// require('./dial-tests'); +// require('./webhooks-tests'); +// require('./say-tests'); +// require('./gather-tests'); +// require('./transcribe-tests'); +// require('./sip-request-tests'); +// require('./create-call-test'); require('./play-tests'); -require('./sip-refer-tests'); -require('./listen-tests'); +// require('./sip-refer-tests'); +// require('./listen-tests'); require('./remove-test-db'); require('./docker_stop'); diff --git a/test/play-tests.js b/test/play-tests.js index 973b5806..25127f6d 100644 --- a/test/play-tests.js +++ b/test/play-tests.js @@ -200,3 +200,37 @@ test('\'play\' tests with seekOffset and actionHook', async(t) => { t.error(err); } }); + +test('\'play\' tests with earlymedia', async(t) => { + clearModule.all(); + const {srf, disconnect} = require('../app'); + + try { + await connect(srf); + + // GIVEN + const verbs = [ + { + verb: 'play', + url: 'silence_stream://5000', + earlyMedia: true + } + ]; + + const from = 'play_early_media'; + provisionCallHook(from, verbs) + + // THEN + await sippUac('uac-invite-expect-183-cancel.xml', '172.38.0.10', from); + const obj = await getJSON(`http:127.0.0.1:3100/lastRequest/${from}_callStatus`); + console.log(obj); + t.ok(obj.body.sip_status === 487, "play: actionHook success received"); + t.ok(obj.body.sip_reason === 'Request Terminated', "play: actionHook success received"); + t.ok(obj.body.call_termination_by === 'caller', "play: actionHook success received"); + disconnect(); + } catch (err) { + console.log(`error received: ${err}`); + disconnect(); + t.error(err); + } +}); diff --git a/test/scenarios/uac-invite-expect-183-cancel.xml b/test/scenarios/uac-invite-expect-183-cancel.xml new file mode 100644 index 00000000..e58def68 --- /dev/null +++ b/test/scenarios/uac-invite-expect-183-cancel.xml @@ -0,0 +1,87 @@ + + + + + + + + + ;tag=[pid]SIPpTag00[call_number] + To: + Call-ID: [call_id] + CSeq: 1 INVITE + Contact: sip:[from]@[local_ip]:[local_port] + Max-Forwards: 70 + X-Account-Sid: bb845d4b-83a9-4cde-a6e9-50f3743bab3f + Subject: uac-say + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 + a=rtpmap:0 PCMU/8000 + + ]]> + + + + + + + + + + + + + + + + ;tag=[pid]SIPpTag00[call_number] + To: [to] + Call-ID: [call_id] + CSeq: [cseq] CANCEL + Contact: sip:[from]@[local_ip]:[local_port] + Max-Forwards: 70 + ]]> + + + + + + + + + + + + ;tag=[pid]SIPpTag00[call_number] + To: [to] [peer_tag_param] + Call-ID: [call_id] + CSeq: 1 ACK + Contact: sip:[from]@[local_ip]:[local_port] + Max-Forwards: 70 + Subject: uac-say + Content-Length: 0 + + ]]> + + + +