Skip to content

Commit

Permalink
test: remove non-applicable cli sarif acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
j-luong committed Mar 22, 2024
1 parent 7ef01c7 commit 9a3286e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 55 deletions.
4 changes: 2 additions & 2 deletions test/acceptance/fake-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export const fakeServer = (basePath: string, snykToken: string): FakeServer => {
return next();
});

app.post(basePath + '/test-dependencies', (req, res) => {
app.post(basePath + '/test-dependencies', (req, res, next) => {
if (req.query.org && req.query.org === 'missing-org') {
res.status(404).send({
code: 404,
Expand All @@ -324,7 +324,7 @@ export const fakeServer = (basePath: string, snykToken: string): FakeServer => {

if (customResponse) {
res.send(customResponse);
return;
return next();
}

res.send({
Expand Down
53 changes: 0 additions & 53 deletions test/jest/acceptance/cli-sarif-output.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { fakeServer } from '../../acceptance/fake-server';
import { createProjectFromWorkspace } from '../util/createProject';
import { runSnykCLI } from '../util/runSnykCLI';
import * as Parser from 'jsonparse';

jest.setTimeout(1000 * 60);

Expand Down Expand Up @@ -72,56 +71,4 @@ describe('test --sarif', () => {
expect(outputObj.runs[0].results.length > 0).toBeTruthy();
expect(outputObj.runs[0].results[0].ruleId).toEqual(expectedRuleId);
});

describe('handling responses larger than 512Mb string size limit in v8', () => {
it('container test --sarif', async () => {
const expectedReferenceNumber = 420000;
const issueID = 'SNYK-ALPINE319-OPENSSL-6148881';
const project = await createProjectFromWorkspace(
'extra-large-response-payload',
);
const response = await project.readJSON('vulns-result-sarif.json');
const reference = response.result.issuesData[issueID].references[0];
response.result.issuesData[issueID].references = new Array(
expectedReferenceNumber,
).fill(reference);

server.setCustomResponse(response);

const imageName = 'hello-world:latest';
const { code, stdoutBuffer, stderrBuffer } = await runSnykCLI(
`container test --platform=linux/amd64 ${imageName} --sarif`,
{
cwd: project.path(),
env,
bufferOutput: true,
},
);

if (stderrBuffer && stderrBuffer.length > 0)
console.log(stderrBuffer?.toString('utf8'));

let hasExpectedSchema = false;
let hasExpectedVersion = false;

const expectedSchema =
'https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json';
const expectedVersion = '2.1.0';

const p = new Parser();
p.onValue = function(value) {
if (this.key === '$schema' && value === expectedSchema) {
hasExpectedSchema = true;
} else if (this.key === 'version' && value === expectedVersion) {
hasExpectedVersion = true;
}
};

p.write(stdoutBuffer);

expect(code).toEqual(1);
expect(hasExpectedSchema).toBeTruthy();
expect(hasExpectedVersion).toBeTruthy();
}, 120000);
});
});

0 comments on commit 9a3286e

Please sign in to comment.