Skip to content

Commit

Permalink
added private_newtwork_cidr to system_information table (#341)
Browse files Browse the repository at this point in the history
* added private_newtwork_cidr to system_information table

* db schema upgrade to add system_information.private_network_cidr in 0.9.2

* increase size of system_information.private_network_cidr to varchar(8192)
  • Loading branch information
davehorton committed Aug 18, 2024
1 parent 2d2b98d commit ed71abd
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
7 changes: 4 additions & 3 deletions db/jambones-sql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 patterns are tested in sequence until one matches';
) COMMENT='An ordered list of digit patterns in an LCR table. The pat';

CREATE TABLE lcr
(
Expand All @@ -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 provider or account to make decisions about routing outbound calls when multiple carriers are available.';
) COMMENT='An LCR (least cost routing) table that is used by a service ';

CREATE TABLE password_settings
(
Expand Down Expand Up @@ -358,7 +358,8 @@ CREATE TABLE system_information
(
domain_name VARCHAR(255),
sip_domain_name VARCHAR(255),
monitoring_domain_name VARCHAR(255)
monitoring_domain_name VARCHAR(255),
private_network_cidr VARCHAR(8192)
);

CREATE TABLE users
Expand Down
17 changes: 11 additions & 6 deletions db/jambones.sqs
Original file line number Diff line number Diff line change
Expand Up @@ -2808,7 +2808,7 @@
</location>
<size>
<width>266.00</width>
<height>80.00</height>
<height>100.00</height>
</size>
<zorder>35</zorder>
<SQLField>
Expand All @@ -2826,6 +2826,11 @@
<type><![CDATA[VARCHAR(255)]]></type>
<uid><![CDATA[0A8DB34E-76C9-4D40-9E31-786E0228DCEE]]></uid>
</SQLField>
<SQLField>
<name><![CDATA[private_network_cidr]]></name>
<type><![CDATA[VARCHAR(8192)]]></type>
<uid><![CDATA[45A2CE92-0BA7-4156-AE05-750D63F386F3]]></uid>
</SQLField>
<labelWindowIndex><![CDATA[3]]></labelWindowIndex>
<ui.treeExpanded><![CDATA[1]]></ui.treeExpanded>
<uid><![CDATA[F0C2DC80-CBA7-4BE7-8856-D10B062A7B17]]></uid>
Expand Down Expand Up @@ -3115,14 +3120,14 @@
<RightSidebarWidth><![CDATA[1235.000000]]></RightSidebarWidth>
<sidebarIndex><![CDATA[2]]></sidebarIndex>
<snapToGrid><![CDATA[0]]></snapToGrid>
<SourceSidebarWidth><![CDATA[312.000000]]></SourceSidebarWidth>
<SourceSidebarWidth><![CDATA[0.000000]]></SourceSidebarWidth>
<SQLEditorFileFormatVersion><![CDATA[4]]></SQLEditorFileFormatVersion>
<uid><![CDATA[58C99A00-06C9-478C-A667-C63842E088F3]]></uid>
<windowHeight><![CDATA[1079.000000]]></windowHeight>
<windowHeight><![CDATA[873.000000]]></windowHeight>
<windowLocationX><![CDATA[0.000000]]></windowLocationX>
<windowLocationY><![CDATA[0.000000]]></windowLocationY>
<windowScrollOrigin><![CDATA[{1, 0}]]></windowScrollOrigin>
<windowWidth><![CDATA[1676.000000]]></windowWidth>
<windowLocationY><![CDATA[71.000000]]></windowLocationY>
<windowScrollOrigin><![CDATA[{1674.5, 0}]]></windowScrollOrigin>
<windowWidth><![CDATA[1512.000000]]></windowWidth>
</SQLDocumentInfo>
<AllowsIndexRenamingOnInsert><![CDATA[1]]></AllowsIndexRenamingOnInsert>
<defaultLabelExpanded><![CDATA[1]]></defaultLabelExpanded>
Expand Down
4 changes: 4 additions & 0 deletions db/upgrade-jambonz-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ const sql = {
'ALTER TABLE applications MODIFY COLUMN speech_synthesis_voice VARCHAR(256)',
'ALTER TABLE applications MODIFY COLUMN fallback_speech_synthesis_voice VARCHAR(256)',
'ALTER TABLE sip_gateways ADD COLUMN use_sips_scheme BOOLEAN NOT NULL DEFAULT 0',
],
9002: [
'ALTER TABLE system_information ADD COLUMN private_network_cidr VARCHAR(8192)',
]
};

Expand Down Expand Up @@ -230,6 +233,7 @@ const doIt = async() => {
if (val < 8004) upgrades.push(...sql['8004']);
if (val < 8005) upgrades.push(...sql['8005']);
if (val < 9000) upgrades.push(...sql['9000']);
if (val < 9002) upgrades.push(...sql['9002']);

// perform all upgrades
logger.info({upgrades}, 'applying schema upgrades..');
Expand Down
4 changes: 4 additions & 0 deletions lib/models/system-information.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ SystemInformation.fields = [
name: 'monitoring_domain_name',
type: 'string',
},
{
name: 'private_network_cidr',
type: 'string',
},
];

module.exports = SystemInformation;
9 changes: 7 additions & 2 deletions test/system-information.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ test('system information test', async(t) => {
body: {
domain_name: 'test.com',
sip_domain_name: 'sip.test.com',
monitoring_domain_name: 'monitor.test.com'
monitoring_domain_name: 'monitor.test.com',
private_network_cidr: '192.168.1.0/24, 10.10.100.1'
}
});
t.ok(result.statusCode === 201, 'successfully created system information ');
let body = result.body;
t.ok(body.domain_name === 'test.com', 'added domain_name ok');
t.ok(body.sip_domain_name === 'sip.test.com', 'added sip_domain_name ok');
t.ok(body.monitoring_domain_name === 'monitor.test.com', 'added monitoring_domain_name ok');
t.ok(body.private_network_cidr === '192.168.1.0/24, 10.10.100.1', 'added private_network_cidr ok');

result = await request.get('/SystemInformation', {
auth: authAdmin,
Expand All @@ -32,6 +34,7 @@ test('system information test', async(t) => {
t.ok(result.domain_name === 'test.com', 'get domain_name ok');
t.ok(result.sip_domain_name === 'sip.test.com', 'get sip_domain_name ok');
t.ok(result.monitoring_domain_name === 'monitor.test.com', 'get monitoring_domain_name ok');
t.ok(result.private_network_cidr === '192.168.1.0/24, 10.10.100.1', 'get private_network_cidr ok');

result = await request.post('/SystemInformation', {
resolveWithFullResponse: true,
Expand All @@ -40,14 +43,16 @@ test('system information test', async(t) => {
body: {
domain_name: 'test1.com',
sip_domain_name: 'sip1.test.com',
monitoring_domain_name: 'monitor1.test.com'
monitoring_domain_name: 'monitor1.test.com',
private_network_cidr: ''
}
});
t.ok(result.statusCode === 201, 'successfully updated system information ');
body = result.body;
t.ok(body.domain_name === 'test1.com', 'updated domain_name ok');
t.ok(body.sip_domain_name === 'sip1.test.com', 'updated sip_domain_name ok');
t.ok(body.monitoring_domain_name === 'monitor1.test.com', 'updated monitoring_domain_name ok');
t.ok(body.private_network_cidr === '', 'updated private_network_cidr ok');

result = await request.get('/SystemInformation', {
auth: authAdmin,
Expand Down

0 comments on commit ed71abd

Please sign in to comment.