From 2f20ae5fed6d7c8db6ca3eb8c261e06b7f1bce3a Mon Sep 17 00:00:00 2001 From: Quan HL Date: Tue, 10 Sep 2024 16:33:18 +0700 Subject: [PATCH] support carrier pad crypto --- db/jambones-sql.sql | 5 +++-- db/jambones.sqs | 24 ++++++++++++++++-------- db/upgrade-jambonz-db.js | 1 + lib/models/voip-carrier.js | 6 +++++- test/voip-carriers.js | 10 +++++++++- 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/db/jambones-sql.sql b/db/jambones-sql.sql index 19776da9..8dab12c6 100644 --- a/db/jambones-sql.sql +++ b/db/jambones-sql.sql @@ -162,7 +162,7 @@ regex VARCHAR(32) NOT NULL COMMENT 'regex-based pattern match against dialed num description VARCHAR(1024), priority INTEGER NOT NULL COMMENT 'lower priority routes are attempted first', PRIMARY KEY (lcr_route_sid) -) COMMENT='An ordered list of digit patterns in an LCR table. The pat'; +) COMMENT='An ordered list of digit patterns in an LCR table. The patterns are tested in sequence until one matches'; CREATE TABLE lcr ( @@ -173,7 +173,7 @@ default_carrier_set_entry_sid CHAR(36) COMMENT 'default carrier/route to use whe service_provider_sid CHAR(36), account_sid CHAR(36), PRIMARY KEY (lcr_sid) -) COMMENT='An LCR (least cost routing) table that is used by a service '; +) COMMENT='An LCR (least cost routing) table that is used by a service provider or account to make decisions about routing outbound calls when multiple carriers are available.'; CREATE TABLE password_settings ( @@ -413,6 +413,7 @@ register_from_user VARCHAR(128), register_from_domain VARCHAR(255), register_public_ip_in_contact BOOLEAN NOT NULL DEFAULT false, register_status VARCHAR(4096), +pad_crypto BOOLEAN NOT NULL DEFAULT 0, PRIMARY KEY (voip_carrier_sid) ) COMMENT='A Carrier or customer PBX that can send or receive calls'; diff --git a/db/jambones.sqs b/db/jambones.sqs index 4c8cf59f..97256e37 100644 --- a/db/jambones.sqs +++ b/db/jambones.sqs @@ -551,7 +551,7 @@ 293.00 - 540.00 + 560.00 6 @@ -737,6 +737,14 @@ + + + + + + + + @@ -3106,7 +3114,7 @@ - + @@ -3120,14 +3128,14 @@ - + - - - - - + + + + + diff --git a/db/upgrade-jambonz-db.js b/db/upgrade-jambonz-db.js index 5aa97eab..09b955b0 100644 --- a/db/upgrade-jambonz-db.js +++ b/db/upgrade-jambonz-db.js @@ -200,6 +200,7 @@ const sql = { ], 9002: [ 'ALTER TABLE system_information ADD COLUMN private_network_cidr VARCHAR(8192)', + 'ALTER TABLE voip_carriers ADD COLUMN pad_crypto BOOLEAN NOT NULL DEFAULT 0', ] }; diff --git a/lib/models/voip-carrier.js b/lib/models/voip-carrier.js index 7da1a7ad..dfbc3c7a 100644 --- a/lib/models/voip-carrier.js +++ b/lib/models/voip-carrier.js @@ -136,7 +136,11 @@ VoipCarrier.fields = [ { name: 'register_status', type: 'string' - } + }, + { + name: 'pad_crypto', + type: 'number' + }, ]; module.exports = VoipCarrier; diff --git a/test/voip-carriers.js b/test/voip-carriers.js index 68b95689..fa980d60 100644 --- a/test/voip-carriers.js +++ b/test/voip-carriers.js @@ -42,6 +42,7 @@ test('voip carrier tests', async(t) => { json: true, }); t.ok(result.name === 'daveh' , 'successfully retrieved voip carrier by sid'); + t.ok(result.pad_crypto === 0 , 'default pad_crypto is 0'); /* fail to query one voip carriers with invalid uuid */ try { @@ -65,11 +66,18 @@ test('voip carrier tests', async(t) => { register_sip_realm: 'bar', register_password: 'baz', register_from_user: 'fromme', - register_from_domain: 'fromdomain' + register_from_domain: 'fromdomain', + pad_crypto: true } }); t.ok(result.statusCode === 204, 'successfully updated voip carrier'); + result = await request.get(`/VoipCarriers/${sid}`, { + auth: authAdmin, + json: true, + }); + t.ok(result.pad_crypto === 1 , 'pad_crypto is updated 1'); + /* provision a phone number for the voip carrier */ result = await request.post('/PhoneNumbers', { resolveWithFullResponse: true,