-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for reachability analysis call
- Loading branch information
Showing
4 changed files
with
97 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -424,60 +424,99 @@ describe('Requests to public API', () => { | |
TEST_TIMEOUT, | ||
); | ||
|
||
describe('git analysis', () => { | ||
let goofBundleId: string; | ||
|
||
it('create git bundle', async () => { | ||
const bundleResponse = await createGitBundle({ | ||
baseURL, | ||
sessionToken, | ||
gitUri: '[email protected]:snyk/goof.git', | ||
source: 'atom', | ||
}); | ||
expect(bundleResponse.type).toEqual('success'); | ||
if (bundleResponse.type === 'error') return; | ||
expect(bundleResponse.value.bundleId).toBeTruthy(); | ||
goofBundleId = bundleResponse.value.bundleId; | ||
}); | ||
describe('git analysis', () => { | ||
let goofBundleId: string; | ||
|
||
it( | ||
'git analysis', | ||
async () => { | ||
// Get analysis results | ||
const response = await getAnalysis({ | ||
it('create git bundle', async () => { | ||
const bundleResponse = await createGitBundle({ | ||
baseURL, | ||
sessionToken, | ||
bundleId: goofBundleId, | ||
includeLint: false, | ||
severity: 1, | ||
gitUri: '[email protected]:snyk/goof.git', | ||
source: 'atom', | ||
}); | ||
expect(response.type).toEqual('success'); | ||
if (response.type === 'error') return; | ||
expect(response.value.status !== AnalysisStatus.failed).toBeTruthy(); | ||
expect(bundleResponse.type).toEqual('success'); | ||
if (bundleResponse.type === 'error') return; | ||
expect(bundleResponse.value.bundleId).toBeTruthy(); | ||
goofBundleId = bundleResponse.value.bundleId; | ||
}); | ||
|
||
if (response.value.status === AnalysisStatus.done) { | ||
expect(response.value.analysisURL.includes(goofBundleId)).toBeTruthy(); | ||
expect(response.value.analysisResults.suggestions).toBeTruthy(); | ||
it( | ||
'git analysis', | ||
async () => { | ||
// Get analysis results | ||
const response = await getAnalysis({ | ||
baseURL, | ||
sessionToken, | ||
bundleId: goofBundleId, | ||
includeLint: false, | ||
severity: 1, | ||
source: 'atom', | ||
}); | ||
expect(response.type).toEqual('success'); | ||
if (response.type === 'error') return; | ||
expect(response.value.status !== AnalysisStatus.failed).toBeTruthy(); | ||
|
||
const suggestion = response.value.analysisResults.suggestions[0]; | ||
expect(suggestion.categories).toEqual(['Security']); | ||
expect(suggestion).toHaveProperty('exampleCommitDescriptions'); | ||
expect(suggestion).toHaveProperty('exampleCommitFixes'); | ||
expect(suggestion.leadURL).toEqual(''); | ||
expect(suggestion.id).toEqual('javascript%2Fdc_interfile_project%2FHttpToHttps'); | ||
expect(suggestion.message).toContain( | ||
'http (used in require) is an insecure protocol and should not be used in new code.', | ||
); | ||
expect(suggestion.rule).toEqual('HttpToHttps'); | ||
expect(suggestion.severity).toEqual(2); | ||
expect(suggestion.tags).toEqual(['maintenance', 'http', 'server']); | ||
expect(Object.keys(response.value.analysisResults.files).length).toEqual(3); | ||
} | ||
}, | ||
TEST_TIMEOUT, | ||
); | ||
}); | ||
if (response.value.status === AnalysisStatus.done) { | ||
expect(response.value.analysisURL.includes(goofBundleId)).toBeTruthy(); | ||
expect(response.value.analysisResults.suggestions).toBeTruthy(); | ||
|
||
const suggestion = response.value.analysisResults.suggestions[0]; | ||
expect(suggestion.categories).toEqual(['Security']); | ||
expect(suggestion).toHaveProperty('exampleCommitDescriptions'); | ||
expect(suggestion).toHaveProperty('exampleCommitFixes'); | ||
expect(suggestion.leadURL).toEqual(''); | ||
expect(suggestion.id).toEqual('javascript%2Fdc_interfile_project%2FHttpToHttps'); | ||
expect(suggestion.message).toContain( | ||
'http (used in require) is an insecure protocol and should not be used in new code.', | ||
); | ||
expect(suggestion.rule).toEqual('HttpToHttps'); | ||
expect(suggestion.severity).toEqual(2); | ||
expect(suggestion.tags).toEqual(['maintenance', 'http', 'server']); | ||
expect(Object.keys(response.value.analysisResults.files).length).toEqual(3); | ||
} | ||
}, | ||
TEST_TIMEOUT, | ||
); | ||
//TODO(Artur): need to adjust this test after we introduce the required changes in api server | ||
it.skip( | ||
'git analysis with reachability flag', | ||
async () => { | ||
// Get analysis results | ||
const response = await getAnalysis({ | ||
baseURL, | ||
sessionToken, | ||
bundleId: goofBundleId, | ||
includeLint: false, | ||
severity: 1, | ||
source: 'atom', | ||
reachability: true, | ||
}); | ||
expect(response.type).toEqual('success'); | ||
if (response.type === 'error') return; | ||
expect(response.value.status !== AnalysisStatus.failed).toBeTruthy(); | ||
|
||
if (response.value.status === AnalysisStatus.done) { | ||
expect(response.value.analysisURL.includes(goofBundleId)).toBeTruthy(); | ||
expect(response.value.analysisResults.suggestions).toBeTruthy(); | ||
|
||
const suggestion = response.value.analysisResults.suggestions[0]; | ||
expect(suggestion.categories).toEqual(['Security']); | ||
expect(suggestion).toHaveProperty('exampleCommitDescriptions'); | ||
expect(suggestion).toHaveProperty('exampleCommitFixes'); | ||
expect(suggestion.leadURL).toEqual(''); | ||
expect(suggestion.id).toEqual('javascript%2Fdc_interfile_project%2FHttpToHttps'); | ||
expect(suggestion.message).toContain( | ||
'http (used in require) is an insecure protocol and should not be used in new code.', | ||
); | ||
expect(suggestion.rule).toEqual('HttpToHttps'); | ||
expect(suggestion.severity).toEqual(2); | ||
expect(suggestion.tags).toEqual(['maintenance', 'http', 'server']); | ||
expect(Object.keys(response.value.analysisResults.files).length).toEqual(3); | ||
} | ||
}, | ||
TEST_TIMEOUT, | ||
); | ||
}); | ||
|
||
it( | ||
'git analysis with empty results', | ||
|