{"_id":"@dudousxd/nestjs-authz-testing","name":"@dudousxd/nestjs-authz-testing","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@dudousxd/nestjs-authz-testing","version":"0.1.0","description":"Test helpers for @dudousxd/nestjs-authz — build a Gate/BoundGate from fixture users & policies and assert with expectCan/expectCannot.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/DavideCarvalho/nestjs-authz.git","directory":"packages/testing"},"author":{"name":"Davi Carvalho","email":"davi@goflip.ai"},"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"}},"peerDependencies":{"@dudousxd/nestjs-authz":">=0.5.0","reflect-metadata":">=0.1.13"},"devDependencies":{"@types/node":"^20.0.0","reflect-metadata":"^0.2.2","typescript":"^5.4.0","vitest":"^3.0.0","@dudousxd/nestjs-authz":"^0.6.0"},"engines":{"node":">=20"},"keywords":["nestjs","authorization","authz","testing","gate","policy","fixtures"],"scripts":{"build":"tsc -p tsconfig.json","test":"vitest run --passWithNoTests","test:watch":"vitest","typecheck":"tsc -p tsconfig.json --noEmit"},"_id":"@dudousxd/nestjs-authz-testing@0.1.0","bugs":{"url":"https://github.com/DavideCarvalho/nestjs-authz/issues"},"homepage":"https://github.com/DavideCarvalho/nestjs-authz#readme","_integrity":"sha512-1doAAcFCaMXA1yahRRNIZvoLdxAB+FhYBQPlLQjyfkU3tTaL6XcLl2u5KL9UEQbm/M7IQMdTNvxal2roilEfWg==","_resolved":"/tmp/b103502faceaf9e9237e80a1886ea806/dudousxd-nestjs-authz-testing-0.1.0.tgz","_from":"file:dudousxd-nestjs-authz-testing-0.1.0.tgz","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-1doAAcFCaMXA1yahRRNIZvoLdxAB+FhYBQPlLQjyfkU3tTaL6XcLl2u5KL9UEQbm/M7IQMdTNvxal2roilEfWg==","shasum":"7588f43a0110e0e2885afff7fb60fda036bec88b","tarball":"https://registry.npmjs.org/@dudousxd/nestjs-authz-testing/-/nestjs-authz-testing-0.1.0.tgz","fileCount":11,"unpackedSize":24059,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@dudousxd%2fnestjs-authz-testing@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQC46+BWlqEnZ67+DBIQ2W5ZbQ7Q4QqNSN7mu1EwByLZvAIhAPrFVKBOOUO7E49bJPtbTCONVmdue0s/iaUNq24bvAHX"}]},"_npmUser":{"name":"dudousxd","email":"davi_carvalho96@hotmail.com"},"directories":{},"maintainers":[{"name":"dudousxd","email":"davi_carvalho96@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nestjs-authz-testing_0.1.0_1781797246440_0.6900291924841941"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-18T15:40:46.244Z","0.1.0":"2026-06-18T15:40:46.575Z","modified":"2026-06-18T15:40:46.987Z"},"maintainers":[{"name":"dudousxd","email":"davi_carvalho96@hotmail.com"}],"description":"Test helpers for @dudousxd/nestjs-authz — build a Gate/BoundGate from fixture users & policies and assert with expectCan/expectCannot.","homepage":"https://github.com/DavideCarvalho/nestjs-authz#readme","keywords":["nestjs","authorization","authz","testing","gate","policy","fixtures"],"repository":{"type":"git","url":"git+https://github.com/DavideCarvalho/nestjs-authz.git","directory":"packages/testing"},"author":{"name":"Davi Carvalho","email":"davi@goflip.ai"},"bugs":{"url":"https://github.com/DavideCarvalho/nestjs-authz/issues"},"license":"MIT","readme":"# `@dudousxd/nestjs-authz-testing`\n\nTest helpers for [`@dudousxd/nestjs-authz`](../core). Build a real `Gate`/`BoundGate`\nfrom fixture users, policies, gates, and an in-memory permission/role provider — no\nNest module, no database — then assert verdicts with `expectCan` / `expectCannot`.\n\n```ts\nimport 'reflect-metadata';\nimport { Policy } from '@dudousxd/nestjs-authz';\nimport { buildGate, expectCan, expectCannot, FakePermissionProvider } from '@dudousxd/nestjs-authz-testing';\n\n@Policy(Post)\nclass PostPolicy {\n  update(user, post) { return user?.id === post.authorId; }\n}\n\nconst gate = buildGate({ policies: [new PostPolicy()] });\nawait expectCan(gate, { id: 1 }, 'update', new Post(10, 1));\nawait expectCannot(gate, { id: 2 }, 'update', new Post(10, 1));\n\n// RBAC seam, zero DB — wildcard grants work via the core matcher:\nconst gate2 = buildGate({ permissionProvider: new FakePermissionProvider({ '1': ['posts.*'] }) });\nawait expectCan(gate2, { id: 1 }, 'posts.update');\n```\n\n## API\n\n- `buildGate(options?)` → `Gate` from `{ policies, gates, superAdmin, after, resolveRoles, permissionProvider, roleProvider }`.\n- `buildBoundGate(user, options?)` → `BoundGate` bound to a fixture user.\n- `expectCan(gate, user, ability, resource?)` / `expectCannot(...)` — assert the verdict\n  (accept a `Gate` + user, or a `BoundGate` with `undefined` user). `expectCannot`\n  treats an unresolved ability as \"cannot\".\n- `FakePermissionProvider` / `FakeRoleProvider` — in-memory RBAC seams keyed by user id.\n- `AuthzAssertionError` — thrown on assertion failure.\n","readmeFilename":"README.md","_rev":"1-9d8e1cf425cb454660c5f31a2dcedd38"}