mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-07-04 19:21:53 +00:00
implementation for service_providers.root_domain
This commit is contained in:
@@ -21,7 +21,16 @@ ServiceProvider.fields = [
|
||||
{
|
||||
name: 'description',
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
name: 'root_domain',
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
name: 'registration_hook',
|
||||
type: 'string',
|
||||
}
|
||||
|
||||
];
|
||||
|
||||
module.exports = ServiceProvider;
|
||||
|
||||
@@ -1005,6 +1005,11 @@ components:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
root_domain:
|
||||
type: string
|
||||
registration_hook:
|
||||
type: string
|
||||
format: url
|
||||
required:
|
||||
- service_provider_sid
|
||||
- name
|
||||
|
||||
@@ -11,7 +11,6 @@ process.on('unhandledRejection', (reason, p) => {
|
||||
|
||||
test('service provider tests', async(t) => {
|
||||
const app = require('../app');
|
||||
let sid;
|
||||
try {
|
||||
let result;
|
||||
result = await request.post('/ServiceProviders', {
|
||||
@@ -37,12 +36,51 @@ test('service provider tests', async(t) => {
|
||||
t.ok(result.statusCode === 201, 'successfully created service provider');
|
||||
const sid = result.body.sid;
|
||||
|
||||
/* add a second service provider */
|
||||
result = await request.post('/ServiceProviders', {
|
||||
resolveWithFullResponse: true,
|
||||
auth: authAdmin,
|
||||
json: true,
|
||||
body: {
|
||||
name: 'johndoe',
|
||||
root_domain: 'example.com'
|
||||
}
|
||||
});
|
||||
t.ok(result.statusCode === 201, 'successfully created service provider with a root domain');
|
||||
const sid2 = result.body.sid;
|
||||
|
||||
/* cannot add a service provider with same name*/
|
||||
result = await request.post('/ServiceProviders', {
|
||||
resolveWithFullResponse: true,
|
||||
simple: false,
|
||||
auth: authAdmin,
|
||||
json: true,
|
||||
body: {
|
||||
name: 'daveh'
|
||||
}
|
||||
});
|
||||
t.ok(result.statusCode === 422, 'cannot add two service providers with the same name');
|
||||
|
||||
/* cannot add a service provider with same root domain*/
|
||||
result = await request.post('/ServiceProviders', {
|
||||
resolveWithFullResponse: true,
|
||||
simple: false,
|
||||
auth: authAdmin,
|
||||
json: true,
|
||||
body: {
|
||||
name: 'janedoe',
|
||||
root_domain: 'example.com'
|
||||
}
|
||||
});
|
||||
//console.log(`result: ${JSON.stringify(result)}`);
|
||||
t.ok(result.statusCode === 422, 'cannot add two service providers with the same name');
|
||||
|
||||
/* query all service providers */
|
||||
result = await request.get('/ServiceProviders', {
|
||||
auth: authAdmin,
|
||||
json: true,
|
||||
});
|
||||
t.ok(result.length === 1 , 'successfully queried all service providers');
|
||||
t.ok(result.length === 2 , 'successfully queried all service providers');
|
||||
|
||||
/* query one service providers */
|
||||
result = await request.get(`/ServiceProviders/${sid}`, {
|
||||
@@ -68,7 +106,12 @@ test('service provider tests', async(t) => {
|
||||
auth: authAdmin,
|
||||
resolveWithFullResponse: true,
|
||||
});
|
||||
t.ok(result.statusCode === 204, 'successfully deleted service provider');
|
||||
t.ok(result.statusCode === 204, 'successfully deleted service provider 1');
|
||||
result = await request.delete(`/ServiceProviders/${sid2}`, {
|
||||
auth: authAdmin,
|
||||
resolveWithFullResponse: true,
|
||||
});
|
||||
t.ok(result.statusCode === 204, 'successfully deleted service provider 2');
|
||||
t.end();
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user