Skip to content

Commit

Permalink
Merge pull request #976 from snyk/feat/composer-auto-manifest
Browse files Browse the repository at this point in the history
feat: enable composer.lock for --all-projects
  • Loading branch information
lili2311 authored Jan 27, 2020
2 parents 2e044f4 + cdb6de4 commit 96de91d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const AUTO_DETECTABLE_FILES: string[] = [
'project.assets.json',
'Podfile',
'Podfile.lock',
'composer.lock',
];

// when file is specified with --file, we look it up here
Expand Down
29 changes: 29 additions & 0 deletions test/acceptance/cli-monitor/cli-monitor.all-projects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,35 @@ export const AllProjectsTests: AcceptanceTests = {
'Same body for --all-projects and --file=pom.xml',
);
},
'`monitor composer-app with --all-projects and without same meta`': (
params,
utils,
) => async (t) => {
utils.chdirWorkspaces();
const spyPlugin = sinon.spy(params.plugins, 'loadPlugin');
t.teardown(spyPlugin.restore);

await params.cli.monitor('composer-app', {
allProjects: true,
});
// Pop all calls to server and filter out calls to `featureFlag` endpoint
const [composerAll] = params.server
.popRequests(2)
.filter((req) => req.url.includes('/monitor/'));

await params.cli.monitor('composer-app', {
file: 'composer.lock',
});
const [requestsComposer] = params.server
.popRequests(2)
.filter((req) => req.url.includes('/monitor/'));

t.deepEqual(
composerAll.body,
requestsComposer.body,
'Same body for --all-projects and --file=composer.lock',
);
},
'`monitor mono-repo-project with lockfiles --all-projects --json`': (
params,
utils,
Expand Down
31 changes: 31 additions & 0 deletions test/acceptance/cli-test/cli-test.all-projects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,5 +440,36 @@ export const AllProjectsTests: AcceptanceTests = {
t.fail('expected to pass');
}
},
'`test composer-app --all-projects`': (params, utils) => async (t) => {
utils.chdirWorkspaces();
const spyPlugin = sinon.spy(params.plugins, 'loadPlugin');
t.teardown(spyPlugin.restore);

const result = await params.cli.test('composer-app', {
allProjects: true,
});

t.ok(spyPlugin.withArgs('composer').calledOnce, 'calls composer plugin');

params.server.popRequests(2).forEach((req) => {
t.equal(req.method, 'POST', 'makes POST request');
t.equal(
req.headers['x-snyk-cli-version'],
params.versionNumber,
'sends version number',
);
t.match(req.url, '/api/v1/test', 'posts to correct url');
});
t.match(
result,
'Package manager: composer',
'contains package manager composer',
);
t.match(
result,
'Target file: composer.lock',
'contains target file composer.lock',
);
},
},
};

0 comments on commit 96de91d

Please sign in to comment.