Skip to content

Commit

Permalink
fix: fail-on with severity-threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
gitphill committed Feb 25, 2020
1 parent 01e29dd commit 8aea485
Show file tree
Hide file tree
Showing 4 changed files with 360 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/acceptance/cli-fail-on.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ const patchableResult = getWorkspaceJSON(
'patchable',
'vulns-result.json',
);
const multiSeveritiesResult = getWorkspaceJSON(
'fail-on',
'multiple-severities',
'vulns-result.json',
);

// @later: remove this config stuff.
// Was copied straight from ../src/cli-server.js
Expand Down Expand Up @@ -392,6 +397,22 @@ test('test project with no vulns and --fail-on=patchable --json', async (t) => {
}
});

test('test project with multiple severities with upgrade and patch with --fail-on=patchable and --severity=high', async (t) => {
try {
server.setNextResponse(multiSeveritiesResult);
chdirWorkspaces('fail-on');
await cli.test('multiple-severities', {
failOn: 'upgradable',
severityThreshold: 'high',
});
t.fail('expected test to throw exception');
} catch (err) {
t.match(err, /Patchable issues/, 'should show patchable issues');
t.notMatch(err, /Issues to fix by upgrading/, 'should not show upgradable issues');
t.equal(err.code, 'VULNS', 'should throw exception');
}
});

// test invalid arg
test('test project with --fail-on=invalid', async (t) => {
try {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "upgradable-app",
"version": "1.0.0",
"description": "multiple severity vulns that are upgradable",
"dependencies": {
"yarn": "1.17.1",
"ms": "^1.0.0"
},
"devDependencies": {}
}
Loading

0 comments on commit 8aea485

Please sign in to comment.