Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support --all-projects for sbom command
Co-authored-by: Max <max.combuchen@snyk.io>
- Loading branch information
1 parent
6989e20
commit 849268c
Showing
5 changed files
with
92 additions
and
10 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
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { createProjectFromWorkspace } from '../../util/createProject'; | ||
import { runSnykCLI } from '../../util/runSnykCLI'; | ||
import { fakeServer } from '../../../acceptance/fake-server'; | ||
import { isCLIV2 } from '../../util/isCLIV2'; | ||
|
||
jest.setTimeout(1000 * 60 * 5); | ||
|
||
describe('snyk sbom --all-projects (mocked server only)', () => { | ||
let server; | ||
let env: Record<string, string>; | ||
|
||
beforeAll((done) => { | ||
const port = process.env.PORT || process.env.SNYK_PORT || '58585'; | ||
const baseApi = '/api/v1'; | ||
env = { | ||
...process.env, | ||
SNYK_API: 'http://localhost:' + port + baseApi, | ||
SNYK_HOST: 'http://localhost:' + port, | ||
SNYK_TOKEN: '123456789', | ||
SNYK_DISABLE_ANALYTICS: '1', | ||
}; | ||
server = fakeServer(baseApi, env.SNYK_TOKEN); | ||
server.listen(port, () => { | ||
done(); | ||
}); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.resetAllMocks(); | ||
server.restore(); | ||
}); | ||
|
||
afterAll((done) => { | ||
server.close(() => { | ||
done(); | ||
}); | ||
}); | ||
|
||
test('`sbom mono-repo-project` generates an SBOM for multiple projects', async () => { | ||
const project = await createProjectFromWorkspace('mono-repo-project'); | ||
|
||
if (isCLIV2()) { | ||
const { code, stdout } = await runSnykCLI( | ||
`sbom --org aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee --format cyclonedx1.4+json --debug --all-projects`, | ||
{ | ||
cwd: project.path(), | ||
env, | ||
}, | ||
); | ||
|
||
expect(code).toEqual(0); | ||
expect(stdout).toEqual( | ||
expect.stringContaining( | ||
'{"bomFormat":"CycloneDX","metadata":{"component":{"name":"mono-repo-project"}}}', | ||
), | ||
); | ||
} | ||
}); | ||
}); |