import test from 'node:test'; import assert from 'node:assert/strict'; import { merchantScope } from '../dist/access.js'; import { hashPassword, verifyPassword } from '@merchantflow/database'; test('passwords use distinct salts and reject incorrect values', () => { const hash = hashPassword('example-password'); assert.notEqual(hash, hashPassword('example-password')); assert.equal(verifyPassword('example-password', hash), true); assert.equal(verifyPassword('wrong', hash), false); assert.equal(verifyPassword('wrong', 'broken'), false); }); test('every role receives its exact merchant scope', () => { assert.deepEqual(merchantScope({ role: 'HEAD_OF_SALES' }), {}); assert.deepEqual(merchantScope({ role: 'ACCOUNT_MANAGER', id: 'manager-1' }), { ownerId: 'manager-1', }); assert.deepEqual(merchantScope({ role: 'COMPLIANCE_OFFICER' }), {}); assert.deepEqual(merchantScope({ role: 'unexpected' }), { id: '__no_access__' }); });