diff --git a/index.js b/index.js index 9065c14..e73a0d9 100644 --- a/index.js +++ b/index.js @@ -76,8 +76,10 @@ module.exports = function(mysqlConfig, logger, writeMysqlConfig = null) { lookupTeamsByAccount: require('./lib/lookup-teams-by-account').bind(null, pool, logger), lookupAllVoipCarriers: require('./lib/lookup-all-voip-carriers').bind(null, pool, logger), lookupCarrierBySid: require('./lib/lookup-carrier-by-sid').bind(null, pool, logger), + lookupSipGatewaysByFilters: require('./lib/lookup-sip-gateways-by-filters').bind(null, pool, logger), lookupSipGatewayBySid: require('./lib/lookup-sip-gateway-by-sid').bind(null, pool, logger), lookupSipGatewaysByCarrier: require('./lib/lookup-sip-gateways-by-carrier').bind(null, pool, logger), + updateSipGatewayBySid: require('./lib/update-sip-gateway-by-sid').bind(null, pool, logger), lookupSmppGatewayBySid: require('./lib/lookup-smpp-gateway-by-sid').bind(null, pool, logger), lookupSmppGateways: require('./lib/lookup-smpp-gateways').bind(null, pool, logger), lookupSmppGatewaysByBindCredentials: diff --git a/lib/lookup-sip-gateway-by-signaling-address.js b/lib/lookup-sip-gateway-by-signaling-address.js index f73c6d8..adbe890 100644 --- a/lib/lookup-sip-gateway-by-signaling-address.js +++ b/lib/lookup-sip-gateway-by-signaling-address.js @@ -3,7 +3,7 @@ const CIDRMatcher = require('cidr-matcher'); const sql = ` SELECT sg.sip_gateway_sid, sg.voip_carrier_sid, vc.name, vc.account_sid, -vc.application_sid, sg.inbound, sg.outbound, sg.is_active, sg.ipv4, sg.protocol +vc.application_sid, sg.inbound, sg.outbound, sg.is_active, sg.ipv4, sg.protocol, sg.send_options_ping FROM sip_gateways sg, voip_carriers vc WHERE sg.voip_carrier_sid = vc.voip_carrier_sid AND port = ? diff --git a/lib/lookup-sip-gateways-by-filters.js b/lib/lookup-sip-gateways-by-filters.js new file mode 100644 index 0000000..1290e02 --- /dev/null +++ b/lib/lookup-sip-gateways-by-filters.js @@ -0,0 +1,27 @@ +const debug = require('debug')('jambonz:db-helpers'); + +/** + * Lookup sip gateways by arbitrary filters + * @param {mysql.Pool} pool + * @param {Object} logger + * @param {Object} filters - An object of column names and values to filter on. + */ +async function lookupSipGatewaysByFilters(pool, logger, filters) { + const pp = pool.promise(); + + let sql = 'SELECT * FROM sip_gateways WHERE '; + const params = []; + for (const [key, value] of Object.entries(filters)) { + sql += `${key} = ? AND `; + params.push(value); + } + + // Remove trailing ' AND ' + sql = sql.slice(0, -5); + + const [r] = await pp.execute(sql, params); + debug(`results: ${JSON.stringify(r)}`); + return r; +} + +module.exports = lookupSipGatewaysByFilters; diff --git a/lib/update-sip-gateway-by-sid.js b/lib/update-sip-gateway-by-sid.js new file mode 100644 index 0000000..ecc1d72 --- /dev/null +++ b/lib/update-sip-gateway-by-sid.js @@ -0,0 +1,33 @@ +const debug = require('debug')('jambonz:db-helpers'); + +/** + * Update a sip gateway given its sid and an object of values. + * @param {mysql.Pool} pool + * @param {Object} logger + * @param {string} sip_gateway_sid - The sid of the gateway to update. + * @param {Object} values - An object where each key-value pair represents a column name and a new value. + */ +async function updateSipGatewayBySid(pool, logger, sip_gateway_sid, values) { + const pp = pool.promise(); + + // Begin building the SQL query string and parameters. + let sql = 'UPDATE sip_gateways SET '; + const params = []; + for (const [key, value] of Object.entries(values)) { + sql += `${key} = ?, `; + params.push(value); + } + + // Remove trailing comma and space + sql = sql.slice(0, -2); + + // Add WHERE clause + sql += ' WHERE sip_gateway_sid = ?'; + params.push(sip_gateway_sid); + + const [r] = await pp.execute(sql, params); + debug(`results: ${JSON.stringify(r)}`); + return r; +} + +module.exports = updateSipGatewayBySid; diff --git a/test/db/jambones-sql.sql b/test/db/jambones-sql.sql index 5d59747..9ef0508 100644 --- a/test/db/jambones-sql.sql +++ b/test/db/jambones-sql.sql @@ -1,4 +1,5 @@ /* SQLEditor (MySQL (2))*/ + SET FOREIGN_KEY_CHECKS=0; DROP TABLE IF EXISTS account_static_ips; @@ -53,6 +54,8 @@ DROP TABLE IF EXISTS signup_history; DROP TABLE IF EXISTS smpp_addresses; +DROP TABLE IF EXISTS google_custom_voices; + DROP TABLE IF EXISTS speech_credentials; DROP TABLE IF EXISTS system_information; @@ -133,9 +136,12 @@ CREATE TABLE clients ( client_sid CHAR(36) NOT NULL UNIQUE , account_sid CHAR(36) NOT NULL, -is_active BOOLEAN NOT NULL DEFAULT true, -username VARCHAR(255) NOT NULL, -password VARCHAR(255), +is_active BOOLEAN NOT NULL DEFAULT 1, +username VARCHAR(64), +password VARCHAR(1024), +allow_direct_app_calling BOOLEAN NOT NULL DEFAULT 1, +allow_direct_queue_calling BOOLEAN NOT NULL DEFAULT 1, +allow_direct_user_calling BOOLEAN NOT NULL DEFAULT 1, PRIMARY KEY (client_sid) ); @@ -334,9 +340,20 @@ last_tested DATETIME, tts_tested_ok BOOLEAN, stt_tested_ok BOOLEAN, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, +label VARCHAR(64), PRIMARY KEY (speech_credential_sid) ); +CREATE TABLE google_custom_voices +( +google_custom_voice_sid CHAR(36) NOT NULL UNIQUE , +speech_credential_sid CHAR(36) NOT NULL, +model VARCHAR(512) NOT NULL, +reported_usage ENUM('REPORTED_USAGE_UNSPECIFIED','REALTIME','OFFLINE') DEFAULT 'REALTIME', +name VARCHAR(64) NOT NULL, +PRIMARY KEY (google_custom_voice_sid) +); + CREATE TABLE system_information ( domain_name VARCHAR(255), @@ -423,7 +440,7 @@ PRIMARY KEY (smpp_gateway_sid) CREATE TABLE phone_numbers ( phone_number_sid CHAR(36) UNIQUE , -number VARCHAR(132) NOT NULL UNIQUE , +number VARCHAR(132) NOT NULL, voip_carrier_sid CHAR(36), account_sid CHAR(36), application_sid CHAR(36), @@ -436,11 +453,13 @@ CREATE TABLE sip_gateways sip_gateway_sid CHAR(36), ipv4 VARCHAR(128) NOT NULL COMMENT 'ip address or DNS name of the gateway. For gateways providing inbound calling service, ip address is required.', netmask INTEGER NOT NULL DEFAULT 32, -port INTEGER NOT NULL DEFAULT 5060 COMMENT 'sip signaling port', +port INTEGER COMMENT 'sip signaling port', inbound BOOLEAN NOT NULL COMMENT 'if true, whitelist this IP to allow inbound calls from the gateway', outbound BOOLEAN NOT NULL COMMENT 'if true, include in least-cost routing when placing calls to the PSTN', voip_carrier_sid CHAR(36) NOT NULL, is_active BOOLEAN NOT NULL DEFAULT 1, +send_options_ping BOOLEAN NOT NULL DEFAULT 0, +pad_crypto BOOLEAN NOT NULL DEFAULT 0, protocol ENUM('udp','tcp','tls', 'tls/srtp') DEFAULT 'udp' COMMENT 'Outbound call protocol', PRIMARY KEY (sip_gateway_sid) ) COMMENT='A whitelisted sip gateway used for origination/termination'; @@ -478,8 +497,18 @@ app_json TEXT, speech_synthesis_vendor VARCHAR(64) NOT NULL DEFAULT 'google', speech_synthesis_language VARCHAR(12) NOT NULL DEFAULT 'en-US', speech_synthesis_voice VARCHAR(64), +speech_synthesis_label VARCHAR(64), speech_recognizer_vendor VARCHAR(64) NOT NULL DEFAULT 'google', speech_recognizer_language VARCHAR(64) NOT NULL DEFAULT 'en-US', +speech_recognizer_label VARCHAR(64), +use_for_fallback_speech BOOLEAN DEFAULT false, +fallback_speech_synthesis_vendor VARCHAR(64), +fallback_speech_synthesis_language VARCHAR(12), +fallback_speech_synthesis_voice VARCHAR(64), +fallback_speech_synthesis_label VARCHAR(64), +fallback_speech_recognizer_vendor VARCHAR(64), +fallback_speech_recognizer_language VARCHAR(64), +fallback_speech_recognizer_label VARCHAR(64), created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, record_all_calls BOOLEAN NOT NULL DEFAULT false, PRIMARY KEY (application_sid) @@ -543,11 +572,10 @@ ALTER TABLE call_routes ADD FOREIGN KEY account_sid_idxfk_3 (account_sid) REFERE ALTER TABLE call_routes ADD FOREIGN KEY application_sid_idxfk (application_sid) REFERENCES applications (application_sid); CREATE INDEX client_sid_idx ON clients (client_sid); -ALTER TABLE clients ADD FOREIGN KEY account_sid_idxfk_4 (account_sid) REFERENCES accounts (account_sid); +ALTER TABLE clients ADD CONSTRAINT account_sid_idxfk_13 FOREIGN KEY account_sid_idxfk_13 (account_sid) REFERENCES accounts (account_sid); -CREATE INDEX username_idx ON clients (username); CREATE INDEX dns_record_sid_idx ON dns_records (dns_record_sid); -ALTER TABLE dns_records ADD FOREIGN KEY account_sid_idxfk_5 (account_sid) REFERENCES accounts (account_sid); +ALTER TABLE dns_records ADD FOREIGN KEY account_sid_idxfk_4 (account_sid) REFERENCES accounts (account_sid); CREATE INDEX lcr_sid_idx ON lcr_routes (lcr_sid); ALTER TABLE lcr_routes ADD FOREIGN KEY lcr_sid_idxfk (lcr_sid) REFERENCES lcr (lcr_sid); @@ -576,14 +604,14 @@ ALTER TABLE account_products ADD FOREIGN KEY product_sid_idxfk (product_sid) REF CREATE INDEX account_offer_sid_idx ON account_offers (account_offer_sid); CREATE INDEX account_sid_idx ON account_offers (account_sid); -ALTER TABLE account_offers ADD FOREIGN KEY account_sid_idxfk_6 (account_sid) REFERENCES accounts (account_sid); +ALTER TABLE account_offers ADD FOREIGN KEY account_sid_idxfk_5 (account_sid) REFERENCES accounts (account_sid); CREATE INDEX product_sid_idx ON account_offers (product_sid); ALTER TABLE account_offers ADD FOREIGN KEY product_sid_idxfk_1 (product_sid) REFERENCES products (product_sid); CREATE INDEX api_key_sid_idx ON api_keys (api_key_sid); CREATE INDEX account_sid_idx ON api_keys (account_sid); -ALTER TABLE api_keys ADD FOREIGN KEY account_sid_idxfk_7 (account_sid) REFERENCES accounts (account_sid); +ALTER TABLE api_keys ADD FOREIGN KEY account_sid_idxfk_6 (account_sid) REFERENCES accounts (account_sid); CREATE INDEX service_provider_sid_idx ON api_keys (service_provider_sid); ALTER TABLE api_keys ADD FOREIGN KEY service_provider_sid_idxfk (service_provider_sid) REFERENCES service_providers (service_provider_sid); @@ -597,7 +625,7 @@ ALTER TABLE sbc_addresses ADD FOREIGN KEY service_provider_sid_idxfk_1 (service_ CREATE INDEX ms_teams_tenant_sid_idx ON ms_teams_tenants (ms_teams_tenant_sid); ALTER TABLE ms_teams_tenants ADD FOREIGN KEY service_provider_sid_idxfk_2 (service_provider_sid) REFERENCES service_providers (service_provider_sid); -ALTER TABLE ms_teams_tenants ADD FOREIGN KEY account_sid_idxfk_8 (account_sid) REFERENCES accounts (account_sid); +ALTER TABLE ms_teams_tenants ADD FOREIGN KEY account_sid_idxfk_7 (account_sid) REFERENCES accounts (account_sid); ALTER TABLE ms_teams_tenants ADD FOREIGN KEY application_sid_idxfk_1 (application_sid) REFERENCES applications (application_sid); @@ -610,20 +638,22 @@ CREATE INDEX smpp_address_sid_idx ON smpp_addresses (smpp_address_sid); CREATE INDEX service_provider_sid_idx ON smpp_addresses (service_provider_sid); ALTER TABLE smpp_addresses ADD FOREIGN KEY service_provider_sid_idxfk_4 (service_provider_sid) REFERENCES service_providers (service_provider_sid); -CREATE UNIQUE INDEX speech_credentials_idx_1 ON speech_credentials (vendor,account_sid); - CREATE INDEX speech_credential_sid_idx ON speech_credentials (speech_credential_sid); CREATE INDEX service_provider_sid_idx ON speech_credentials (service_provider_sid); ALTER TABLE speech_credentials ADD FOREIGN KEY service_provider_sid_idxfk_5 (service_provider_sid) REFERENCES service_providers (service_provider_sid); CREATE INDEX account_sid_idx ON speech_credentials (account_sid); -ALTER TABLE speech_credentials ADD FOREIGN KEY account_sid_idxfk_9 (account_sid) REFERENCES accounts (account_sid); +ALTER TABLE speech_credentials ADD FOREIGN KEY account_sid_idxfk_8 (account_sid) REFERENCES accounts (account_sid); + +CREATE INDEX google_custom_voice_sid_idx ON google_custom_voices (google_custom_voice_sid); +CREATE INDEX speech_credential_sid_idx ON google_custom_voices (speech_credential_sid); +ALTER TABLE google_custom_voices ADD FOREIGN KEY speech_credential_sid_idxfk (speech_credential_sid) REFERENCES speech_credentials (speech_credential_sid) ON DELETE CASCADE; CREATE INDEX user_sid_idx ON users (user_sid); CREATE INDEX email_idx ON users (email); CREATE INDEX phone_idx ON users (phone); CREATE INDEX account_sid_idx ON users (account_sid); -ALTER TABLE users ADD FOREIGN KEY account_sid_idxfk_10 (account_sid) REFERENCES accounts (account_sid); +ALTER TABLE users ADD FOREIGN KEY account_sid_idxfk_9 (account_sid) REFERENCES accounts (account_sid); CREATE INDEX service_provider_sid_idx ON users (service_provider_sid); ALTER TABLE users ADD FOREIGN KEY service_provider_sid_idxfk_6 (service_provider_sid) REFERENCES service_providers (service_provider_sid); @@ -631,7 +661,7 @@ ALTER TABLE users ADD FOREIGN KEY service_provider_sid_idxfk_6 (service_provider CREATE INDEX email_activation_code_idx ON users (email_activation_code); CREATE INDEX voip_carrier_sid_idx ON voip_carriers (voip_carrier_sid); CREATE INDEX account_sid_idx ON voip_carriers (account_sid); -ALTER TABLE voip_carriers ADD FOREIGN KEY account_sid_idxfk_11 (account_sid) REFERENCES accounts (account_sid); +ALTER TABLE voip_carriers ADD FOREIGN KEY account_sid_idxfk_10 (account_sid) REFERENCES accounts (account_sid); CREATE INDEX service_provider_sid_idx ON voip_carriers (service_provider_sid); ALTER TABLE voip_carriers ADD FOREIGN KEY service_provider_sid_idxfk_7 (service_provider_sid) REFERENCES service_providers (service_provider_sid); @@ -648,12 +678,14 @@ CREATE INDEX smpp_gateway_sid_idx ON smpp_gateways (smpp_gateway_sid); CREATE INDEX voip_carrier_sid_idx ON smpp_gateways (voip_carrier_sid); ALTER TABLE smpp_gateways ADD FOREIGN KEY voip_carrier_sid_idxfk (voip_carrier_sid) REFERENCES voip_carriers (voip_carrier_sid); +CREATE UNIQUE INDEX phone_numbers_unique_idx_voip_carrier_number ON phone_numbers (number,voip_carrier_sid); + CREATE INDEX phone_number_sid_idx ON phone_numbers (phone_number_sid); CREATE INDEX number_idx ON phone_numbers (number); CREATE INDEX voip_carrier_sid_idx ON phone_numbers (voip_carrier_sid); ALTER TABLE phone_numbers ADD FOREIGN KEY voip_carrier_sid_idxfk_1 (voip_carrier_sid) REFERENCES voip_carriers (voip_carrier_sid); -ALTER TABLE phone_numbers ADD FOREIGN KEY account_sid_idxfk_12 (account_sid) REFERENCES accounts (account_sid); +ALTER TABLE phone_numbers ADD FOREIGN KEY account_sid_idxfk_11 (account_sid) REFERENCES accounts (account_sid); ALTER TABLE phone_numbers ADD FOREIGN KEY application_sid_idxfk_3 (application_sid) REFERENCES applications (application_sid); @@ -677,7 +709,7 @@ CREATE INDEX service_provider_sid_idx ON applications (service_provider_sid); ALTER TABLE applications ADD FOREIGN KEY service_provider_sid_idxfk_9 (service_provider_sid) REFERENCES service_providers (service_provider_sid); CREATE INDEX account_sid_idx ON applications (account_sid); -ALTER TABLE applications ADD FOREIGN KEY account_sid_idxfk_13 (account_sid) REFERENCES accounts (account_sid); +ALTER TABLE applications ADD FOREIGN KEY account_sid_idxfk_12 (account_sid) REFERENCES accounts (account_sid); ALTER TABLE applications ADD FOREIGN KEY call_hook_sid_idxfk (call_hook_sid) REFERENCES webhooks (webhook_sid); @@ -702,4 +734,5 @@ ALTER TABLE accounts ADD FOREIGN KEY queue_event_hook_sid_idxfk (queue_event_hoo ALTER TABLE accounts ADD FOREIGN KEY device_calling_application_sid_idxfk (device_calling_application_sid) REFERENCES applications (application_sid); ALTER TABLE accounts ADD FOREIGN KEY siprec_hook_sid_idxfk (siprec_hook_sid) REFERENCES applications (application_sid); -SET FOREIGN_KEY_CHECKS=1; \ No newline at end of file + +SET FOREIGN_KEY_CHECKS=1; diff --git a/test/db/populate-test-data.sql b/test/db/populate-test-data.sql index fd971fb..a60d2ae 100644 --- a/test/db/populate-test-data.sql +++ b/test/db/populate-test-data.sql @@ -20,12 +20,12 @@ values ('5f200a4f-b997-4f04-b56e-03c627ea547d', 'Account A#', '3f35518f-5a0d-4c2 insert into voip_carriers (voip_carrier_sid, name, account_sid, service_provider_sid, e164_leading_plus, requires_register, register_username, register_sip_realm, register_password) values ('287c1452-620d-4195-9f19-c9814ef90d78', 'westco', 'ee9d7d49-b3e4-4fdb-9d66-661149f717e8', null, 1, 1, 'janedoe', 'mydomain.com', 'test123'); -insert into sip_gateways (sip_gateway_sid, voip_carrier_sid, ipv4, inbound, outbound) -values ('124a5339-c62c-4075-9e19-f4de70a96597', '287c1452-620d-4195-9f19-c9814ef90d78', '3.3.3.3', true, true); +insert into sip_gateways (sip_gateway_sid, voip_carrier_sid, ipv4, port, inbound, outbound) +values ('124a5339-c62c-4075-9e19-f4de70a96597', '287c1452-620d-4195-9f19-c9814ef90d78', '3.3.3.3', 5060, true, true); insert into sip_gateways (sip_gateway_sid, voip_carrier_sid, ipv4, port, inbound, outbound) values ('efbc4830-57cd-4c78-a56f-d64fdf210fe8', '287c1452-620d-4195-9f19-c9814ef90d78', '3.3.3.3', 5062, false, true); -insert into sip_gateways (sip_gateway_sid, voip_carrier_sid, ipv4, inbound, outbound) -values ('1e674a9a-763d-4247-8a54-b7a56ab6b605', '287c1452-620d-4195-9f19-c9814ef90d78', '3.3.3.4/31', true, false); +insert into sip_gateways (sip_gateway_sid, voip_carrier_sid, ipv4, port, inbound, outbound) +values ('1e674a9a-763d-4247-8a54-b7a56ab6b605', '287c1452-620d-4195-9f19-c9814ef90d78', '3.3.3.4/31', 5060, true, false); insert into lcr (lcr_sid, name, is_active, account_sid ) values ('4a968442-3d40-4704-83ae-b28f9b4f91d3', 'Test 1', 1, 'ee9d7d49-b3e4-4fdb-9d66-661149f717e8'); insert into lcr (lcr_sid, name, is_active, service_provider_sid ) values ('4a968442-3d40-4704-83ae-b28f9b4f91d4', 'Test 2', 1, '3f35518f-5a0d-4c2e-90a5-2407bb3b36f0'); diff --git a/test/db/populate-test-data2.sql b/test/db/populate-test-data2.sql index 9099857..9d45238 100644 --- a/test/db/populate-test-data2.sql +++ b/test/db/populate-test-data2.sql @@ -14,8 +14,8 @@ values ('5f190a4f-b997-4f04-b56e-03c627ea547d', 'Account A2', '3f35518f-5a0d-4c2 insert into voip_carriers (voip_carrier_sid, name, account_sid, service_provider_sid, e164_leading_plus) values ('387c1452-620d-4195-9f19-c9814ef90d78', 'westco2', NULL, '3f35518f-5a0d-4c2e-90a5-2407bb3b36f0', 1); -insert into sip_gateways (sip_gateway_sid, voip_carrier_sid, ipv4, inbound, outbound) -values ('88191aa4-fff2-4c64-b005-43414a8e94d7', '387c1452-620d-4195-9f19-c9814ef90d78', '6.6.6.6', true, true); +insert into sip_gateways (sip_gateway_sid, voip_carrier_sid, ipv4, port, inbound, outbound) +values ('88191aa4-fff2-4c64-b005-43414a8e94d7', '387c1452-620d-4195-9f19-c9814ef90d78', '6.6.6.6', 5060, true, true); insert into voip_carriers (voip_carrier_sid, name, account_sid, service_provider_sid, e164_leading_plus) values ('287c1452-620d-4195-9f19-c9814ef90d78', 'westco', 'ee9d7d49-b3e4-4fdb-9d66-661149f717e8', '3f35518f-5a0d-4c2e-90a5-2407bb3b36f0', 1); insert into voip_carriers (voip_carrier_sid, name, account_sid, service_provider_sid) values ('ceafc86d-11f3-4dbd-9523-1e0f4502bfc7', 'eastco', 'ee9d7d49-b3e4-4fdb-9d66-661149f717e8', '3f35518f-5a0d-4c2e-90a5-2407bb3b36f0'); diff --git a/test/sip-gateways.js b/test/sip-gateways.js index bd4d233..1f53dec 100644 --- a/test/sip-gateways.js +++ b/test/sip-gateways.js @@ -1,5 +1,6 @@ const test = require('tape').test ; const config = require('config'); +const lookupSipGatewaysByFilters = require('../lib/lookup-sip-gateways-by-filters'); const mysqlOpts = config.get('mysql'); process.on('unhandledRejection', (reason, p) => { @@ -11,16 +12,29 @@ test('sip gateways tests', async(t) => { const { lookupSipGatewayBySignalingAddress, lookupSipGatewaysByCarrier, - lookupSipGatewayBySid + lookupSipGatewayBySid, + lookupSipGatewaysByFilters, + updateSipGatewayBySid } = fn(mysqlOpts); try { let gateways = await lookupSipGatewaysByCarrier('287c1452-620d-4195-9f19-c9814ef90d78'); t.ok(gateways.length === 3 && gateways[2].port === 5062, 'retrieves sip gateways for a voip carrier'); //console.log(gateways); + gateways = await lookupSipGatewaysByFilters({voip_carrier_sid: '287c1452-620d-4195-9f19-c9814ef90d78'}); + t.ok(gateways.length === 3 && gateways[2].port === 5062, 'retrieves sip gateways for a voip carrier'); + let gateway = await lookupSipGatewayBySignalingAddress('3.3.3.3', 5060); //console.log(`gateway: ${JSON.stringify(gateway)}`); t.ok(gateway.sip_gateway_sid === '124a5339-c62c-4075-9e19-f4de70a96597', 'retrieves sip gateway with default port'); + t.ok(gateway.send_options_ping === 0, 'retrieves sip gateway with send_options_ping'); + + await updateSipGatewayBySid(gateway.sip_gateway_sid, {send_options_ping: true}); + + gateway = await lookupSipGatewayBySignalingAddress('3.3.3.3', 5060); + //console.log(`gateway: ${JSON.stringify(gateway)}`); + t.ok(gateway.sip_gateway_sid === '124a5339-c62c-4075-9e19-f4de70a96597', 'retrieves sip gateway with default port'); + t.ok(gateway.send_options_ping === 1, 'retrieves sip gateway with send_options_ping'); gateway = await lookupSipGatewayBySignalingAddress('3.3.3.3', 5062); //console.log(`gateway: ${JSON.stringify(gateway)}`);