Skip to main content
Glama
pii-scrubber.test.ts1.5 kB
import { describe, it, expect } from '@jest/globals'; import { scrubPII, applyRedaction, RedactionLevel, containsPII, assertNoPII } from '../../src/utils/pii-scrubber'; describe('PII Scrubber', () => { it('should redact emails inside strings', () => { const result = scrubPII('alice@example.com'); expect(typeof result).toBe('string'); expect((result as string).toLowerCase()).toContain('[redacted]'); }); it('should redact known object fields', () => { const input = { email: 'bob@domain.com', name: 'Bob', telefoonnummer: '0612345678' }; const out = scrubPII(input) as Record<string, unknown>; expect(out.email).toBe('[REDACTED]'); expect(out.name).toBe('[REDACTED]'); expect(out.telefoonnummer).toBe('[REDACTED]'); }); it('applyRedaction FULL should redact sensitive values', () => { const input = { email: 'x@y.com', inkomen_aanvrager: 55000 }; const out = applyRedaction(input, RedactionLevel.FULL) as Record<string, unknown>; expect(out.email).toBe('[REDACTED]'); // Under FULL redaction numeric PII fields are also redacted expect(out.inkomen_aanvrager).toBe('[REDACTED]'); }); it('containsPII should detect email-like strings', () => { expect(containsPII('contact: user@test.nl')).toBe(true); expect(containsPII('no pii here')).toBe(false); }); it('assertNoPII should throw when message contains PII', () => { expect(() => assertNoPII('this is bad: alice@example.com')).toThrow(); }); });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pace8/Test'

If you have feedback or need assistance with the MCP directory API, please join our Discord server