This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
router.post('/abc', validateParams([ | |
{ | |
param_key: 'abc', | |
required: true, | |
type: 'string', | |
validator_functions: [(param) => {return param.length === 10}] | |
}]), routeFunction); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const validateParams = function (requestParams) { | |
return function (req, res, next) { | |
for (let param of requestParams) { | |
if (checkParamPresent(Object.keys(req.body), param)) { | |
let reqParam = req.body[param.param_key]; | |
if (!checkParamType(reqParam, param)) { | |
return res.send(400, { | |
status: 400, | |
result: `${param.param_key} is of type ` + | |
`${typeof reqParam} but should be ${param.type}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
# Read the second command line argument as the file name | |
read_file = open(sys.argv[1], 'r') | |
# Read the third command line argument as the output file name | |
write_file = open(sys.argv[2], 'w') | |
temp = '' | |
flag = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
'scan_result':OrderedDict( [ | |
('scanned_json_result', | |
{ | |
u'files':[ | |
{ | |
u'licenses':[ | |
{ | |
u'category':u'Permissive', | |
u'dejacode_url': u'https: //enterprise.dejacode.com/urn/urn: dje: license:apache-2.0', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.test import TestCase | |
from scanapp.models import ScanInfo | |
class ScanInfoTestCase(TestCase): | |
def test_scan_info_added(self): | |
URL_scan_info = ScanInfo(scan_type="URL", is_complete=True) | |
local_scan_info = ScanInfo(scan_type="localscan", is_complete=False) | |
URL_scan_info = ScanInfo.objects.get(scan_type="URL") |
NewerOlder