Skip to content

Commit

Permalink
test(compartment-mapper): check for resistance to bundled dependency …
Browse files Browse the repository at this point in the history
…name collision
  • Loading branch information
naugtur committed Jan 15, 2024
1 parent 1ff3c4b commit 27e2382
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 3 deletions.

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

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

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

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

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

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

53 changes: 53 additions & 0 deletions packages/compartment-mapper/test/test-policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const fixtureAttack = new URL(
'fixtures-policy/node_modules/app/attack.js',
import.meta.url,
).toString();
const nameConfusionAttack = new URL(
'fixtures-policy/node_modules/app/attack-name.js',
import.meta.url,
).toString();

const globals = {
redPill: 42,
Expand Down Expand Up @@ -84,6 +88,15 @@ const anyPolicy = {
'alice>carol': ANY,
},
};
const evePolicy = {
entry: { ...policy.entry, packages: 'any' },
resources: {
...policy.resources,
eve: {
packages: 'any',
},
},
};

const defaultExpectations = {
namespace: {
Expand All @@ -110,6 +123,34 @@ const anyExpectations = {
carol: { bluePill: 'number', redPill: 'number', purplePill: 'number' },
},
};
const nameConfusionExpectations = {
namespace: {
alice: {
bluePill: 'undefined',
purplePill: 'undefined',
redPill: 'number',
},
bob: {
bluePill: 'number',
purplePill: 'undefined',
redPill: 'undefined',
},
carol: {
bluePill: 'undefined',
purplePill: 'number',
redPill: 'undefined',
},
evilCarol: {
bluePill: 'undefined',
purplePill: 'undefined',
redPill: 'undefined',
},
scopedBob: {
scoped: 1,
},
},
};

const powerlessCarolExpectations = {
namespace: {
...defaultExpectations.namespace,
Expand Down Expand Up @@ -225,6 +266,18 @@ scaffold(
},
);

scaffold(
'policy - attack - duplicated name via bundled dep',
test.only,
nameConfusionAttack,
makeResultAssertions(nameConfusionExpectations),
1, // expected number of assertions
{
addGlobals: globals,
policy: evePolicy,
},
);

const recursiveEdit = editor => originalPolicy => {
const policyToAlter = JSON.parse(JSON.stringify(originalPolicy));
const recur = obj => {
Expand Down

0 comments on commit 27e2382

Please sign in to comment.