diff options
Diffstat (limited to 'openecomp-ui/fixture')
-rw-r--r-- | openecomp-ui/fixture/data/entitlementPools.json | 36 | ||||
-rw-r--r-- | openecomp-ui/fixture/data/featureGroup.json | 59 | ||||
-rw-r--r-- | openecomp-ui/fixture/data/featureGroups.json | 28 | ||||
-rw-r--r-- | openecomp-ui/fixture/data/licenseAgreementList.json | 33 | ||||
-rw-r--r-- | openecomp-ui/fixture/data/licenseKeyGroups.json | 20 | ||||
-rw-r--r-- | openecomp-ui/fixture/data/licenseModels.json | 16 | ||||
-rw-r--r-- | openecomp-ui/fixture/data/softwareProduct.json | 96 | ||||
-rw-r--r-- | openecomp-ui/fixture/data/softwareProductList.json | 34 | ||||
-rw-r--r-- | openecomp-ui/fixture/express.js | 231 | ||||
-rw-r--r-- | openecomp-ui/fixture/fixture.js | 93 | ||||
-rw-r--r-- | openecomp-ui/fixture/middleware.js | 24 |
11 files changed, 670 insertions, 0 deletions
diff --git a/openecomp-ui/fixture/data/entitlementPools.json b/openecomp-ui/fixture/data/entitlementPools.json new file mode 100644 index 0000000000..22750cbb6d --- /dev/null +++ b/openecomp-ui/fixture/data/entitlementPools.json @@ -0,0 +1,36 @@ +{ + "results":[ + { + "name": "ep1", + "description": "string", + "thresholdValue": 75, + "thresholdUnits": "%", + "entitlementMetric": {"choice": "User", "other":""}, + "increments": "string", + "aggregationFunction": {"choice": "Average", "other": ""}, + "operationalScope": {"choices": ["VM"], "other": ""}, + "time": {"choice": "Hour", "other": ""}, + "sku": "DEF2-385A-4521-AAAA", + "id": "1", + "referencingFeatureGroups": ["1","2"], + "partNumber": "51529" + }, + { + "name": "ep2", + "description": "string", + "thresholdValue": 99, + "thresholdUnits": "%", + "entitlementMetric": {"choice": "User", "other":""}, + "increments": "string", + "aggregationFunction": {"choice": "Average", "other": ""}, + "operationalScope": {"choices": ["Other"], "other": "blabla"}, + "time": {"choice": "Hour", "other": ""}, + "sku": "DEF2-385A-4521-AAAA", + "id": "2", + "refCount": 0, + "partNumber": "51529", + "referencingFeatureGroups": [] + } + ] +} + diff --git a/openecomp-ui/fixture/data/featureGroup.json b/openecomp-ui/fixture/data/featureGroup.json new file mode 100644 index 0000000000..278baecb36 --- /dev/null +++ b/openecomp-ui/fixture/data/featureGroup.json @@ -0,0 +1,59 @@ +{ + "name": "fssss", + "description": "gdfgdfgdsfg", + "id": "1", + "licenseKeyGroupsIds": [ + "1,2" + ], + "entitlementPoolsIds": [ + "1,2" + ], + "licenseKeyGroups": [ + { + "name": "ls1", + "description": "string", + "type": "string", + "operationalScope": "string", + "id": "1", + "refCount": 0 + }, + { + "name": "ls2", + "description": "string", + "type": "string", + "operationalScope": "string", + "id": "1", + "refCount": 0 + } + ], + "entitlementPools": [ + { + "name": "ep1", + "description": "string", + "thresholdValue": 0, + "thresholdUnits": "string", + "entitlementMetric": "string", + "increments": "string", + "aggregationFunction": "string", + "operationalScope": "string", + "time": "string", + "sku": "string", + "id": "string", + "refCount": 0 + }, + { + "name": "ep2", + "description": "string", + "thresholdValue": 0, + "thresholdUnits": "string", + "entitlementMetric": "string", + "increments": "string", + "aggregationFunction": "string", + "operationalScope": "string", + "time": "string", + "sku": "string", + "id": "string", + "refCount": 0 + } + ] +} diff --git a/openecomp-ui/fixture/data/featureGroups.json b/openecomp-ui/fixture/data/featureGroups.json new file mode 100644 index 0000000000..eea4967ca8 --- /dev/null +++ b/openecomp-ui/fixture/data/featureGroups.json @@ -0,0 +1,28 @@ +{ + "results": [ + { + "name": "fs1", + "id": "0", + "description": "fs1-description", + "licenseKeyGroupsIds": [ + "1" + ], + "entitlementPoolsIds": [ + "1" + ], + "referencingLicenseAgreements": ["1","2"] + }, + { + "name": "fs2", + "id": "1", + "description": "fs2-description", + "licenseKeyGroupsIds": [ + "2" + ], + "entitlementPoolsIds": [ + "2" + ], + "referencingLicenseAgreements": [] + } + ] +} diff --git a/openecomp-ui/fixture/data/licenseAgreementList.json b/openecomp-ui/fixture/data/licenseAgreementList.json new file mode 100644 index 0000000000..b113295fcb --- /dev/null +++ b/openecomp-ui/fixture/data/licenseAgreementList.json @@ -0,0 +1,33 @@ +{ + "results": [ + { + "name": "name0", + "description": "description0", + "licenseTerm": {"choice": "Other", "other": "blabla"}, + "requirementsAndConstrains": "requirementsAndConstrains0", + "featureGroupsIds": [], + "id": "0" + }, + { + "name": "name1", + "description": "description1", + "licenseTerm": {"choice": "Fixed_Term", "other": ""}, + "requirementsAndConstrains": "requirementsAndConstrains1", + "featureGroupsIds": [ + "1" + ], + "id": "1" + }, + { + "name": "name2", + "description": "description2", + "licenseTerm": {"choice": "Unlimited", "other": ""}, + "requirementsAndConstrains": "requirementsAndConstrains2", + "featureGroupsIds": [ + "2" + ], + "id": "2" + } + ], + "listCount": 3 +} diff --git a/openecomp-ui/fixture/data/licenseKeyGroups.json b/openecomp-ui/fixture/data/licenseKeyGroups.json new file mode 100644 index 0000000000..74050ab033 --- /dev/null +++ b/openecomp-ui/fixture/data/licenseKeyGroups.json @@ -0,0 +1,20 @@ +{ + "results":[ + { + "name": "lsk1", + "description": "string", + "type": "Unique", + "operationalScope": {"choices": ["Network_Wide","VM"], "other": ""}, + "id": "1", + "referencingFeatureGroups":["1","2"] + }, + { + "name": "lsk2", + "description": "string", + "type": "One_Time", + "operationalScope": {"choices": ["Other"], "other": "blabla"}, + "id": "2", + "referencingFeatureGroups": 0 + } + ] +} diff --git a/openecomp-ui/fixture/data/licenseModels.json b/openecomp-ui/fixture/data/licenseModels.json new file mode 100644 index 0000000000..5239c4fafc --- /dev/null +++ b/openecomp-ui/fixture/data/licenseModels.json @@ -0,0 +1,16 @@ +{ + "results":[ + { + "vendorName": "Omer Corp.", + "description": "", + "iconRef": "string", + "id": "1" + }, + { + "vendorName": "Robotricks", + "description": "Optimus Prime", + "iconRef": "string", + "id": "2" + } + ] +} diff --git a/openecomp-ui/fixture/data/softwareProduct.json b/openecomp-ui/fixture/data/softwareProduct.json new file mode 100644 index 0000000000..5b60587614 --- /dev/null +++ b/openecomp-ui/fixture/data/softwareProduct.json @@ -0,0 +1,96 @@ +{ + "name": "VSP5", + "version": "0.1", + "id": "4730033D16C64E3CA556AB0AC4478218", + "description": "A software model for Fortigate. Nam hendrerit sollicitudin semper. Aenean consectetur nisi sit amet ante sodales consectetur. Nullam rutrum massa in pellentesque ' +elementum. Aliquam efficitur tellus lacus, eget iaculis justo iaculis eu. ", + "categoryId": "category", + "vendorId": "1", + "checkinStatus": "CHECK_OUT", + "licensingData": "test data", + "validationData": { + "logicalStructure": [ + { + "type": "PPD", + "catalogInstances": [ + { + "name": "PPD1", + "artifacts": [ + { + "name": "chopstick.py" + }, + { + "name": "bread.py" + } + ] + } + ] + } + ], + "importStructure": { + "HEAT": [ + { + "fileName": "sushi.yml", + "env": "soy.env", + "nested": [ + { + "fileName": "salmon.yml", + "env": "skin.env", + "artifacts": [ + { + "name": "rice.py", + "status": "OK" + }, + { + "name": "tuna.py", + "status": "Missing" + } + ] + } + ], + "artifacts": [ + { + "name": "chopstick.py", + "status": "OK" + }, + { + "name": "bread.py", + "status": "Missing" + } + ], + "volume": [ + { + "fileName": "fishtank.yml", + "env": "middletown.env" + } + ], + "network": [ + { + "fileName": "fishnet.yml", + "env": "ship.env" + } + ] + } + ], + "volume": [ + { + "fileName": "vol1.yml", + "env": "e1.env" + }, + { + "fileName": "vol2.yml", + "env": "e2.env" + } + ], + "network": [ + { + "fileName": "net1.yml", + "env": "env1.env" + }, + { + "fileName": "net2.yml", + "env": "env2.env" + } + ] + } + } +} diff --git a/openecomp-ui/fixture/data/softwareProductList.json b/openecomp-ui/fixture/data/softwareProductList.json new file mode 100644 index 0000000000..4554abc95f --- /dev/null +++ b/openecomp-ui/fixture/data/softwareProductList.json @@ -0,0 +1,34 @@ +{ + "results": [ + { + "name": "Software Product 1", + "version": "1.0", + "id": "1", + "category": "Category1", + "subCategory": "Sub Category1", + "vendor": "1", + "status": "string", + "checkinStatus": "string" + }, + { + "name": "Software Product 2", + "version": "1.0", + "id": "2", + "category": "Category2", + "subCategory": "Sub Category2", + "vendor": "2", + "status": "string", + "checkinStatus": "string" + }, + { + "name": "Software Product 3", + "version": "1.0", + "id": "3", + "category": "Category3", + "subCategory": "Sub Category3", + "vendor": "3", + "status": "string", + "checkinStatus": "string" + } + ] +} diff --git a/openecomp-ui/fixture/express.js b/openecomp-ui/fixture/express.js new file mode 100644 index 0000000000..ed8bf956f9 --- /dev/null +++ b/openecomp-ui/fixture/express.js @@ -0,0 +1,231 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +var args = process.argv.slice(2); + +function defineRoutes(router) { + + //LICENSE-MODELS + router.get('/v1.0/vendor-license-models', licenseModelsList); + + //FEATURE-GROUP + router.get('/v1.0/vendor-license-models/:licenseModelId/feature-groups', featureGroupList); + router.get('/v1.0/vendor-license-models/:licenseModelId/feature-groups/:featureGroupId', featureGroup); + router.post('/v1.0/vendor-license-models/:licenseModelId/feature-groups', addFeatureGroup); + router.delete('/v1.0/vendor-license-models/:licenseModelId/feature-groups/:featureGroupId', deletefeatureGroup); + router.put('/v1.0/vendor-license-models/:licenseModelId/feature-groups/:featureGroupId', updatefeatureGroup); + + + + //LICENSE-AGREEMENT + router.get('/v1.0/vendor-license-models/:licenseModelId/license-agreements', licenseAgreementList); + router.post('/v1.0/vendor-license-models/:licenseModelId/license-agreements/', addLicenseAgreement); + router.delete('/v1.0/vendor-license-models/:licenseModelId/license-agreements/:licenseAgreementId', deleteLicenseAgreement); + router.put('/v1.0/vendor-license-models/:licenseModelId/license-agreements/:licenseAgreementId', updateLicenseAgreement); + + //ENTITLEMENT POOLS + router.get('/v1.0/vendor-license-models/:licenseModelId/entitlement-pools', entitlementPoolsList); + router.post('/v1.0/vendor-license-models/:licenseModelId/entitlement-pools', addEntitlementPool); + router.put('/v1.0/vendor-license-models/:licenseModelId/entitlement-pools/:entitlementPoolId', updateEntitlementPool); + router.delete('/v1.0/vendor-license-models/:licenseModelId/entitlement-pools/:entitlementPoolId', deleteEntitlementPool); + + //LICENSE KEY GROUPS + router.get('/v1.0/vendor-license-models/:licenseModelId/license-key-groups', licenseKeyGroupsList); + router.post('/v1.0/vendor-license-models/:licenseModelId/license-key-groups', addLicenseKeyGroup); + router.delete('/v1.0/vendor-license-models/:licenseModelId/license-key-groups/:licenseKeyGroupId', deleteLicenseKeyGroup); + router.put('/v1.0/vendor-license-models/:licenseModelId/license-key-groups/:licenseKeyGroupId', updateLicenseKeyGroup); + + //VENDOR SOFTWARE PRODUCT + + router.post('/v1.0/vendor-software-products/:vspId/upload', softwareProductUpload); + router.get('/v1.0/vendor-software-products/:vspId', getSoftwareProduct); + router.get('/v1.0/vendor-software-products', softwareProductList); + + router.put('/v1.0/vendor-software-products/:vspId/processes/:prcId', putSoftwareProductProcess); + router.post('/v1.0/vendor-software-products/:vspId/processes', postSoftwareProductProcess); +} + + +function licenseModelsList(req, res) { + res.json(require('./data/licenseModels')); +} + +function featureGroupList(req, res) { + res.json(require('./data/featureGroups')); +} + +function featureGroup(req, res) { + res.json(require('./data/featureGroup')); +} + +function deletefeatureGroup(req, res) { + res.json({ + returnCode: 'OK' + }); +} + + +function updatefeatureGroup(req, res) { + res.json({ + returnCode: 'OK' + }); +} + +function addFeatureGroup(req,res) { + var id = Math.floor(Math.random() * (100 - 1) + 1).toString(); + res.json({ + returnCode: 'OK', + value: id + }) +} + +/** ENTITLEMENT POOLS **/ +function entitlementPoolsList(req, res) { + res.json(require('./data/entitlementPools')); +} + +function updateEntitlementPool(req, res) { + res.json({ + returnCode: 'OK' + }); +} + +function addEntitlementPool(req,res) { + var id = Math.floor(Math.random() * (100 - 1) + 1).toString(); + res.json({ + returnCode: 'OK', + value: id + }) +} + +function deleteEntitlementPool(req, res) { + res.json({ + returnCode: 'OK' + }); +} + +/** LICENSE KEY GROUPS */ + +function licenseKeyGroupsList(req, res) { + res.json(require('./data/licenseKeyGroups')); +} + +function addLicenseKeyGroup(req,res) { + var id = Math.floor(Math.random() * (100 - 1) + 1).toString(); + res.json({ + returnCode: 'OK', + value: id + }) +} + +function deleteLicenseKeyGroup(req, res) { + res.json({ + returnCode: 'OK' + }); +} + +function updateLicenseKeyGroup(req, res) { + res.json({ + returnCode: 'OK' + }); +} + +function licenseAgreementList(req, res) { + res.json(require('./data/licenseAgreementList')); +} + + +function addLicenseAgreement(req,res) { + var id = Math.floor(Math.random() * (100 - 1) + 1).toString(); + res.json({ + returnCode: 'OK', + value: id + }) +} +function deleteLicenseAgreement(req, res) { + res.json({ + returnCode: 'OK' + }); +} +function updateLicenseAgreement(req, res) { + res.json({ + returnCode: 'OK' + }); +} + +/** VENDOR SOFTWARE PRODUCT */ + +function softwareProductUpload(req, res) { + res.json({ + status: 'SUCCESS' + }); +} + +function getSoftwareProduct(req, res) { + res.json(require('./data/softwareProduct')); +} + + +function putSoftwareProductProcess(req, res) { + res.json({ + status: 'SUCCESS' + }); +} + +function postSoftwareProductProcess(req, res) { + var id = Math.floor(Math.random() * (100 - 1) + 1).toString(); + res.json({ + returnCode: 'OK', + value: id + }); +} + + + + +function createFixtureServer(port) { + var express = require('express'); + var app = express(); + var bodyParser = require('body-parser'); + app.use(bodyParser.urlencoded({extended: true})); + app.use(bodyParser.json()); + + var router = express.Router(); + + defineRoutes(router); + + app.use('/api', router); + app.use('/onboarding-api', router); + app.use('/sdc1/feProxy/onboarding-api', router); + + app.listen(port); + + console.log('Fixture server is up. port->', port); + //console.log(router.stack); + return app; +} + +/** SOFTWARE PRODUCT LIST **/ +function softwareProductList(req, res) { + res.json(require('./data/softwareProductList')); +} + + +createFixtureServer(args[0]); diff --git a/openecomp-ui/fixture/fixture.js b/openecomp-ui/fixture/fixture.js new file mode 100644 index 0000000000..7e5b263c5c --- /dev/null +++ b/openecomp-ui/fixture/fixture.js @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +'use strict'; + +const PORT = 4000; + +function startFixtureServer() { + return require('child_process').fork('fixture/express', [PORT]); +} + +function buildProxyMiddleware() { + return require('./middleware')(PORT); +} + +function getProxyData(fixtureServerOptions, req, res, next) { + if (!fixtureServerOptions.serverProcess) { + fixtureServerOptions.serverProcess = startFixtureServer(); + } + + return fixtureServerOptions.proxy(req, res, next); +} + +function wrapFixture(fixtureServerOptions, req, res, next) { + if (fixtureServerOptions.proxy) { + return getProxyData(fixtureServerOptions, req, res, next); + } else { + next(); + } +} + + +module.exports = function fixture(options) { + + let proxy; + if(options.enabled) { + proxy = buildProxyMiddleware(); + } + + let fixtureServerOptions = { + proxy, + serverProcess: null + }; + + (function startWatch() { + var nodeWatch = require('node-watch'); + + nodeWatch(['fixture/data', 'fixture/express.js'], function () { + if (fixtureServerOptions.proxy && fixtureServerOptions.serverProcess) { + fixtureServerOptions.serverProcess.kill(); + fixtureServerOptions.serverProcess = startFixtureServer(); + } + }); + + nodeWatch(['devConfig.json'], function () { + let devConfigDefaults = require('../devConfig.defaults'); + require('fs').readFile('devConfig.json', (err, data) => { + if (err) throw err; + const config = Object.assign({}, devConfigDefaults, JSON.parse(data)); + if (config.useFixture) { + fixtureServerOptions.proxy = proxy || buildProxyMiddleware(); + } + else { + fixtureServerOptions.proxy = null; + if (fixtureServerOptions.serverProcess) { + fixtureServerOptions.serverProcess.kill(); + fixtureServerOptions.serverProcess = null; + } + } + }); + }); + + })(); + + return (req, res, next) => wrapFixture(fixtureServerOptions, req, res, next); +}; diff --git a/openecomp-ui/fixture/middleware.js b/openecomp-ui/fixture/middleware.js new file mode 100644 index 0000000000..915bb81cab --- /dev/null +++ b/openecomp-ui/fixture/middleware.js @@ -0,0 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +module.exports = function createProxyMiddleware(port) { + var proxy = require('http-proxy-middleware'); + return proxy(['/api', '/onboarding-api'], {target: 'http://localhost:' + port}); +}; |