All files / realm/blong-party/browser/test/test testAclMatrix.ts

100% Statements 46/46
100% Branches 2/2
100% Functions 1/1
100% Lines 46/46

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 471x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 10x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 10x 10x  
import {handler} from '@feasibleone/blong';
import {featureToSteps} from '@feasibleone/blong-cucumber';
 
import aclMatrixFeature from '../feature/aclMatrix.ts';
import {ACL_TARGET_CONSENTS, ACL_TARGET_PERSONS, ACL_TARGET_RULES} from './aclMatrix.ts';
 
/**
 * Browser-side (HTTP) ACL matrix flow — group `test.acl.matrix`.
 *
 * The feature file is the matrix: its Background asserts the fixture the matrix
 * is built from (the chart, the users, the grants and the rules), and its
 * scenarios are the outcome tables — the guarded reads of `party.person`, then
 * the same rules read back from the unguarded `access.acl`.  The steps come from
 * the shared factories (see `aclSteps.ts`) — the matrix probes through the real
 * gateway (see the `aclMatrix` library for why the probe cannot run in-process)
 * and asserts once, printing the redrawn tables on failure.
 */
export default handler(({lib: {group, aclFixture, aclMatrix, aclFixtureStep, aclMatrixStep}}) => ({
    testAclMatrix: ({name = 'acl matrix'}: {name?: string} = {}) =>
        featureToSteps(
            aclMatrixFeature,
            {
                'the ACL org chart is': aclFixtureStep(aclFixture, 'the ACL org chart'),
                'the ACL users are': aclFixtureStep(aclFixture, 'the ACL users'),
                'the ACL grants are': aclFixtureStep(aclFixture, 'the ACL grants'),
                'the ACL rules are': aclFixtureStep(aclFixture, 'the ACL rules'),
                'the ACL consents are': aclFixtureStep(aclFixture, 'the ACL consents'),
                'the party.person.get access matrix is': aclMatrixStep(
                    aclMatrix,
                    ACL_TARGET_PERSONS,
                    'party.person.get',
                ),
                'the party.consent.get access matrix is': aclMatrixStep(
                    aclMatrix,
                    ACL_TARGET_CONSENTS,
                    'party.consent.get',
                ),
                'the access.acl.get access matrix is': aclMatrixStep(
                    aclMatrix,
                    ACL_TARGET_RULES,
                    'access.acl.get',
                ),
            },
            {name, group},
        ),
}));