Skip to content

Commit

Permalink
test: experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
thisislawatts committed May 6, 2024
1 parent 7be0f77 commit b579944
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 5 deletions.
3 changes: 2 additions & 1 deletion cliv2/go.mod
Expand Up @@ -202,4 +202,5 @@ require (
// version 2491eb6c1c75 contains a valid license
replace github.com/mattn/go-localereader v0.0.1 => github.com/mattn/go-localereader v0.0.2-0.20220822084749-2491eb6c1c75

//replace github.com/snyk/go-application-framework => ../../go-application-framework
replace github.com/snyk/code-client-go => ../../code-client-go
replace github.com/snyk/go-application-framework => ../../go-application-framework
39 changes: 39 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -165,6 +165,7 @@
"jsonparse": "^1.3.1",
"lodash": "^4.17.20",
"mock-fs": "^4.13.0",
"nock": "^14.0.0-beta.6",
"node-loader": "^2.0.0",
"npm-run-all": "^4.1.5",
"patch-package": "^6.5.0",
Expand Down
10 changes: 9 additions & 1 deletion test/acceptance/fake-server.ts
Expand Up @@ -112,7 +112,6 @@ export const fakeServer = (basePath: string, snykToken: string): FakeServer => {
};

const setNextResponse = (response: string | Record<string, unknown>) => {
console.log(`Fake server setNextResponse: ${response}`)
if (typeof response === 'string') {
nextResponse = JSON.parse(response);
return;
Expand Down Expand Up @@ -156,6 +155,7 @@ export const fakeServer = (basePath: string, snykToken: string): FakeServer => {
app.use(express.json({ type: 'application/vnd.api+json', strict: false }));
app.use((req, res, next) => {
requests.push(req);
console.log(req.method, req.url, req.body);
next();
});

Expand Down Expand Up @@ -225,6 +225,14 @@ export const fakeServer = (basePath: string, snykToken: string): FakeServer => {
}
});

// Supporting new code test
app.get('/deeproxy/filters', (req, res) => {
return res.send({
configFiles: ["test"],
extensions: ["test"],
});
});

app.post(basePath + '/vuln/:registry', (req, res, next) => {
const vulnerabilities = [];
if (req.query.org && req.query.org === 'missing-org') {
Expand Down
10 changes: 7 additions & 3 deletions test/jest/acceptance/snyk-code/snyk-code.spec.ts
Expand Up @@ -4,9 +4,13 @@ import { fakeServer } from '../../../acceptance/fake-server';
import { fakeDeepCodeServer } from '../../../acceptance/deepcode-fake-server';
import { getServerPort } from '../../util/getServerPort';
import { matchers } from 'jest-json-schema';
import * as nock from 'nock'

const stripAnsi = require('strip-ansi');

nock.disableNetConnect()


expect.extend(matchers);

const EXIT_CODE_ACTION_NEEDED = 1;
Expand Down Expand Up @@ -83,7 +87,7 @@ describe('snyk code test', () => {
'integration',
({ type, env: integrationEnv }) => {
describe(`${type} workflow`, () => {
it.only('should show error if sast is not enabled', async () => {
it.skip('should show error if sast is not enabled', async () => {
// Setup
const { path } = await createProjectFromFixture(
'sast/shallow_sast_webgoat',
Expand All @@ -105,7 +109,7 @@ describe('snyk code test', () => {
expect(code).toBe(EXIT_CODE_FAIL_WITH_ERROR);
});

it('succeed testing with correct exit code - with sarif oputput and no markdown', async () => {
it.only('succeed testing with correct exit code - with sarif oputput and no markdown', async () => {
const sarifPayload = require('../../../fixtures/sast/sample-sarif.json');
const { path } = await createProjectFromFixture(
'sast/shallow_sast_webgoat',
Expand All @@ -114,7 +118,7 @@ describe('snyk code test', () => {
deepCodeServer.setSarifResponse(sarifPayload);

const { stdout, stderr, code } = await runSnykCLI(
`code test ${path()} --sarif --no-markdown`,
`code test ${path()} --sarif --no-markdown -d`,
{
env: {
...env,
Expand Down

0 comments on commit b579944

Please sign in to comment.