Skip to content

Commit

Permalink
test: fix tests after staging update
Browse files Browse the repository at this point in the history
  • Loading branch information
Mila Votradovec committed Mar 18, 2021
1 parent 9db70e6 commit 78173e2
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions tests/api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,28 +424,30 @@ 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]:DeepCodeAI/cli.git',
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;
});

it(
'git analysis',
async () => {
const bundleId = 'gh/DeepcodeAI/cli/320d98a6896f5376efe6cefefb6e70b46b97d566';

// Get analysis results
const response = await getAnalysis({
baseURL,
sessionToken,
bundleId,
bundleId: goofBundleId,
includeLint: false,
severity: 1,
source: 'atom',
Expand All @@ -455,26 +457,27 @@ describe('Requests to public API', () => {
expect(response.value.status !== AnalysisStatus.failed).toBeTruthy();

if (response.value.status === AnalysisStatus.done) {
expect(response.value.analysisURL.includes(bundleId)).toBeTruthy();
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', 'InTest']);
expect(suggestion.categories).toEqual(['Security']);
expect(suggestion).toHaveProperty('exampleCommitDescriptions');
expect(suggestion).toHaveProperty('exampleCommitFixes');
expect(suggestion.leadURL).toEqual('');
expect(suggestion.id).toEqual('python%2Fdc%2FHardcodedNonCryptoSecret%2Ftest');
expect(suggestion.id).toEqual('javascript%2Fdc_interfile_project%2FHttpToHttps');
expect(suggestion.message).toContain(
'Avoid hardcoding values that are meant to be secret. Found a hardcoded string used in here.',
'http (used in require) is an insecure protocol and should not be used in new code.',
);
expect(suggestion.rule).toEqual('HardcodedNonCryptoSecret/test');
expect(suggestion.severity).toEqual(1);
expect(suggestion.tags).toEqual(['maintenance', 'bug', 'key', 'secret', 'credentials']);
expect(Object.keys(response.value.analysisResults.files).length).toEqual(1);
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',
Expand Down

0 comments on commit 78173e2

Please sign in to comment.