/** * Property-Based Tests: Config Wizard Sensitive Value Masking * * Feature: config-wizard * * Tests the maskSensitive display function from `configure.js`. * * Validates: Requirements 3.4 */ const fc = require('fast-check'); const { maskSensitive } = require('../../configure.js'); // --- Property 4: Sensitive value masking --- describe('Property 4: Sensitive value masking', () => { /** * **Validates: Requirements 3.4** * * For any string value longer than 8 characters, maskSensitive returns * first4 + '****' + last4. For any string value of 8 characters or fewer, * maskSensitive returns the full value unchanged. */ test('strings longer than 8 chars are masked as first4 + **** + last4', () => { fc.assert( fc.property( fc.string({ minLength: 9, maxLength: 200 }), (value) => { const result = maskSensitive('ANY_NAME', value); const expected = value.slice(0, 4) + '****' + value.slice(-4); return result === expected; } ), { numRuns: 100 } ); }); test('strings of 8 chars or fewer are returned unchanged', () => { fc.assert( fc.property( fc.string({ minLength: 0, maxLength: 8 }), (value) => { const result = maskSensitive('ANY_NAME', value); return result === value; } ), { numRuns: 100 } ); }); test('masking behavior is independent of the variable name parameter', () => { fc.assert( fc.property( fc.string({ minLength: 9, maxLength: 100 }), fc.string({ minLength: 1, maxLength: 50 }), (value, name) => { const result = maskSensitive(name, value); const expected = value.slice(0, 4) + '****' + value.slice(-4); return result === expected; } ), { numRuns: 100 } ); }); });