2017-02-18 20:14:10 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* DO NOT EDIT THIS FILE
|
|
|
|
* For FCC testing purposes!
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
const cors = require('cors');
|
|
|
|
const fs = require('fs');
|
|
|
|
const runner = require('../test-runner');
|
2017-02-18 20:14:10 +01:00
|
|
|
|
|
|
|
module.exports = function (app) {
|
|
|
|
|
|
|
|
app.route('/_api/server.js')
|
|
|
|
.get(function(req, res, next) {
|
|
|
|
console.log('requested');
|
|
|
|
fs.readFile(__dirname + '/server.js', function(err, data) {
|
|
|
|
if(err) return next(err);
|
|
|
|
res.send(data.toString());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
app.route('/_api/routes/api.js')
|
|
|
|
.get(function(req, res, next) {
|
|
|
|
console.log('requested');
|
|
|
|
fs.readFile(__dirname + '/routes/api.js', function(err, data) {
|
|
|
|
if(err) return next(err);
|
|
|
|
res.type('txt').send(data.toString());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
app.route('/_api/controllers/convertHandler.js')
|
|
|
|
.get(function(req, res, next) {
|
|
|
|
console.log('requested');
|
|
|
|
fs.readFile(__dirname + '/controllers/convertHandler.js', function(err, data) {
|
|
|
|
if(err) return next(err);
|
|
|
|
res.type('txt').send(data.toString());
|
|
|
|
});
|
|
|
|
});
|
2021-08-24 18:19:56 +02:00
|
|
|
|
2017-02-18 20:14:10 +01:00
|
|
|
app.get('/_api/get-tests', cors(), function(req, res, next){
|
2021-08-24 18:19:56 +02:00
|
|
|
console.log('requested');
|
|
|
|
if(process.env.NODE_ENV === 'test') return next();
|
2017-02-18 20:14:10 +01:00
|
|
|
res.json({status: 'unavailable'});
|
|
|
|
},
|
|
|
|
function(req, res, next){
|
|
|
|
if(!runner.report) return next();
|
|
|
|
res.json(testFilter(runner.report, req.query.type, req.query.n));
|
|
|
|
},
|
|
|
|
function(req, res){
|
|
|
|
runner.on('done', function(report){
|
|
|
|
process.nextTick(() => res.json(testFilter(runner.report, req.query.type, req.query.n)));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
app.get('/_api/app-info', function(req, res) {
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
let hs = Object.keys(res._headers)
|
2017-02-18 20:14:10 +01:00
|
|
|
.filter(h => !h.match(/^access-control-\w+/));
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
let hObj = {};
|
2017-02-18 20:14:10 +01:00
|
|
|
hs.forEach(h => {hObj[h] = res._headers[h]});
|
|
|
|
delete res._headers['strict-transport-security'];
|
|
|
|
res.json({headers: hObj});
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
function testFilter(tests, type, n) {
|
Fix (Boilerplate): Add Event Parameter to test, Remove Infosec Requriements, Add Lowercase Requirement (#12)
* Fix missing event, correct example conversion
* Fix unit case
* Remove Infosec items, add lowercase requirement
* Convert to ES6, Update Packages, Fix display
* Applying @nhcarrigan's changes from site tests
* Removed unneeded mongodb ref
* Remove User Stories, Reformat README
* Apply suggestions from code review - Remove "Quality Assurance Project" Prefix
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
* Re-add the example text, clean up formatting
* Update Favicon
* Fix repo link, remove zombie.js
* Remove unused files, add sample.env
Co-authored-by: Shaun Hamilton <51722130+Sky020@users.noreply.github.com>
Co-authored-by: Rex Schrader <rex.schader@gmail.com>
2020-11-25 16:09:04 +01:00
|
|
|
let out;
|
2017-02-18 20:14:10 +01:00
|
|
|
switch (type) {
|
|
|
|
case 'unit' :
|
|
|
|
out = tests.filter(t => t.context.match('Unit Tests'));
|
|
|
|
break;
|
|
|
|
case 'functional':
|
|
|
|
out = tests.filter(t => t.context.match('Functional Tests') && !t.title.match('#example'));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
out = tests;
|
|
|
|
}
|
|
|
|
if(n !== undefined) {
|
|
|
|
return out[n] || out;
|
|
|
|
}
|
|
|
|
return out;
|
|
|
|
}
|