-
Notifications
You must be signed in to change notification settings - Fork 687
test(sbom-monitor): add Dragonfly user journey acceptance test #6870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jacek-rzrz
wants to merge
1
commit into
main
Choose a base branch
from
test/osf-422/sbom-monitor-dragonfly-user-journey
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+53
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
53 changes: 53 additions & 0 deletions
53
test/jest/acceptance/snyk-sbom-test/sbom-test-user-journey.spec.ts
This file contains hidden or 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,53 @@ | ||
| import { existsSync } from 'fs'; | ||
|
|
||
| import { runSnykCLI } from '../../util/runSnykCLI'; | ||
| import { getFixturePath } from '../../util/getFixturePath'; | ||
|
|
||
| jest.setTimeout(1000 * 300); | ||
|
|
||
| const SBOM_FILE_PATH = getFixturePath('sbom/snyk-goof-sbom.json'); | ||
| const ASSET_NAME = 'cli-sbom-monitor-user-journey'; | ||
|
|
||
| // Marker to make this user-journey test easy to locate in CI output. | ||
| const LOG_TAG = '[sbom-monitor-user-journey]'; | ||
|
|
||
| const dragonflyEnv = { | ||
| ...process.env, | ||
| SNYK_API: process.env.TEST_SNYK_API_DEV, | ||
| SNYK_TOKEN: process.env.TEST_SNYK_TOKEN_DEV, | ||
| INTERNAL_SNYK_CLI_ROLLOUT_DFLY_SBOM_MONITOR: 'true', | ||
| }; | ||
|
|
||
| const describeIfPreProd = process.env.TEST_SNYK_TOKEN_DEV | ||
| ? describe | ||
| : describe.skip; | ||
|
|
||
| beforeAll(() => { | ||
| if (!existsSync(SBOM_FILE_PATH)) { | ||
| throw new Error( | ||
| `SBOM fixture not found at ${SBOM_FILE_PATH}. Please ensure test fixtures are properly set up.`, | ||
| ); | ||
| } | ||
| }); | ||
|
|
||
| describeIfPreProd('snyk sbom test --report', () => { | ||
| it('should successfully test an SBOM', async () => { | ||
| const command = `sbom test --report --experimental --file=${SBOM_FILE_PATH} --asset-name=${ASSET_NAME}`; | ||
| console.log(`${LOG_TAG} running: snyk ${command}`); | ||
|
|
||
| const { code, stdout, stderr } = await runSnykCLI(command, { | ||
| env: dragonflyEnv, | ||
| }); | ||
|
|
||
| // Emit the full CLI result so the run is verifiable from the CI logs even | ||
| // when the assertions pass silently. | ||
| console.log(`${LOG_TAG} exit code: ${code}`); | ||
| console.log(`${LOG_TAG} stdout:\n${stdout}`); | ||
| console.log(`${LOG_TAG} stderr:\n${stderr}`); | ||
|
|
||
| expect(stderr).toBe(''); | ||
| expect(stdout).toContain('View your asset(s) at:'); | ||
| // The goof SBOM fixture contains known vulnerabilities, so the CLI exits 1. | ||
| expect(code).toBe(1); | ||
| }); | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical Bug: Wrong command is being executed
The test is intended to test
snyk sbom monitor(per the file name, describe block, test name, and PR description), but the command actually executessbom testinstead:This should be:
The
--reportflag is not needed forsbom monitoras monitoring inherently reports to the server. This bug causes the test to validate the wrong CLI functionality entirely, making it fail to test the Dragonfly SBOM monitor flow as intended.Spotted by Graphite

Is this helpful? React 👍 or 👎 to let us know.