Skip to content

Commit

Permalink
feat: auto detect composer.lock
Browse files Browse the repository at this point in the history
  • Loading branch information
aryehbeitz authored and Anton Drukh committed Dec 21, 2017
1 parent 7b9345b commit 2334a61
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var DETECTABLE_FILES = [
'obj/project.assets.json',
'project.assets.json',
/\.csproj$/,
'composer.lock',
];

// when file is specified with --file, we look it up here
Expand Down
42 changes: 42 additions & 0 deletions test/acceptance/cli.acceptance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,48 @@ function (t) {
});
});

test('`test composer-app` auto-detects composer.lock', function (t) {
chdirWorkspaces();
return cli.test('composer-app')
.then(function () {
var req = server.popRequest();
t.equal(req.method, 'POST', 'makes POST request');
t.match(req.url, '/vuln/composer', 'posts to correct url');
t.equal(req.body.packageFormatVersion, 'composer:0.0.1', 'specifies package format');
});
});

test('`test composer-app auto-detects composer`',
function (t) {
chdirWorkspaces();
var plugin = {
inspect: function () {
return Promise.resolve({package: {}});
},
};
sinon.spy(plugin, 'inspect');

sinon.stub(plugins, 'loadPlugin');
t.teardown(plugins.loadPlugin.restore);
plugins.loadPlugin
.withArgs('composer')
.returns(plugin);

return cli.test('composer-app')
.then(function () {
var req = server.popRequest();
t.equal(req.method, 'POST', 'makes POST request');
t.match(req.url, '/vuln/composer', 'posts to correct url');
t.same(plugin.inspect.getCall(0).args,
['composer-app', 'composer.lock', {
args: null,
file: 'composer.lock',
packageManager: 'composer',
},], 'calls composer plugin');
});
});


test('`test --policy-path`', function (t) {
t.plan(3);

Expand Down

0 comments on commit 2334a61

Please sign in to comment.