aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks
diff options
context:
space:
mode:
authoryanhuanwang <martin.c.yan@est.tech>2019-03-22 09:23:23 +0000
committerMartin Yan <martin.c.yan@est.tech>2019-03-22 09:33:33 +0000
commit08463e56ca8460b2da380ecf8e2c3605ea7bd4a2 (patch)
tree26609f0f5576152889a31b8e62992eaaea408e8d /test/mocks
parent921c7baee8511eac0aa972139df3a238ac56299b (diff)
Take feedName as parameter from POST request
Update dmaapBusController so that it takes feedName as parameter from POST request from http client Change-Id: If57e5c0073bf1fe6d62c644c772d9744fdd859f8 Issue-ID: DCAEGEN2-1225 Signed-off-by: yanhuanwang <martin.c.yan@est.tech>
Diffstat (limited to 'test/mocks')
-rw-r--r--test/mocks/datafilecollector-testharness/dr-sim/dmaapBusController.js91
1 files changed, 65 insertions, 26 deletions
diff --git a/test/mocks/datafilecollector-testharness/dr-sim/dmaapBusController.js b/test/mocks/datafilecollector-testharness/dr-sim/dmaapBusController.js
index cca85f98b..a1b2770cf 100644
--- a/test/mocks/datafilecollector-testharness/dr-sim/dmaapBusController.js
+++ b/test/mocks/datafilecollector-testharness/dr-sim/dmaapBusController.js
@@ -6,35 +6,38 @@ const stream = require('stream');
var app = express();
var fs = require("fs");
var path = require('path');
-var privateKey = fs.readFileSync('cert/private.key', 'utf8');
+var privateKey = fs.readFileSync('cert/private.key', 'utf8');
var certificate = fs.readFileSync('cert/certificate.crt', 'utf8');
-var credentials = {key: privateKey, cert: certificate};
+var credentials = {
+ key: privateKey,
+ cert: certificate
+};
var parser = new ArgumentParser({
- version: '0.0.1',
- addHelp:true,
- description: 'Datarouter simulator'
- });
+ version: '0.0.1',
+ addHelp: true,
+ description: 'Datarouter simulator'
+});
-parser.addArgument('--tc' , { help: 'TC $NoOfTc' } );
-parser.addArgument('--printtc' ,
- {
- help: 'Print complete usage help',
- action: 'storeTrue'
- }
- );
+parser.addArgument('--tc', {
+ help: 'TC $NoOfTc'
+});
+parser.addArgument('--printtc', {
+ help: 'Print complete usage help',
+ action: 'storeTrue'
+});
var args = parser.parseArgs();
-if (args.tc=="100") {
+if (args.tc == "100") {
console.log("TC: 100")
}
-if (args.tc=="101") {
+if (args.tc == "101") {
console.log("TC: 101")
//preparations
}
-if (args.tc=="102") {
+if (args.tc == "102") {
console.log("TC: 102")
//preparations
}
@@ -47,30 +50,66 @@ if (args.printtc) {
}
var bodyParser = require('body-parser')
-app.use(bodyParser.urlencoded({ extended: false }))
+app.use(bodyParser.urlencoded({
+ extended: false
+}))
// parse application/json
app.use(bodyParser.json())
// parse application/vnd.api+json as json
-app.use(bodyParser.json({ type: 'application/vnd.api+json' }))
+app.use(bodyParser.json({
+ type: 'application/vnd.api+json'
+}))
// parse some custom thing into a Buffer
-app.use(bodyParser.raw({limit:1024*1024*20, type: 'application/octet-stream' }))
+app.use(bodyParser.raw({
+ limit: 1024 * 1024 * 20,
+ type: 'application/octet-stream'
+}))
// parse an HTML body into a string
-app.use(bodyParser.text({ type: 'text/html' }))
-app.get("/",function(req, res){
+app.use(bodyParser.text({
+ type: 'text/html'
+}))
+app.get("/", function (req, res) {
res.send("ok");
})
app.post('/webapi/feeds/', function (req, res) {
- res.send("ok");
+ res.setHeader('Content-Type', 'application/json');
+ var feedName = req.body.feedName;
+ console.log(feedName);
+ res.end(JSON.stringify({
+ "type": "feed",
+ "lastMod": "2019-03-21T16:00:40.489",
+ "status": "VALID",
+ "asprClassification": "unclassified",
+ "feedDescription": "generated for CSIT",
+ "feedId": "3",
+ "feedName": feedName,
+ "feedVersion": "csit",
+ "logURL": "https://dmaap-dr-prov/feedlog/3",
+ "owner": "dgl",
+ "publishURL": "https://dmaap-dr-prov/publish/3",
+ "pubs": [{
+ "lastMod": "2019-01-24T16:00:40.484",
+ "status": "VALID",
+ "dcaeLocationName": "san-francisco",
+ "feedId": "3",
+ "pubId": "3.4gh53",
+ "username": "tmp_i63w8psh6ycnoqu",
+ "userpwd": "6jkc1uwywrc8q4w"
+ }],
+ "subs": [],
+ "subscribeURL": "https://dmaap-dr-prov/subscribe/3",
+ "suspended": false
+ }));
})
var httpServer = http.createServer(app);
var httpsServer = https.createServer(credentials, app);
-var httpPort=6665
-var httpsPort=6666
+var httpPort = 6665
+var httpsPort = 6666
httpServer.listen(httpPort);
-console.log("DR-simulator listening (http) at "+httpPort)
+console.log("DR-simulator listening (http) at " + httpPort)
httpsServer.listen(httpsPort);
-console.log("DR-simulator listening (https) at "+httpsPort) \ No newline at end of file
+console.log("DR-simulator listening (https) at " + httpsPort) \ No newline at end of file