Compare commits

...

6 Commits

Author SHA1 Message Date
khang
81def62a03 fix tests 2022-08-17 18:33:53 -04:00
khang
b60fd4bbc4 Fix application /:sid return 2022-08-17 16:33:37 -04:00
Hans Krutzer
08163a31d0 Add missing fields to PhoneNumbers POST request Swagger spec (#53) 2022-08-17 15:55:25 +02:00
Dave Horton
1898ba501d upgrade should a FK to new column 2022-08-09 15:27:26 +02:00
Dave Horton
6f52202deb bugfix: FK was wrong 2022-08-03 17:22:30 +01:00
Dave Horton
0ceb79b568 add siprec_hook_sid to accounts model 2022-08-03 14:56:07 +01:00
8 changed files with 26 additions and 14 deletions

View File

@@ -577,6 +577,6 @@ 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 webhooks (webhook_sid);
ALTER TABLE accounts ADD FOREIGN KEY siprec_hook_sid_idxfk (siprec_hook_sid) REFERENCES applications (application_sid);
SET FOREIGN_KEY_CHECKS=1;

View File

@@ -1580,14 +1580,14 @@
<SQLField>
<name><![CDATA[siprec_hook_sid]]></name>
<type><![CDATA[CHAR(36)]]></type>
<referencesField>webhook_sid</referencesField>
<referencesTable>webhooks</referencesTable>
<referencesField><![CDATA[webhook_sid]]></referencesField>
<referencesTable><![CDATA[webhooks]]></referencesTable>
<referencesField>application_sid</referencesField>
<referencesTable>applications</referencesTable>
<referencesField><![CDATA[application_sid]]></referencesField>
<referencesTable><![CDATA[applications]]></referencesTable>
<sourceCardinality>4</sourceCardinality>
<destinationCardinality>2</destinationCardinality>
<referencesFieldUID><![CDATA[E046BA30-BC18-483C-A5C8-766E7160F574]]></referencesFieldUID>
<referencesTableUID><![CDATA[64D64CB9-0990-4C68-BE71-F9FD43C2BE19]]></referencesTableUID>
<destinationCardinality>1</destinationCardinality>
<referencesFieldUID><![CDATA[EF943D13-DCB0-43C1-B03F-550612E20F9D]]></referencesFieldUID>
<referencesTableUID><![CDATA[E97EE4F0-7ED7-4E8C-862E-D98192D6EAE0]]></referencesTableUID>
<uid><![CDATA[4B8283B4-5E16-4846-A79D-12C6B2E73C86]]></uid>
</SQLField>
<labelWindowIndex><![CDATA[25]]></labelWindowIndex>

View File

@@ -24,7 +24,9 @@ const opts = {
const sql = {
'7006': [
'ALTER TABLE `accounts` ADD COLUMN `siprec_hook_sid` CHAR(36)'
'ALTER TABLE `accounts` ADD COLUMN `siprec_hook_sid` CHAR(36)',
// eslint-disable-next-line max-len
'ALTER TABLE accounts ADD FOREIGN KEY siprec_hook_sid_idxfk (siprec_hook_sid) REFERENCES applications (application_sid)'
]
};

View File

@@ -314,6 +314,10 @@ Account.fields = [
name: 'subspace_sip_teleport_destinations',
type: 'string',
},
{
name: 'siprec_hook_sid',
type: 'string',
},
];
module.exports = Account;

View File

@@ -104,7 +104,7 @@ router.get('/:sid', async(req, res) => {
const account_sid = req.user.hasAccountAuth ? req.user.account_sid : null;
const results = await Application.retrieve(req.params.sid, service_provider_sid, account_sid);
if (results.length === 0) return res.status(404).end();
return res.status(200).json(results);
return res.status(200).json(results[0]);
}
catch (err) {
sysError(logger, res, err);

View File

@@ -1346,6 +1346,12 @@ paths:
schema:
type: object
properties:
account_sid:
type: string
format: uuid
application_sid:
type: string
format: uuid
number:
type: string
description: telephone number

View File

@@ -60,8 +60,8 @@ test('application tests', async(t) => {
auth: authAdmin,
json: true,
});
t.ok(result[0].name === 'daveh' , 'successfully retrieved application by sid');
t.ok(result[0].messaging_hook.url === 'http://example.com/sms' , 'successfully retrieved messaging_hook from application');
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');
/* update applications */
result = await request.put(`/Applications/${sid}`, {
@@ -84,7 +84,7 @@ test('application tests', async(t) => {
auth: authAdmin,
json: true,
});
t.ok(result[0].messaging_hook.url === 'http://example2.com/mms' , 'successfully updated messaging_hook');
t.ok(result.messaging_hook.url === 'http://example2.com/mms' , 'successfully updated messaging_hook');
/* assign phone number to application */
result = await request.put(`/PhoneNumbers/${phone_number_sid}`, {

View File

@@ -318,7 +318,7 @@ test('authentication tests', async(t) => {
json: true
});
//console.log(`result: ${JSON.stringify(result)}`);
t.ok(result.length === 1, 'using account token A1 we are able to retrieve application A1');
t.ok(result.name === "A1-app", 'using account token A1 we are able to retrieve application A1');
/* cannot see app under another account using account token */
result = await request.get(`/Applications/${appA2}`, {