Skip to content

Commit

Permalink
clean up regex, mesage
Browse files Browse the repository at this point in the history
  • Loading branch information
gardnerjr committed May 6, 2019
1 parent 20cc1bb commit 0a1a53b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/jsonValidationTest.js
Expand Up @@ -52,7 +52,7 @@ describe('Validating Workbooks...', () => {
browseDirectory(workbookPath, (error, results) => {
results.filter(file => file.substr(-9) === '.workbook')
.forEach(file => {
validateJsonStringAndGetObject(file);
let settings = validateJsonStringAndGetObject(file);
validateNoResourceIds(settings, file);
});

Expand Down Expand Up @@ -103,7 +103,7 @@ var browseDirectory = function (dir, done, hasRoot=false, rootDir="") {
next();
});
} else {
if (hasRoot && dir === rootDir) {
if (hasRoot && dir === rootDir) {
next();
} else {
results.push(file);
Expand Down Expand Up @@ -136,9 +136,9 @@ function validateNoResourceIds(settings, file) {
// there's probably a better way but this is simplest. make sure there are no strings like '/subscriptions/[guid]` in the whole content
// not parsing individual steps/etc at this time
let str = JSON.stringify(settings);
let regexp = /(\/subscriptions\/[a-z0-9]{8}-)/gi; // just loking for /subscriptions/[first part of guid]
let regexp = /(\/subscriptions\/[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})/gi;
while ((matches = regexp.exec(str)) !== null) {
assert.fail(file + ": Found possible resource Id " + matches[0]);
assert.fail(file + ": Found probably hardcoded resource Id '" + matches[0] + "'");
}
}

Expand Down

0 comments on commit 0a1a53b

Please sign in to comment.