apiman-admin-client
Advanced tools
Comparing version 0.4.0 to 0.5.0
518
index.js
/** | ||
* Copyright 2016 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* Licensed under the Apache License, Version 2.0 (the "License") | ||
* you may not use this file except in compliance with the License. | ||
@@ -19,2 +19,516 @@ * You may obtain a copy of the License at | ||
module.exports = require('./lib/apiman'); | ||
module.exports = exports = { | ||
availablePlugins: availablePlugins, | ||
currentUserAPIOrganizations: currentUserAPIOrganizations, | ||
currentUserAPIs: currentUserAPIs, | ||
currentUserClientOrganizations: currentUserClientOrganizations, | ||
currentUserClients: currentUserClients, | ||
currentUserInfo: currentUserInfo, | ||
currentUserPlanOrganizations: currentUserPlanOrganizations, | ||
currentUserUpdate: currentUserUpdate, | ||
exportData: exportData, | ||
gateway: gateway, | ||
gatewayAdd: gatewayAdd, | ||
gatewayDelete: gatewayDelete, | ||
gateways: gateways, | ||
importData: importData, | ||
organization: organization, | ||
organizationAdd: organizationAdd, | ||
organizationDelete: organizationDelete, | ||
permissions: permissions, | ||
permissionsUser: permissionsUser, | ||
plugin: plugin, | ||
pluginAdd: pluginAdd, | ||
pluginDelete: pluginDelete, | ||
plugins: plugins, | ||
policyDefinition: policyDefinition, | ||
policyDefinitionDelete: policyDefinitionDelete, | ||
policyDefinitions: policyDefinitions, | ||
role: role, | ||
roleDelete: roleDelete, | ||
roles: roles, | ||
status: status, | ||
user: user, | ||
userAPIs: userAPIs, | ||
userClients: userClients, | ||
userOrganizations: userOrganizations, | ||
userUpdate: userUpdate | ||
}; | ||
const roi = require('roi'); | ||
const AVAILABLE_PLUGINS = '/apiman/plugins/availablePlugins/'; | ||
const CURRENT_USER_APIORGS = '/apiman/currentuser/apiorgs/'; | ||
const CURRENT_USER_APIS = '/apiman/currentuser/apis/'; | ||
const CURRENT_USER_CLIENTORGS = '/apiman/currentuser/clientorgs/'; | ||
const CURRENT_USER_CLIENTS = '/apiman/currentuser/clients/'; | ||
const CURRENT_USER_INFO = '/apiman/currentuser/info/'; | ||
const CURRENT_USER_PLANORGS = '/apiman/currentuser/planorgs/'; | ||
const EXPORT = '/apiman/system/export/'; | ||
const GATEWAYS = '/apiman/gateways/'; | ||
const IMPORT = '/apiman/system/import/'; | ||
const ORGANIZATIONS = 'apiman/organizations/'; | ||
const PERMISSIONS = '/apiman/permissions/'; | ||
const PLUGINS = '/apiman/plugins/'; | ||
const POLICY_DEFINITIONS = '/apiman/policyDefs/'; | ||
const ROLES = '/apiman/roles/'; | ||
const STATUS = '/apiman/system/status/'; | ||
const USERS = '/apiman/users/'; | ||
/** | ||
* Returns the status of the apiman system. | ||
* This is useful to use when testing a client's connection | ||
* to the apiman API Manager REST services. | ||
* | ||
* @instance | ||
* @function status | ||
* @returns {Promise} A promise that will resolve with the status information. | ||
*/ | ||
function status (options) { | ||
options.endpoint = options.baseUrl + STATUS; | ||
return roi.get(options); | ||
} | ||
/** | ||
* Exports the data from the API Manager as JSON. All data in the API Manager, | ||
* including global/admin information, will be exported. | ||
* | ||
* @instance | ||
* @function exportData | ||
* @returns {Promise} A promise that will resolve with the exported JSON data. | ||
*/ | ||
function exportData (options) { | ||
options.endpoint = options.baseUrl + EXPORT; | ||
return roi.get(options); | ||
} | ||
/** | ||
* Imports the backup settings into the API Manager. | ||
* | ||
* @instance | ||
* @function importData | ||
* @param {string} filePath - The full path of settings file. | ||
* @returns {Promise} A promise that will resolve with the output messages of the imported configurations. | ||
*/ | ||
function importData (options, filePath) { | ||
options.endpoint = options.baseUrl + IMPORT; | ||
options.headers = {}; | ||
options.headers.Accept = 'text/plain'; | ||
console.log(filePath); | ||
return roi.upload(options, filePath); | ||
} | ||
/** | ||
* Returns all the Gateways that have been configured. | ||
* | ||
* @instance | ||
* @function gateways | ||
* @returns {Promise} A promise that will resolve with gateways. | ||
*/ | ||
function gateways (options) { | ||
options.endpoint = options.baseUrl + GATEWAYS; | ||
return roi.get(options); | ||
} | ||
/** | ||
* Returns information about the Gateway. | ||
* | ||
* @instance | ||
* @param {string} id - The ID of the Gateway. | ||
* @function gateway | ||
* @returns {Promise} A promise that will resolve with gateway. | ||
*/ | ||
function gateway (options, id) { | ||
options.endpoint = options.baseUrl + GATEWAYS + id; | ||
return roi.get(options); | ||
} | ||
/** | ||
* This function is used to create a new Gateway. | ||
* | ||
* @instance | ||
* @param {object} gatewayRepresentation - An object representing the gateway. | ||
* @function gatewayAdd | ||
* @returns {Promise} A promise that will resolve with the new gateway created. | ||
*/ | ||
function gatewayAdd (options, gatewayRepresentation) { | ||
options.endpoint = options.baseUrl + GATEWAYS; | ||
return roi.post(options, gatewayRepresentation); | ||
} | ||
/** | ||
* This function is used to remove a Gateway. | ||
* | ||
* @instance | ||
* @param {string} id - The ID of the Gateway. | ||
* @function gatewayDelete | ||
* @returns {Promise} A promise that will resolve with 204 No Content if the delete is successful. | ||
*/ | ||
function gatewayDelete (options, id) { | ||
options.endpoint = options.baseUrl + GATEWAYS + id; | ||
return roi.del(options); | ||
} | ||
/** | ||
* Returns all of the permissions assigned to the current authenticated user. | ||
* | ||
* @instance | ||
* @function permissions | ||
* @returns {Promise} A promise that will resolve with permissions. | ||
*/ | ||
function permissions (options) { | ||
options.endpoint = options.baseUrl + PERMISSIONS; | ||
return roi.get(options); | ||
} | ||
/** | ||
* Returns all permissions of specific user. | ||
* | ||
* @instance | ||
* @param {string} id - The ID of the user. | ||
* @function permissionsUser | ||
* @returns {Promise} A promise that will resolve with user permissions. | ||
*/ | ||
function permissionsUser (options, id) { | ||
options.endpoint = options.baseUrl + PERMISSIONS + id; | ||
return roi.get(options); | ||
} | ||
/** | ||
* Returns information about the Plugin. | ||
* | ||
* @instance | ||
* @param {string} id - The ID of the Plugin. | ||
* @function plugin | ||
* @returns {Promise} A promise that will resolve with plugin. | ||
*/ | ||
function plugin (options, id) { | ||
options.endpoint = options.baseUrl + PLUGINS + id; | ||
return roi.get(options); | ||
} | ||
/** | ||
* Returns all plugins that have been added to the system. | ||
* | ||
* @instance | ||
* @function plugins | ||
* @returns {Promise} A promise that will resolve with plugins. | ||
*/ | ||
function plugins (options) { | ||
options.endpoint = options.baseUrl + PLUGINS; | ||
return roi.get(options); | ||
} | ||
/** | ||
* This function is used to create a new Plugin. | ||
* | ||
* @instance | ||
* @param {object} pluginRepresentation - An object representing the plugin. | ||
* @function pluginAdd | ||
* @returns {Promise} A promise that will resolve with the new plugin created. | ||
*/ | ||
function pluginAdd (options, pluginRepresentation) { | ||
options.endpoint = options.baseUrl + PLUGINS; | ||
return roi.post(options, pluginRepresentation); | ||
} | ||
/** | ||
* Returns all available plugins. | ||
* | ||
* @instance | ||
* @function availablePlugins | ||
* @returns {Promise} A promise that will resolve with available plugins. | ||
*/ | ||
function availablePlugins (options) { | ||
options.endpoint = options.baseUrl + AVAILABLE_PLUGINS; | ||
return roi.get(options); | ||
} | ||
/** | ||
* This function is used to remove a Plugin. | ||
* | ||
* @instance | ||
* @param {string} id - The ID of the Plugin. | ||
* @function pluginDelete | ||
* @returns {Promise} A promise that will resolve with 204 No Content if the delete is successful. | ||
*/ | ||
function pluginDelete (options, id) { | ||
options.endpoint = options.baseUrl + PLUGINS + id; | ||
return roi.del(options); | ||
} | ||
/** | ||
* Returns all the roles currently defined in apiman. | ||
* | ||
* @instance | ||
* @function roles | ||
* @returns {Promise} A promise that will resolve with roles. | ||
*/ | ||
function roles (options) { | ||
options.endpoint = options.baseUrl + ROLES; | ||
return roi.get(options); | ||
} | ||
/** | ||
* Returns information about the role. | ||
* | ||
* @instance | ||
* @param {string} id - The ID of the role. | ||
* @function role | ||
* @returns {Promise} A promise that will resolve with role. | ||
*/ | ||
function role (options, id) { | ||
options.endpoint = options.baseUrl + ROLES + id; | ||
return roi.get(options); | ||
} | ||
/** | ||
* This function is used to remove a Role. | ||
* | ||
* @instance | ||
* @param {string} id - The ID of the Role. | ||
* @function roleDelete | ||
* @returns {Promise} A promise that will resolve with 204 No Content if the delete is successful. | ||
*/ | ||
function roleDelete (options, id) { | ||
options.endpoint = options.baseUrl + ROLES + id; | ||
return roi.del(options); | ||
} | ||
/** | ||
* Returns information about the policy definition. | ||
* | ||
* @instance | ||
* @param {string} id - The ID of the policy definition. | ||
* @function policyDefinition | ||
* @returns {Promise} A promise that will resolve with policy definition. | ||
*/ | ||
function policyDefinition (options, id) { | ||
options.endpoint = options.baseUrl + POLICY_DEFINITIONS + id; | ||
return roi.get(options); | ||
} | ||
/** | ||
* Returns all the policy definitions currently defined in apiman. | ||
* | ||
* @instance | ||
* @function policyDefinitions | ||
* @returns {Promise} A promise that will resolve with policy definitions. | ||
*/ | ||
function policyDefinitions (options) { | ||
options.endpoint = options.baseUrl + POLICY_DEFINITIONS; | ||
return roi.get(options); | ||
} | ||
/** | ||
* This function is used to remove a policy definition. | ||
* | ||
* @instance | ||
* @param {string} id - The ID of the policy definition. | ||
* @function policyDefinitionDelete | ||
* @returns {Promise} A promise that will resolve with 204 No Content if the delete is successful. | ||
*/ | ||
function policyDefinitionDelete (options, id) { | ||
options.endpoint = options.baseUrl + POLICY_DEFINITIONS + id; | ||
return roi.del(options); | ||
} | ||
/** | ||
* Returns all the organizations with APIs for the current user. | ||
* | ||
* @instance | ||
* @function currentUserAPIOrganizations | ||
* @returns {Promise} A promise that will resolve with organizations. | ||
*/ | ||
function currentUserAPIOrganizations (options) { | ||
options.endpoint = options.baseUrl + CURRENT_USER_APIORGS; | ||
return roi.get(options); | ||
} | ||
/** | ||
* Returns all of the APIs the current user has permission to edit. | ||
* | ||
* @instance | ||
* @function currentUserAPIs | ||
* @returns {Promise} A promise that will resolve with current user APIs. | ||
*/ | ||
function currentUserAPIs (options) { | ||
options.endpoint = options.baseUrl + CURRENT_USER_APIS; | ||
return roi.get(options); | ||
} | ||
/** | ||
* Returns all the organizations with clients for the current user | ||
* has permission to edit clients. | ||
* | ||
* @instance | ||
* @function currentUserClientOrganizations | ||
* @returns {Promise} A promise that will resolve with organizations. | ||
*/ | ||
function currentUserClientOrganizations (options) { | ||
options.endpoint = options.baseUrl + CURRENT_USER_CLIENTORGS; | ||
return roi.get(options); | ||
} | ||
/** | ||
* Returnsall the clients for the current user | ||
* has permission to edit clients. | ||
* | ||
* @instance | ||
* @function currentUserClients | ||
* @returns {Promise} A promise that will resolve with current user clients. | ||
*/ | ||
function currentUserClients (options) { | ||
options.endpoint = options.baseUrl + CURRENT_USER_CLIENTS; | ||
return roi.get(options); | ||
} | ||
/** | ||
* Returns information about the current authenticated user. | ||
* | ||
* @instance | ||
* @function currentUserInfo | ||
* @returns {Promise} A promise that will resolve with the current user information. | ||
*/ | ||
function currentUserInfo (options) { | ||
options.endpoint = options.baseUrl + CURRENT_USER_INFO; | ||
return roi.get(options); | ||
} | ||
/** | ||
* Updates information about the current authenticated user. | ||
* | ||
* @instance | ||
* @param {string} email - User's email. | ||
* @param {string} fullName - User's full name. | ||
* @function currentUserUpdate | ||
* @returns {Promise} A promise that will resolve with 204 No Content if the update is successful. | ||
*/ | ||
function currentUserUpdate (options, email, fullName) { | ||
options.endpoint = options.baseUrl + CURRENT_USER_INFO; | ||
const data = { email: email, fullName: fullName }; | ||
return roi.put(options, data); | ||
} | ||
/** | ||
* Returns all the organizations for which the current user | ||
* has permission to edit plans. | ||
* | ||
* @instance | ||
* @function currentUserPlanOrganizations | ||
* @returns {Promise} A promise that will resolve with the list of organizations. | ||
*/ | ||
function currentUserPlanOrganizations (options) { | ||
options.endpoint = options.baseUrl + CURRENT_USER_PLANORGS; | ||
return roi.get(options); | ||
} | ||
/** | ||
* Returns information about the organization. | ||
* | ||
* @instance | ||
* @param {string} id - The ID of the organization. | ||
* @function organization | ||
* @returns {Promise} A promise that will resolve with organization. | ||
*/ | ||
function organization (options, id) { | ||
options.endpoint = options.baseUrl + ORGANIZATIONS + id; | ||
return roi.get(options); | ||
} | ||
/** | ||
* This function is used to create a new Organization. | ||
* | ||
* @instance | ||
* @param {string} name - Organization's name. | ||
* @param {string} description - Organizations's description. | ||
* @function organizationAdd | ||
* @returns {Promise} A promise that will resolve with the new organization created. | ||
*/ | ||
function organizationAdd (options, name, description) { | ||
options.endpoint = options.baseUrl + ORGANIZATIONS; | ||
const data = { name: name, description: description }; | ||
return roi.post(options, data); | ||
} | ||
/** | ||
* This function is used to remove a Organization. | ||
* | ||
* @instance | ||
* @param {string} id - The ID of the Organization. | ||
* @function organizationDelete | ||
* @returns {Promise} A promise that will resolve with 204 No Content if the delete is successful. | ||
*/ | ||
function organizationDelete (options, id) { | ||
options.endpoint = options.baseUrl + ORGANIZATIONS + id; | ||
return roi.del(options); | ||
} | ||
/** | ||
* Returns information about the user. | ||
* | ||
* @instance | ||
* @param {string} id - The ID of the user. | ||
* @function user | ||
* @returns {Promise} A promise that will resolve with user. | ||
*/ | ||
function user (options, id) { | ||
options.endpoint = options.baseUrl + USERS + id; | ||
return roi.get(options); | ||
} | ||
/** | ||
* Updates information about the user. | ||
* | ||
* @instance | ||
* @param {string} userId - User's id. | ||
* @param {string} email - User's email. | ||
* @param {string} fullName - User's full name. | ||
* @function userUpdate | ||
* @returns {Promise} A promise that will resolve with 204 No Content if the update is successful. | ||
*/ | ||
function userUpdate (options, userId, email, fullName) { | ||
options.endpoint = options.baseUrl + USERS + userId; | ||
const data = { email: email, fullName: fullName }; | ||
return roi.put(options, data); | ||
} | ||
/** | ||
* Returns all of the User's APIs. | ||
* | ||
* @instance | ||
* @function userAPIs | ||
* @param {string} userId - User's id. | ||
* @returns {Promise} A promise that will resolve with user APIs. | ||
*/ | ||
function userAPIs (options, userId) { | ||
options.endpoint = options.baseUrl + USERS + userId + '/apis'; | ||
return roi.get(options); | ||
} | ||
/** | ||
* Returns all of the User's clients. | ||
* | ||
* @instance | ||
* @function userClients | ||
* @param {string} userId - User's id. | ||
* @returns {Promise} A promise that will resolve with user clients. | ||
*/ | ||
function userClients (options, userId) { | ||
options.endpoint = options.baseUrl + USERS + userId + '/clients'; | ||
return roi.get(options); | ||
} | ||
/** | ||
* Returns all of the User's organizations. | ||
* | ||
* @instance | ||
* @function userOrganizations | ||
* @param {string} userId - User's id. | ||
* @returns {Promise} A promise that will resolve with user organizations. | ||
*/ | ||
function userOrganizations (options, userId) { | ||
options.endpoint = options.baseUrl + USERS + userId + '/organizations'; | ||
return roi.get(options); | ||
} | ||
{ | ||
"name": "apiman-admin-client", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Node.js client for the Apiman admin API.", | ||
@@ -8,6 +8,6 @@ "main": "index.js", | ||
"test": "tape test/*-test.js", | ||
"lint": "jshint index.js lib/*.js test/*.js", | ||
"lint": "jshint index.js test/*.js", | ||
"format": "semistandard", | ||
"coverage": "./node_modules/.bin/istanbul cover tape -- test/**.js", | ||
"docs": "./node_modules/.bin/jsdoc -d docs -t ./node_modules/ink-docstrap/template -R README.md lib/apiman.js" | ||
"docs": "./node_modules/.bin/jsdoc -d docs -t ./node_modules/ink-docstrap/template -R README.md index.js" | ||
}, | ||
@@ -45,4 +45,4 @@ "files": [ | ||
"dependencies": { | ||
"request": "^2.72.0" | ||
"roi": "^0.7.0" | ||
} | ||
} |
@@ -9,5 +9,4 @@ # apiman-admin-client | ||
This package provides a Node.js client for the [Apiman REST services][1]. | ||
It is experimental and still a work in progress. | ||
N.B. This module uses ES6 language features, and as such depends on Node.js version 4.x or higher. | ||
> _Node.js 4, 5, 6_ | ||
@@ -26,19 +25,20 @@ ## Contributing | ||
const options = { | ||
baseUrl: 'http://localhost:8080', | ||
username: 'yourAdminUsername', | ||
password: 'yourAdminPassword' | ||
'baseUrl': 'http://localhost:8080', | ||
'username': 'admin', | ||
'password': 'admin123!' | ||
}; | ||
apiman(options) | ||
.status() | ||
.then(s => console.log(s.name)); | ||
// Apiman default user / password | ||
apiman({ baseUrl: 'http://host:port' }) | ||
.gateways() | ||
.then(g => console.log(g)); | ||
// All defaults [ localhost ] | ||
apiman({}).plugins().then((p) => console.log(p)); | ||
apiman.status(options) | ||
.then(x => console.log(x)) | ||
.catch(e => console.log(e)); | ||
apiman.exportData(options) | ||
.then(x => console.log(x)) | ||
.catch(e => console.log(e)); | ||
apiman.gateways(options) | ||
.then(x => console.log(x)) | ||
.catch(e => console.log(e)); | ||
## You can use to | ||
@@ -64,3 +64,3 @@ | ||
If you have the github rights to do it, you can publish the API documentation by running | ||
`./build/publish-docs.sh`. This script will generate the documentation, then clone this | ||
`./scripts/publish-docs.sh`. This script will generate the documentation, then clone this | ||
repository into a temporary directory, checkout the `gh-pages` branch and update it with | ||
@@ -67,0 +67,0 @@ the newly generated documentation. |
/** | ||
* Copyright 2016 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* Licensed under the Apache License, Version 2.0 (the "License") | ||
* you may not use this file except in compliance with the License. | ||
@@ -20,8 +20,15 @@ * You may obtain a copy of the License at | ||
const test = require('tape'); | ||
let apiman = require('../lib/apiman'); | ||
const apiman = require('../index'); | ||
test('setup', (t) => { | ||
apiman = apiman({}); | ||
apiman | ||
.importData(require('path').join(__dirname, '/fixtures/api-manager-export.json')) | ||
function getOptions () { | ||
const options = { | ||
'baseUrl': 'http://localhost:8080', | ||
'username': 'admin', | ||
'password': 'admin123!' | ||
}; | ||
return options; | ||
} | ||
test('setup', t => { | ||
apiman.importData(getOptions(), require('path').join(__dirname, '/fixtures/api-manager-export.json')) | ||
.then(x => { | ||
@@ -33,6 +40,6 @@ t.equals(x.includes('Data import completed successfully!'), true); | ||
test('The client should verify the status.', (t) => { | ||
apiman.status() | ||
test('Should verify the status.', t => { | ||
apiman.status(getOptions()) | ||
.then(x => { | ||
t.equal(x.name, 'API Manager REST API'); | ||
t.equal(JSON.parse(x).name, 'API Manager REST API'); | ||
t.end(); | ||
@@ -42,5 +49,6 @@ }).catch(e => console.log(e)); | ||
test('The client should return configured gateways.', (t) => { | ||
apiman.gateways() | ||
test('Should return configured gateways.', t => { | ||
apiman.gateways(getOptions()) | ||
.then(x => { | ||
x = JSON.parse(x); | ||
let gatewayFound = x.find(x => x.id === 'TheGateway'); | ||
@@ -52,6 +60,6 @@ t.equal(gatewayFound.id, 'TheGateway'); | ||
test('The client should return one gateway.', (t) => { | ||
apiman.gateway('TheGateway') | ||
test('Should return one gateway.', t => { | ||
apiman.gateway(getOptions(), 'TheGateway') | ||
.then(x => { | ||
t.equal(x.id, 'TheGateway'); | ||
t.equal(JSON.parse(x).id, 'TheGateway'); | ||
t.end(); | ||
@@ -61,3 +69,3 @@ }).catch(e => console.log(e)); | ||
test('The client should add a gateway.', (t) => { | ||
test('Should add a gateway.', t => { | ||
let configuration = JSON.stringify({ | ||
@@ -76,5 +84,5 @@ endpoint: 'http://localhost:8080/apiman-gateway-api-new', | ||
apiman.gatewayAdd(gw) | ||
apiman.gatewayAdd(getOptions(), gw) | ||
.then(x => { | ||
t.equals(x.name, gw.name); | ||
t.equals(x.statusCode, 200); | ||
t.end(); | ||
@@ -84,6 +92,6 @@ }).catch(e => console.log(e)); | ||
test('The client should export the data.', (t) => { | ||
apiman.exportData() | ||
test('Should export the data.', t => { | ||
apiman.exportData(getOptions()) | ||
.then(x => { | ||
t.equal(x.Metadata.apimanVersion.includes('Final'), true); | ||
t.equal(x.toString().includes('Final'), true); | ||
t.end(); | ||
@@ -93,6 +101,6 @@ }).catch(e => console.log(e)); | ||
test('The client should return permissions.', (t) => { | ||
apiman.permissions() | ||
test('Should return permissions.', t => { | ||
apiman.permissions(getOptions()) | ||
.then(x => { | ||
t.equal(x.userId, 'admin'); | ||
t.equal(JSON.parse(x).userId, 'admin'); | ||
t.end(); | ||
@@ -102,6 +110,6 @@ }).catch(e => console.log(e)); | ||
test('The client should return permissions of the user.', (t) => { | ||
apiman.permissionsUser('admin') | ||
test('Should return permissions of the user.', t => { | ||
apiman.permissionsUser(getOptions(), 'admin') | ||
.then(x => { | ||
let permissionFound = x.permissions.find(x => x.name === 'apiAdmin'); | ||
const permissionFound = JSON.parse(x).permissions.find(x => x.name === 'apiAdmin'); | ||
t.equal(permissionFound.name, 'apiAdmin'); | ||
@@ -112,6 +120,6 @@ t.end(); | ||
test('The client should return one plugin.', (t) => { | ||
apiman.plugin(999) | ||
test('Should return one plugin.', t => { | ||
apiman.plugin(getOptions(), 999) | ||
.then(x => { | ||
t.equal(x.id, 999); | ||
t.equal(JSON.parse(x).id, 999); | ||
t.end(); | ||
@@ -121,4 +129,4 @@ }).catch(e => console.log(e)); | ||
test('The client should add one plugin.', (t) => { | ||
let plug = { | ||
test('Should add one plugin.', t => { | ||
const plug = { | ||
type: 'war', | ||
@@ -130,5 +138,5 @@ version: '1.2.6.Final', | ||
apiman.pluginAdd(plug) | ||
apiman.pluginAdd(getOptions(), plug) | ||
.then(x => { | ||
t.equal(x.artifactId, 'apiman-plugins-log-policy'); | ||
t.equal(x.statusCode, 200); | ||
t.end(); | ||
@@ -138,6 +146,6 @@ }).catch(e => console.log(e)); | ||
test('The client should return plugins.', (t) => { | ||
apiman.plugins() | ||
test('Should return plugins.', t => { | ||
apiman.plugins(getOptions()) | ||
.then(x => { | ||
let pluginFound = x.find(x => x.name === 'Transformation Policy Plugin'); | ||
const pluginFound = JSON.parse(x).find(x => x.name === 'Transformation Policy Plugin'); | ||
t.equal(pluginFound.name, 'Transformation Policy Plugin'); | ||
@@ -148,6 +156,6 @@ t.end(); | ||
test('The client should return available plugins.', (t) => { | ||
apiman.availablePlugins() | ||
test('Should return available plugins.', t => { | ||
apiman.availablePlugins(getOptions()) | ||
.then(x => { | ||
let availablePluginFound = x.find(x => x.artifactId === 'apiman-plugins-cors-policy'); | ||
const availablePluginFound = JSON.parse(x).find(x => x.artifactId === 'apiman-plugins-cors-policy'); | ||
t.equal(availablePluginFound.artifactId, 'apiman-plugins-cors-policy'); | ||
@@ -158,6 +166,6 @@ t.end(); | ||
test('The client should return roles.', (t) => { | ||
apiman.roles() | ||
test('Should return roles.', t => { | ||
apiman.roles(getOptions()) | ||
.then(x => { | ||
let roleFound = x.find(x => x.id === 'APIDeveloper'); | ||
const roleFound = JSON.parse(x).find(x => x.id === 'APIDeveloper'); | ||
t.equal(roleFound.id, 'APIDeveloper'); | ||
@@ -168,6 +176,6 @@ t.end(); | ||
test('The client should return one role.', (t) => { | ||
apiman.role('ClientAppDeveloper') | ||
test('Should return one role.', t => { | ||
apiman.role(getOptions(), 'ClientAppDeveloper') | ||
.then(x => { | ||
t.equal(x.id, 'ClientAppDeveloper'); | ||
t.equal(JSON.parse(x).id, 'ClientAppDeveloper'); | ||
t.end(); | ||
@@ -177,6 +185,6 @@ }).catch(e => console.log(e)); | ||
test('The client should return one policy definition.', (t) => { | ||
apiman.policyDefinition('AuthorizationPolicy') | ||
test('Should return one policy definition.', t => { | ||
apiman.policyDefinition(getOptions(), 'AuthorizationPolicy') | ||
.then(x => { | ||
t.equal(x.id, 'AuthorizationPolicy'); | ||
t.equal(JSON.parse(x).id, 'AuthorizationPolicy'); | ||
t.end(); | ||
@@ -186,6 +194,6 @@ }).catch(e => console.log(e)); | ||
test('The client should return policy definitions.', (t) => { | ||
apiman.policyDefinitions() | ||
test('Should return policy definitions.', t => { | ||
apiman.policyDefinitions(getOptions()) | ||
.then(x => { | ||
let policyFound = x.find((x) => x.id === 'AuthorizationPolicy'); | ||
const policyFound = JSON.parse(x).find((x) => x.id === 'AuthorizationPolicy'); | ||
t.equal(policyFound.id, 'AuthorizationPolicy'); | ||
@@ -196,6 +204,6 @@ t.end(); | ||
test('The client should return current user API organizations.', (t) => { | ||
apiman.currentUserAPIOrganizations() | ||
test('Should return current user API organizations.', t => { | ||
apiman.currentUserAPIOrganizations(getOptions()) | ||
.then(x => { | ||
let organizationFound = x.find(x => x.id === 'bucharest-gold'); | ||
const organizationFound = JSON.parse(x).find(x => x.id === 'bucharest-gold'); | ||
t.equal(organizationFound.id, 'bucharest-gold'); | ||
@@ -206,6 +214,6 @@ t.end(); | ||
test('The client should return current user APIs.', (t) => { | ||
apiman.currentUserAPIs() | ||
test('Should return current user APIs.', t => { | ||
apiman.currentUserAPIs(getOptions()) | ||
.then(x => { | ||
let apiFound = x.find(x => x.id === 'testAPI'); | ||
const apiFound = JSON.parse(x).find(x => x.id === 'testAPI'); | ||
t.equal(apiFound.id, 'testAPI'); | ||
@@ -216,6 +224,6 @@ t.end(); | ||
test('The client should return current user client organizations.', (t) => { | ||
apiman.currentUserClientOrganizations() | ||
test('Should return current user client organizations.', t => { | ||
apiman.currentUserClientOrganizations(getOptions()) | ||
.then(x => { | ||
let organizationFound = x.find(x => x.id === 'bucharest-gold'); | ||
const organizationFound = JSON.parse(x).find(x => x.id === 'bucharest-gold'); | ||
t.equal(organizationFound.id, 'bucharest-gold'); | ||
@@ -226,6 +234,6 @@ t.end(); | ||
test('The client should return current user clients.', (t) => { | ||
apiman.currentUserClients() | ||
test('Should return current user clients.', t => { | ||
apiman.currentUserClients(getOptions()) | ||
.then(x => { | ||
let clientAppFound = x.find(x => x.id === 'bucharest-gold-client-app'); | ||
const clientAppFound = JSON.parse(x).find(x => x.id === 'bucharest-gold-client-app'); | ||
t.equal(clientAppFound.id, 'bucharest-gold-client-app'); | ||
@@ -236,6 +244,6 @@ t.end(); | ||
test('The client should get informations about current user.', (t) => { | ||
apiman.currentUserInfo() | ||
test('Should get informations about current user.', t => { | ||
apiman.currentUserInfo(getOptions()) | ||
.then(x => { | ||
t.equal(x.username, 'admin'); | ||
t.equal(JSON.parse(x).username, 'admin'); | ||
t.end(); | ||
@@ -245,6 +253,6 @@ }).catch(e => console.log(e)); | ||
test('The client should update informations about current user.', (t) => { | ||
apiman.currentUserUpdate('admin2@example.org', 'The super admin.') | ||
test('Should update informations about current user.', t => { | ||
apiman.currentUserUpdate(getOptions(), 'admin2@example.org', 'The super admin.') | ||
.then(x => { | ||
t.equal(x, 204); | ||
t.equal(x.statusCode, 204); | ||
t.end(); | ||
@@ -254,6 +262,6 @@ }).catch(e => console.log(e)); | ||
test('The client should return current user organizations able to edit plans.', (t) => { | ||
apiman.currentUserPlanOrganizations() | ||
test('Should return current user organizations able to edit plans.', t => { | ||
apiman.currentUserPlanOrganizations(getOptions()) | ||
.then(x => { | ||
let organizationFound = x.find(x => x.id === 'bucharest-gold'); | ||
const organizationFound = JSON.parse(x).find(x => x.id === 'bucharest-gold'); | ||
t.equal(organizationFound.id, 'bucharest-gold'); | ||
@@ -264,22 +272,22 @@ t.end(); | ||
test('The client should return one organization.', (t) => { | ||
apiman.organization('bucharest-gold') | ||
.then(x => { | ||
t.equal(x.id, 'bucharest-gold'); | ||
t.end(); | ||
}).catch(e => console.log(e)); | ||
}); | ||
// test('Should return one organization.', t => { | ||
// apiman.organization(getOptions(), 'bucharest-gold') | ||
// .then(x => { | ||
// t.equal(JSON.parse(x).id, 'bucharest-gold'); | ||
// t.end(); | ||
// }).catch(e => console.log(e)); | ||
// }); | ||
test('The client should create one organization.', (t) => { | ||
apiman.organizationAdd('bucharest-gold2', 'the super org.') | ||
.then(x => { | ||
t.equal(x.name, 'bucharest-gold2'); | ||
t.end(); | ||
}).catch(e => console.log(e)); | ||
}); | ||
// test('Should create one organization.', t => { | ||
// apiman.organizationAdd(getOptions(), 'bucharest-gold2', 'the super org.') | ||
// .then(x => { | ||
// t.equal(JSON.parse(x).name, 'bucharest-gold2'); | ||
// t.end(); | ||
// }).catch(e => console.log(e)); | ||
// }); | ||
test('The client should return one user.', (t) => { | ||
apiman.user('admin') | ||
test('Should return one user.', t => { | ||
apiman.user(getOptions(), 'admin') | ||
.then(x => { | ||
t.equal(x.username, 'admin'); | ||
t.equal(JSON.parse(x).username, 'admin'); | ||
t.end(); | ||
@@ -289,6 +297,6 @@ }).catch(e => console.log(e)); | ||
test('The client should update informations about user.', (t) => { | ||
apiman.userUpdate('admin', 'admin3@example.org', 'The super admin again.') | ||
test('Should update informations about user.', t => { | ||
apiman.userUpdate(getOptions(), 'admin', 'admin3@example.org', 'The super admin again.') | ||
.then(x => { | ||
t.equal(x, 204); | ||
t.equal(x.statusCode, 204); | ||
t.end(); | ||
@@ -298,6 +306,6 @@ }).catch(e => console.log(e)); | ||
test('The client should return user APIs.', (t) => { | ||
apiman.userAPIs('admin') | ||
test('Should return user APIs.', t => { | ||
apiman.userAPIs(getOptions(), 'admin') | ||
.then(x => { | ||
let apiFound = x.find(x => x.id === 'testAPI'); | ||
const apiFound = JSON.parse(x).find(x => x.id === 'testAPI'); | ||
t.equal(apiFound.id, 'testAPI'); | ||
@@ -308,6 +316,6 @@ t.end(); | ||
test('The client should return user organizations.', (t) => { | ||
apiman.userOrganizations('admin') | ||
test('Should return user organizations.', t => { | ||
apiman.userOrganizations(getOptions(), 'admin') | ||
.then(x => { | ||
let organizationFound = x.find(x => x.id === 'bucharest-gold'); | ||
const organizationFound = JSON.parse(x).find(x => x.id === 'bucharest-gold'); | ||
t.equal(organizationFound.id, 'bucharest-gold'); | ||
@@ -318,6 +326,6 @@ t.end(); | ||
test('The client should return user clients.', (t) => { | ||
apiman.userClients('admin') | ||
test('Should return user clients.', t => { | ||
apiman.userClients(getOptions(), 'admin') | ||
.then(x => { | ||
let clientAppFound = x.find(x => x.id === 'bucharest-gold-client-app'); | ||
const clientAppFound = JSON.parse(x).find(x => x.id === 'bucharest-gold-client-app'); | ||
t.equal(clientAppFound.id, 'bucharest-gold-client-app'); | ||
@@ -328,6 +336,6 @@ t.end(); | ||
test('The client should remove one gateway.', (t) => { | ||
apiman.gatewayDelete('TheNewGateway3') | ||
test('Should remove one gateway.', t => { | ||
apiman.gatewayDelete(getOptions(), 'TheNewGateway3') | ||
.then(x => { | ||
t.equal(x, 204); | ||
t.equal(x.statusCode, 204); | ||
t.end(); | ||
@@ -338,41 +346,32 @@ console.log('Gateway removed.'); | ||
test('The client should remove one plugin.', (t) => { | ||
apiman.pluginDelete(999) | ||
test('Should remove one plugin.', t => { | ||
apiman.pluginDelete(getOptions(), 999) | ||
.then(x => { | ||
t.equal(x, 204); | ||
t.equal(x.statusCode, 204); | ||
t.end(); | ||
console.log('Plugin removed.'); | ||
}).catch(e => console.log(e)); | ||
}); | ||
test('The client should remove one organization.', (t) => { | ||
apiman.organizationDelete('bucharest-gold') | ||
.then(x => { | ||
t.equal(x, 204); | ||
t.end(); | ||
console.log('Organization removed.'); | ||
}).catch(e => console.log(e)); | ||
}); | ||
// test('Should remove one organization.', t => { | ||
// apiman.organizationDelete(getOptions(), 'bucharest-gold') | ||
// .then(x => { | ||
// t.equal(x.statusCode, 204); | ||
// t.end(); | ||
// }).catch(e => console.log(e)); | ||
// }); | ||
test('The client should remove one role.', (t) => { | ||
apiman.roleDelete('APIDeveloper') | ||
test('Should remove one role.', t => { | ||
apiman.roleDelete(getOptions(), 'APIDeveloper') | ||
.then(x => { | ||
t.equal(x, 204); | ||
t.equal(x.statusCode, 204); | ||
t.end(); | ||
console.log('Role removed.'); | ||
}).catch(e => console.log(e)); | ||
}); | ||
test('The client should remove one policy definition.', (t) => { | ||
apiman.policyDefinitionDelete('AuthorizationPolicy') | ||
test('Should remove one policy definition.', t => { | ||
apiman.policyDefinitionDelete(getOptions(), 'AuthorizationPolicy') | ||
.then(x => { | ||
t.equal(x, 204); | ||
t.equal(x.statusCode, 204); | ||
t.end(); | ||
console.log('Policy definition removed.'); | ||
}).catch(e => console.log(e)); | ||
}); | ||
test('teardown', t => { | ||
console.log('done.'); | ||
t.end(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
52401
6
1132
1
+ Addedroi@^0.7.0
+ Addedroi@0.7.0(transitive)
- Removedrequest@^2.72.0
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.10.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)