mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-10-26 17:44:13 +00:00
1 parent
e09933900b
commit
24621f79dd
31 files changed
+15
-1150
No files matched your search
+2
-19
@@ -41,9 +41,6 @@ test('application tests', async(t) => {
|
||||
url: 'http://example.com/status',
|
||||
method: 'POST'
|
||||
},
|
||||
messaging_hook: {
|
||||
url: 'http://example.com/sms'
|
||||
},
|
||||
app_json : '[\
|
||||
{\
|
||||
"verb": "play",\
|
||||
@@ -71,9 +68,6 @@ test('application tests', async(t) => {
|
||||
url: 'http://example.com/status',
|
||||
method: 'POST'
|
||||
},
|
||||
messaging_hook: {
|
||||
url: 'http://example.com/sms'
|
||||
},
|
||||
app_json : '[\
|
||||
{\
|
||||
"verb": "play",\
|
||||
@@ -110,7 +104,6 @@ test('application tests', async(t) => {
|
||||
json: true,
|
||||
});
|
||||
t.ok(result.name === 'daveh' , 'successfully retrieved application by sid');
|
||||
t.ok(result.messaging_hook.url === 'http://example.com/sms' , 'successfully retrieved messaging_hook from application');
|
||||
t.ok(result.use_for_fallback_speech === 1, 'successfully create use_for_fallback_speech');
|
||||
t.ok(result.fallback_speech_synthesis_vendor === 'google', 'successfully create fallback_speech_synthesis_vendor');
|
||||
t.ok(result.fallback_speech_synthesis_language === 'en-US', 'successfully create fallback_speech_synthesis_language');
|
||||
@@ -151,9 +144,6 @@ test('application tests', async(t) => {
|
||||
call_hook: {
|
||||
url: 'http://example2.com'
|
||||
},
|
||||
messaging_hook: {
|
||||
url: 'http://example2.com/mms'
|
||||
},
|
||||
app_json : '[\
|
||||
{\
|
||||
"verb": "hangup",\
|
||||
@@ -175,12 +165,11 @@ test('application tests', async(t) => {
|
||||
});
|
||||
t.ok(result.statusCode === 204, 'successfully updated application');
|
||||
|
||||
/* validate messaging hook was updated */
|
||||
/* validate application was updated */
|
||||
result = await request.get(`/Applications/${sid}`, {
|
||||
auth: authAdmin,
|
||||
json: true,
|
||||
});
|
||||
t.ok(result.messaging_hook.url === 'http://example2.com/mms' , 'successfully updated messaging_hook');
|
||||
app_json = JSON.parse(result.app_json);
|
||||
t.ok(app_json[0].verb === 'hangup', 'successfully updated app_json from application')
|
||||
t.ok(result.record_all_calls === 1, 'successfully updated record_all_calls from application')
|
||||
@@ -202,15 +191,12 @@ test('application tests', async(t) => {
|
||||
call_hook: {
|
||||
url: 'http://example2.com'
|
||||
},
|
||||
messaging_hook: {
|
||||
url: 'http://example2.com/mms'
|
||||
},
|
||||
app_json : null
|
||||
}
|
||||
});
|
||||
t.ok(result.statusCode === 204, 'successfully updated application');
|
||||
|
||||
/* validate messaging hook was updated */
|
||||
/* validate app_json was removed */
|
||||
result = await request.get(`/Applications/${sid}`, {
|
||||
auth: authAdmin,
|
||||
json: true,
|
||||
@@ -227,9 +213,6 @@ test('application tests', async(t) => {
|
||||
call_hook: {
|
||||
url: 'http://example2.com'
|
||||
},
|
||||
messaging_hook: {
|
||||
url: 'http://example2.com/mms'
|
||||
},
|
||||
app_json : '[\
|
||||
{\
|
||||
"verb": "play",\
|
||||
|
||||
@@ -125,9 +125,6 @@ let result = await request.post('/Applications', {
|
||||
url: 'http://example.com/status',
|
||||
method: 'POST'
|
||||
},
|
||||
messaging_hook: {
|
||||
url: 'http://example.com/sms'
|
||||
},
|
||||
app_json
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
require('./docker_start');
|
||||
require('./create-test-db');
|
||||
require('./sip-gateways');
|
||||
require('./smpp-gateways');
|
||||
require('./service-providers');
|
||||
require('./voip-carriers');
|
||||
require('./accounts');
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
const test = require('tape') ;
|
||||
const ADMIN_TOKEN = '38700987-c7a4-4685-a5bb-af378f9734de';
|
||||
const authAdmin = {bearer: ADMIN_TOKEN};
|
||||
const { createClient } = require('./http-client');
|
||||
const request = createClient({
|
||||
baseUrl: 'http://127.0.0.1:3000/v1'
|
||||
});
|
||||
const {createVoipCarrier, deleteObjectBySid} = require('./utils');
|
||||
|
||||
|
||||
process.on('unhandledRejection', (reason, p) => {
|
||||
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
|
||||
});
|
||||
|
||||
test('smpp gateway tests', async(t) => {
|
||||
const app = require('../app');
|
||||
let sid;
|
||||
try {
|
||||
let result;
|
||||
const voip_carrier_sid = await createVoipCarrier(request);
|
||||
|
||||
/* add a smpp gateway */
|
||||
result = await request.post('/SmppGateways', {
|
||||
resolveWithFullResponse: true,
|
||||
auth: authAdmin,
|
||||
json: true,
|
||||
body: {
|
||||
voip_carrier_sid,
|
||||
ipv4: '192.168.1.1',
|
||||
netmask: 32,
|
||||
inbound: true,
|
||||
outbound: true,
|
||||
use_tls: true,
|
||||
is_primary: true
|
||||
}
|
||||
});
|
||||
t.ok(result.statusCode === 201, 'successfully created smpp gateway ');
|
||||
const sid = result.body.sid;
|
||||
|
||||
/* query all smpp gateways */
|
||||
console.log('querying with ')
|
||||
result = await request.get('/SmppGateways', {
|
||||
qs: {voip_carrier_sid},
|
||||
auth: authAdmin,
|
||||
json: true,
|
||||
});
|
||||
t.ok(result.length === 1 , 'successfully queried all smpp gateways');
|
||||
|
||||
/* query one smpp gateway */
|
||||
result = await request.get(`/SmppGateways/${sid}`, {
|
||||
auth: authAdmin,
|
||||
json: true,
|
||||
});
|
||||
//console.log(`result: ${JSON.stringify(result)}`);
|
||||
t.ok(result.ipv4 === '192.168.1.1' , 'successfully retrieved voip carrier by sid');
|
||||
|
||||
|
||||
/* update smpp gateway */
|
||||
result = await request.put(`/SmppGateways/${sid}`, {
|
||||
auth: authAdmin,
|
||||
json: true,
|
||||
resolveWithFullResponse: true,
|
||||
body: {
|
||||
port: 5061,
|
||||
netmask:24,
|
||||
outbound: false
|
||||
}
|
||||
});
|
||||
t.ok(result.statusCode === 204, 'successfully updated voip carrier');
|
||||
|
||||
/* delete smpp gatewas */
|
||||
result = await request.delete(`/SmppGateways/${sid}`, {
|
||||
resolveWithFullResponse: true,
|
||||
simple: false,
|
||||
json: true,
|
||||
auth: authAdmin
|
||||
});
|
||||
//console.log(`result: ${JSON.stringify(result)}`);
|
||||
t.ok(result.statusCode === 204, 'successfully deleted smpp gateway');
|
||||
|
||||
await deleteObjectBySid(request, '/VoipCarriers', voip_carrier_sid);
|
||||
|
||||
//t.end();
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err);
|
||||
t.end(err);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -180,9 +180,6 @@ test('view-only user tests', async(t) => {
|
||||
url: 'http://example.com/status',
|
||||
method: 'POST'
|
||||
},
|
||||
messaging_hook: {
|
||||
url: 'http://example.com/sms'
|
||||
},
|
||||
app_json : '[\
|
||||
{\
|
||||
"verb": "play",\
|
||||
@@ -241,9 +238,6 @@ test('view-only user tests', async(t) => {
|
||||
url: 'http://example.com/status',
|
||||
method: 'POST'
|
||||
},
|
||||
messaging_hook: {
|
||||
url: 'http://example.com/sms'
|
||||
},
|
||||
app_json : '[\
|
||||
{\
|
||||
"verb": "play",\
|
||||
|
||||
@@ -439,39 +439,6 @@ test('webapp tests', async(t) => {
|
||||
});
|
||||
t.ok(result.statusCode === 204, 'successfully deleted sip gateway for BYOC carrier');
|
||||
|
||||
/* add a smpp gateway to the carrier */
|
||||
result = await request.post('/SmppGateways', {
|
||||
resolveWithFullResponse: true,
|
||||
auth: authUser,
|
||||
json: true,
|
||||
body: {
|
||||
voip_carrier_sid: carrier_sid,
|
||||
ipv4: '192.168.1.1',
|
||||
inbound: true,
|
||||
outbound: true
|
||||
}
|
||||
});
|
||||
t.ok(result.statusCode === 201, 'successfully created smpp gateway for BYOC carrier');
|
||||
gateway_sid = result.body.sid;
|
||||
|
||||
/* update smpp gateway */
|
||||
result = await request.put(`/SmppGateways/${gateway_sid}`, {
|
||||
resolveWithFullResponse: true,
|
||||
auth: authUser,
|
||||
json: true,
|
||||
body: {
|
||||
port: 5080
|
||||
}
|
||||
});
|
||||
t.ok(result.statusCode === 204, 'successfully updated smpp gateway for BYOC carrier');
|
||||
|
||||
/* delete smpp gateway */
|
||||
result = await request.delete(`/SmppGateways/${gateway_sid}`, {
|
||||
resolveWithFullResponse: true,
|
||||
auth: authUser,
|
||||
});
|
||||
t.ok(result.statusCode === 204, 'successfully deleted smpp gateway for BYOC carrier');
|
||||
|
||||
result = await request.get('/Sbcs', {
|
||||
resolveWithFullResponse: true,
|
||||
auth: authUser,
|
||||
@@ -479,14 +446,6 @@ test('webapp tests', async(t) => {
|
||||
});
|
||||
//console.log(result.body);
|
||||
t.ok(result.statusCode === 200 && result.body.length === 1, 'retrieve Sbcs');
|
||||
|
||||
result = await request.get('/Smpps', {
|
||||
resolveWithFullResponse: true,
|
||||
auth: authUser,
|
||||
json: true,
|
||||
});
|
||||
//console.log(result.body);
|
||||
t.ok(result.statusCode === 200 && result.body.length === 2, 'retrieve Smpps');
|
||||
|
||||
/* delete account */
|
||||
result = await request.delete(`/Accounts/${account_sid}`, {
|
||||
|
||||
Reference in new issue
Block a user