-
Notifications
You must be signed in to change notification settings - Fork 534
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
test: user journey tests for Go based snyk code test [CLI-225] #5172
Open
j-luong
wants to merge
34
commits into
main
Choose a base branch
from
chore/CLI-225_validateNativeSnykCode
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
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.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
def598e
test: adding code test native workflow acceptance test (WIP)
j-luong 4fb77d3
test: user journey tests for Go based snyk code
j-luong 035d083
test: split snyk code tests between user journey/integration tests
j-luong 3be05d5
test: split user journey (e2e) out to separate file
thisislawatts a714c5e
test: split user journey (e2e) out to separate file
thisislawatts d60ebd5
test: experimental
thisislawatts 9cb4948
test: run all tests
thisislawatts b1a20ed
chore(deps): remove unused nock
thisislawatts 0f5707a
test: remove unused var
thisislawatts 6e835cf
test: focus test cases for stability
thisislawatts 76032ad
test: passing happy case
thisislawatts e3cd196
test: passing happy case
thisislawatts 012e126
test: all tests are passing
thisislawatts 12c6078
test: failure for empty project
thisislawatts 848a50c
test: all tests are passing
thisislawatts 059ffe1
test: add validation for local code engine behaviour
thisislawatts acc30b9
test: remove e2e spec
thisislawatts 4735ef7
chore: remove local link
thisislawatts 7a55dd3
test: relabel suite
thisislawatts 9a06da0
test: introduce e2e verification of happy path
thisislawatts 8531505
test: skip local engine tests until native workflow supports it
thisislawatts 42069f9
test: add journey tests
mgyorke 1a50320
test: fix analytics tests
mgyorke cc1946d
test: added empty file
mgyorke c07290c
fix: revert unintended changes
mgyorke 7b725f7
fix: include empty folder for testing
mgyorke 779f447
test: wip integration tests
mgyorke 9d0cfbb
test(code): WIP clean-up code acceptance tests
j-luong e5937dc
test(code): WIP adding some golang/native snyk code tests
j-luong 5f342e2
test: WIP fixes integration tests on native workflow
mgyorke 018c0f4
test: skip lce on native and small code cleanup
mgyorke 6c5233e
test: fixed warnings and remove unused code from dev
mgyorke 08662f8
test: use environment variables for credentials and endpoint
mgyorke 521dd24
test: remove dev debug logging
mgyorke File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,9 @@ export const fakeServer = (basePath: string, snykToken: string): FakeServer => { | |
}; | ||
|
||
const popRequest = () => { | ||
return requests.pop()!; | ||
const request = requests?.pop(); | ||
if (request) return request; | ||
else throw new Error('No request found in requests array'); | ||
}; | ||
|
||
const popRequests = (num: number) => { | ||
|
@@ -225,6 +227,89 @@ export const fakeServer = (basePath: string, snykToken: string): FakeServer => { | |
} | ||
}); | ||
|
||
// needed for code-client-go | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was debating if we should move should move these mock responses into a separate file. |
||
app.get('/deeproxy/filters', (req, res) => { | ||
res.status(200); | ||
if (customResponse) { | ||
res.send(customResponse); | ||
} | ||
res.send({}); | ||
}); | ||
|
||
// needed for code-client-go | ||
app.post('/deeproxy/bundle', (req, res) => { | ||
res.status(200); | ||
res.send({ | ||
bundleHash: | ||
'faa6b7161c14f933ef4ca79a18ad9283eab362d5e6d3a977125eb95b37c377d8', | ||
missingFiles: [], | ||
}); | ||
}); | ||
|
||
// needed for code-client-go | ||
app.post(`/api/rest/orgs/:orgId/scans`, (req, res) => { | ||
res.status(201); | ||
res.send({ data: { id: 'a6fb2742-b67f-4dc3-bb27-42b67f1dc344' } }); | ||
}); | ||
|
||
// needed for code-client-go | ||
app.get(`/api/rest/orgs/:orgId/scans/:id`, (req, res) => { | ||
res.status(200); | ||
res.send({ | ||
data: { | ||
attributes: { | ||
status: 'done', | ||
components: [ | ||
{ findings_url: 'http://localhost:12345/api/code_mock_stream' }, | ||
], | ||
}, | ||
id: 'a6fb2742-b67f-4dc3-bb27-42b67f1dc344', | ||
}, | ||
}); | ||
}); | ||
|
||
app.get(`/api/code_mock_stream`, (req, res) => { | ||
res.status(200); | ||
res.send({ | ||
$schema: | ||
'https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json', | ||
version: '2.1.0', | ||
runs: [ | ||
{ | ||
tool: { | ||
driver: { | ||
name: 'SnykCode', | ||
semanticVersion: '1.0.0', | ||
version: '1.0.0', | ||
rules: [], | ||
}, | ||
}, | ||
results: [ | ||
{ | ||
ruleId: 'javascript/DisablePoweredBy', | ||
ruleIndex: 1, | ||
level: 'warning', | ||
}, | ||
], | ||
properties: { | ||
coverage: [ | ||
{ | ||
files: 8, | ||
isSupported: true, | ||
lang: 'JavaScript', | ||
}, | ||
{ | ||
files: 1, | ||
isSupported: true, | ||
lang: 'HTML', | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
}); | ||
}); | ||
|
||
app.post(basePath + '/vuln/:registry', (req, res, next) => { | ||
const vulnerabilities = []; | ||
if (req.query.org && req.query.org === 'missing-org') { | ||
|
@@ -611,6 +696,14 @@ export const fakeServer = (basePath: string, snykToken: string): FakeServer => { | |
}, | ||
); | ||
|
||
// needed for code-client-go | ||
app.post( | ||
basePath.replace('v1', 'hidden') + `/orgs/:orgId/workspaces`, | ||
(req, res) => { | ||
res.status(201).send({}); | ||
}, | ||
); | ||
|
||
app.post(`/rest/orgs/:orgId/sbom_tests`, (req, res) => { | ||
const response = { | ||
data: { | ||
|
@@ -861,7 +954,7 @@ export const fakeServer = (basePath: string, snykToken: string): FakeServer => { | |
getRequests, | ||
popRequest, | ||
popRequests, | ||
setCustomResponse: setCustomResponse, | ||
setCustomResponse, | ||
setLocalCodeEngineConfiguration, | ||
setNextResponse, | ||
setNextStatusCode, | ||
|
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,2 @@ | ||
const message: string = 'Hello, World!'; | ||
console.log(message); |
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 @@ | ||
# git include me |
Oops, something went wrong.
Oops, something went wrong.
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.
these small changes are pedantic and unrelated to the work but we get rid of a few linting warnings.