Skip to content

Commit

Permalink
test: gradle --all-sub-projects policy is not applying
Browse files Browse the repository at this point in the history
Also fix some formatting
  • Loading branch information
lili2311 committed Jun 23, 2020
1 parent e75db65 commit 9f50581
Show file tree
Hide file tree
Showing 8 changed files with 925 additions and 814 deletions.
4 changes: 3 additions & 1 deletion src/lib/policy/find-and-load-policy.ts
Expand Up @@ -19,7 +19,9 @@ export async function findAndLoadPolicy(
const isDocker = scanType === 'docker';
const isNodeProject = ['npm', 'yarn'].includes(scanType);
// monitor
let policyLocations: string[] = [options['policy-path'] || scannedProjectFolder || root];
let policyLocations: string[] = [
options['policy-path'] || scannedProjectFolder || root,
];
if (isDocker) {
policyLocations = policyLocations.filter((loc) => loc !== root);
} else if (isNodeProject) {
Expand Down
44 changes: 22 additions & 22 deletions test/acceptance/cli-monitor/cli-monitor.all-projects.spec.ts
Expand Up @@ -17,31 +17,31 @@ export const AllProjectsTests: AcceptanceTests = {
utils,
) => async (t) => {
utils.chdirWorkspaces();
await params.cli.monitor('mono-repo-with-ignores ', {
await params.cli.monitor('mono-repo-with-ignores', {
allProjects: true,
detectionDepth: 1,
detectionDepth: 2,
});

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/monitor', 'posts to correct url');
t.ok(req.body.depGraph, 'body contains depGraph');
t.match(
req.body.policy,
'npm:node-uuid:20160328',
'body contains policy',
);
t.match(
req.body.depGraph.pkgManager.name,
/(npm)/,
'depGraph has package manager',
);
// Pop all calls to server and filter out calls to `featureFlag` endpoint
const requests = params.server
.popRequests(4)
.filter((req) => req.url.includes('/monitor/'));
let policyCount = 0;
requests.forEach((req) => {
const vulnerableFolderPath =
process.platform === 'win32'
? 'vulnerable\\package-lock.json'
: 'vulnerable/package-lock.json';

if (req.body.targetFileRelativePath.endsWith(vulnerableFolderPath)) {
t.match(
req.body.policy,
'npm:node-uuid:20160328',
'body contains policy',
);
policyCount += 1;
}
});
t.equal(policyCount, 1, 'one policy found');
},
'`monitor mono-repo-project --all-projects --detection-depth=1`': (
params,
Expand Down

0 comments on commit 9f50581

Please sign in to comment.