Skip to content

Commit

Permalink
Merge pull request #113 from Optum/master
Browse files Browse the repository at this point in the history
Match Templates - Bug fixes related to edits / toggles
  • Loading branch information
JD Weeks authored Nov 2, 2018
2 parents d24f4e1 + 5781d6a commit 0eef372
Show file tree
Hide file tree
Showing 23 changed files with 1,043 additions and 705 deletions.
950 changes: 603 additions & 347 deletions api-docs.yml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ function init() {
const users = require('./routes/users');
app.use('/api/users', users);

//Error Handling
app.use(function(err, req, res, next){
console.log(err.stack);
res.status(404).send(err.message);
});


// ready for testing (see test/test.js)
app.emit('started');
}
Expand Down
19 changes: 13 additions & 6 deletions controllers/serviceController.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,19 @@ function searchDuplicate(service, next) {
name: { $ne: service.name },
basePath: service.basePath
};

const query = {
name: service.name,
basePath: service.basePath
};
Service.findOne(query2ServDiffNmSmBP, function (err, sameNmDupBP) {

Service.findOne(query2ServDiffNmSmBP, function(err, sameNmDupBP) {
if (err) {
handleError(err, res, 500);
return;
}
else if (sameNmDupBP)
next({ "twoServDiffNmSmBP": "yes" });
next({ twoServDiffNmSmBP: true });
else {
Service.findOne(query, function (err, duplicate) {
if (err) {
Expand Down Expand Up @@ -159,13 +161,14 @@ function addService(req, res) {
type: req.body.type,
delay: req.body.delay,
basePath: '/' + req.body.sut.name + req.body.basePath,
matchTemplates: req.body.matchTemplates,
rrpairs: req.body.rrpairs
};

searchDuplicate(serv, function(duplicate) {
if(duplicate && duplicate.twoServDiffNmSmBP && duplicate.twoServDiffNmSmBP=='yes'){
if (duplicate && duplicate.twoServDiffNmSmBP){
res.json({"error":"twoSeviceDiffNameSameBasePath"});
return 'twoSeviceDiffNameSameBasePath';
return;
}
else if (duplicate) {
// merge services
Expand Down Expand Up @@ -205,8 +208,13 @@ function updateService(req, res) {
}

// don't let consumer alter name, base path, etc.
service.matchTemplates = req.body.matchTemplates;
service.rrpairs = req.body.rrpairs;
if (req.body.delay) service.delay = req.body.delay;

const delay = req.body.delay;
if (delay || delay === 0) {
service.delay = req.body.delay;
}

// save updated service in DB
service.save(function (err, newService) {
Expand Down Expand Up @@ -283,7 +291,6 @@ function isYaml(req) {

function createFromSpec(req, res) {
const type = req.query.type;
const base = req.query.base;
const name = req.query.name;
const url = req.query.url;
const sut = { name: req.query.group };
Expand Down
13 changes: 12 additions & 1 deletion controllers/systemController.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,18 @@ function addSystem(req, res) {
});
}

function delSystem(req, res) {
System.findOneAndRemove({ name: req.params.name }, function(err) {
if (err) {
handleError(err, res, 400);
return;
}
res.json({ 'message' : 'deleted system', 'name' : req.params.name });
});
}

module.exports = {
getSystems: getSystems,
addSystem: addSystem
addSystem: addSystem,
delSystem: delSystem
}
13 changes: 12 additions & 1 deletion controllers/userController.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ function getUsers(req, res) {
});
}

function delUser(req, res) {
User.findOneAndRemove({ uid : req.params.name }, function(err) {
if (err) {
handleError(err, res, 400);
return;
}
res.json({ 'message' : 'deleted user', 'username' : req.params.name });
});
}

module.exports = {
getUsers: getUsers
getUsers: getUsers,
delUser: delUser
}
51 changes: 51 additions & 0 deletions examples/hello-service.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<definitions name = "HelloService"
targetNamespace = "http://www.examples.com/wsdl/HelloService.wsdl"
xmlns = "http://schemas.xmlsoap.org/wsdl/"
xmlns:soap = "http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns = "http://www.examples.com/wsdl/HelloService.wsdl"
xmlns:xsd = "http://www.w3.org/2001/XMLSchema">

<message name = "SayHelloRequest">
<part name = "firstName" type = "xsd:string"/>
</message>

<message name = "SayHelloResponse">
<part name = "greeting" type = "xsd:string"/>
</message>

<portType name = "Hello_PortType">
<operation name = "sayHello">
<input message = "tns:SayHelloRequest"/>
<output message = "tns:SayHelloResponse"/>
</operation>
</portType>

<binding name = "Hello_Binding" type = "tns:Hello_PortType">
<soap:binding style = "rpc"
transport = "http://schemas.xmlsoap.org/soap/http"/>
<operation name = "sayHello">
<soap:operation soapAction = "sayHello"/>
<input>
<soap:body
encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
namespace = "urn:examples:helloservice"
use = "encoded"/>
</input>

<output>
<soap:body
encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
namespace = "urn:examples:helloservice"
use = "encoded"/>
</output>
</operation>
</binding>

<service name = "Hello_Service">
<documentation>WSDL File for HelloService</documentation>
<port binding = "tns:Hello_Binding" name = "Hello_Port">
<soap:address
location = "http://www.examples.com/SayHello/" />
</port>
</service>
</definitions>
175 changes: 0 additions & 175 deletions examples/petstore.json

This file was deleted.

Loading

0 comments on commit 0eef372

Please sign in to comment.