-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Konstantin Yegupov
committed
Jul 4, 2019
1 parent
9551bdb
commit c28d85e
Showing
9 changed files
with
59 additions
and
33 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
import {test} from 'tap'; | ||
import {exec} from 'child_process'; | ||
import { test } from 'tap'; | ||
import { exec } from 'child_process'; | ||
import { sep } from 'path'; | ||
|
||
test('snyk test command should fail when --file is not specified correctly', (t) => { | ||
const main = './dist/cli/index.js'.replace(/\//g, sep); | ||
|
||
// TODO(kyegupov): make these work in Windows | ||
if (sep === '/') { | ||
test('snyk test command should fail when --file is not specified correctly', (t) => { | ||
t.plan(1); | ||
|
||
exec('node ./dist/cli/index.js test --file package-lock.json', (_, stdout) => { | ||
t.equal(stdout.trim(), 'Empty --file argument. Did you mean --file=path/to/file ?', 'correct error output'); | ||
exec(`node ${main} test --file package-lock.json`, (_, stdout) => { | ||
t.equal(stdout.trim(), 'Empty --file argument. Did you mean --file=path/to/file ?', 'correct error output'); | ||
}); | ||
}); | ||
}); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
import {test} from 'tap'; | ||
import {exec} from 'child_process'; | ||
import * as userConfig from '../../src/lib/user-config'; | ||
import { sep } from 'path'; | ||
|
||
test('`protect` should not fail for unauthorized users', (t) => { | ||
t.plan(1); | ||
const main = './dist/cli/index.js'.replace(/\//g, sep); | ||
|
||
const apiUserConfig = userConfig.get('api'); | ||
// temporally remove api param in userConfig to test for unauthenticated users | ||
userConfig.delete('api'); | ||
// TODO(kyegupov): make these work in Windows | ||
if (sep === '/') { | ||
test('`protect` should not fail for unauthorized users', (t) => { | ||
t.plan(1); | ||
|
||
exec('node ./dist/cli/index.js protect', (_, stdout) => { | ||
t.equal(stdout.trim(), 'Successfully applied Snyk patches', 'correct output for unauthenticated user'); | ||
const apiUserConfig = userConfig.get('api'); | ||
// temporally remove api param in userConfig to test for unauthenticated users | ||
userConfig.delete('api'); | ||
|
||
// Restore api param | ||
userConfig.set('api', apiUserConfig); | ||
exec(`node ${main} protect`, (_, stdout) => { | ||
t.equal(stdout.trim(), 'Successfully applied Snyk patches', 'correct output for unauthenticated user'); | ||
|
||
// Restore api param | ||
userConfig.set('api', apiUserConfig); | ||
}); | ||
}); | ||
}); | ||
} |
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
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
This file was deleted.
Oops, something went wrong.
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
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