"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const redactor_1 = require("../walls/06-memory/privacy/redactor");
describe('Redactor — secret redaction', () => {
    it('redacts API keys', () => {
        const input = 'api_key=sk_test_abcdef1234567890abcdef12';
        const result = (0, redactor_1.redactSecrets)(input);
        expect(result.redacted).toBeGreaterThanOrEqual(1);
        expect(result.content).toContain('<REDACTED>');
        expect(result.secrets).toContain('API_KEY');
    });
    it('redacts tokens', () => {
        const input = 'token=eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U';
        const result = (0, redactor_1.redactSecrets)(input);
        expect(result.redacted).toBeGreaterThanOrEqual(1);
    });
    it('redacts passwords', () => {
        const input = 'password=supersecret123';
        const result = (0, redactor_1.redactSecrets)(input);
        expect(result.redacted).toBeGreaterThanOrEqual(1);
        expect(result.secrets).toContain('PASSWORD');
    });
    it('redacts private keys', () => {
        const input = '-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEA...\n-----END RSA PRIVATE KEY-----';
        const result = (0, redactor_1.redactSecrets)(input);
        expect(result.redacted).toBeGreaterThanOrEqual(1);
        expect(result.content).toContain('<PRIVATE_KEY_REDACTED>');
    });
    it('redacts JWT tokens', () => {
        const input = 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U';
        const result = (0, redactor_1.redactSecrets)(input);
        expect(result.redacted).toBeGreaterThanOrEqual(1);
        expect(result.content).toContain('<JWT_REDACTED>');
    });
    it('redacts AWS keys', () => {
        const input = 'AKIAIOSFODNN7EXAMPLE';
        const result = (0, redactor_1.redactSecrets)(input);
        expect(result.redacted).toBe(1);
        expect(result.content).toContain('<AWS_KEY_REDACTED>');
    });
    it('redacts GitHub tokens', () => {
        const input = 'ghp_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghij';
        const result = (0, redactor_1.redactSecrets)(input);
        expect(result.redacted).toBe(1);
        expect(result.content).toContain('<GITHUB_TOKEN_REDACTED>');
    });
    it('redacts connection strings', () => {
        const input = 'mongodb://user:pass@host:27017/db';
        const result = (0, redactor_1.redactSecrets)(input);
        expect(result.redacted).toBe(1);
        expect(result.content).toContain('<CONNECTION_STRING_REDACTED>');
    });
    it('does not redact normal text', () => {
        const input = 'This is a normal sentence about redacting secrets.';
        const result = (0, redactor_1.redactSecrets)(input);
        expect(result.redacted).toBe(0);
        expect(result.content).toBe(input);
    });
    it('redacts multiple secrets in one string', () => {
        const input = 'api_key=abcdef1234567890abcdef12 password=secret12345678';
        const result = (0, redactor_1.redactSecrets)(input);
        expect(result.redacted).toBeGreaterThanOrEqual(2);
    });
});
describe('isEnvFile', () => {
    it('detects .env', () => {
        expect((0, redactor_1.isEnvFile)('.env')).toBe(true);
    });
    it('detects .env.local', () => {
        expect((0, redactor_1.isEnvFile)('.env.local')).toBe(true);
    });
    it('detects .env.production', () => {
        expect((0, redactor_1.isEnvFile)('.env.production')).toBe(true);
    });
    it('rejects normal files', () => {
        expect((0, redactor_1.isEnvFile)('config.json')).toBe(false);
        expect((0, redactor_1.isEnvFile)('.gitignore')).toBe(false);
    });
});
describe('getSecretSummary', () => {
    it('returns array of secret names', () => {
        const summary = (0, redactor_1.getSecretSummary)();
        expect(Array.isArray(summary)).toBe(true);
        expect(summary.length).toBeGreaterThan(0);
        expect(summary[0]).toHaveProperty('name');
        expect(summary[0]).toHaveProperty('present');
    });
});
//# sourceMappingURL=redactor.test.js.map