UNPKG

ace-ai

Version:

ACE SDK for generating synthetic data and ensuring security and compliance with PII and HIPAA regulations. Includes MCP server protection.

74 lines (63 loc) 2.69 kB
const { expect } = require('chai'); const { protectMCPHost, validateDataBeforeLLM, ensureUSDataResidency } = require('../src/security/mcp-protection'); describe('MCP Protection', function() { describe('protectMCPHost', function() { it('should return false for invalid request', function() { const result = protectMCPHost(null); expect(result).to.be.false; }); it('should return true for valid request without sensitive data', function() { const request = { data: 'normal data' }; const result = protectMCPHost(request); expect(result).to.be.true; }); it('should return false for request with secrets', function() { const request = { data: 'api_key=secret123' }; const result = protectMCPHost(request); expect(result).to.be.false; }); it('should return false for request with PII', function() { const request = { data: 'John Doe, 123-45-6789' }; const result = protectMCPHost(request); expect(result).to.be.false; }); }); describe('validateDataBeforeLLM', function() { it('should return error for invalid data', function() { const result = validateDataBeforeLLM(null); expect(result.isValid).to.be.false; expect(result.error).to.equal('Invalid data provided'); }); it('should return valid result for data without PII/HIPAA', function() { const data = 'normal text'; const result = validateDataBeforeLLM(data); expect(result.isValid).to.be.true; expect(result.sanitizedData).to.equal(data); }); it('should sanitize data with PII', function() { const data = 'Contact John Doe at john@example.com'; const result = validateDataBeforeLLM(data); expect(result.isValid).to.be.true; expect(result.sanitizedData).to.contain('[EMAIL REDACTED]'); expect(result.warning).to.exist; }); }); describe('ensureUSDataResidency', function() { it('should return true for no data', function() { const result = ensureUSDataResidency(null, 'US'); expect(result).to.be.true; }); it('should return true for non-HIPAA data to any destination', function() { const result = ensureUSDataResidency('normal data', 'CA'); expect(result).to.be.true; }); it('should return false for HIPAA data to non-US destination', function() { const result = ensureUSDataResidency('Patient John Doe, 123-45-6789', 'CA'); expect(result).to.be.false; }); it('should return true for HIPAA data to US destination', function() { const result = ensureUSDataResidency('Patient John Doe, 123-45-6789', 'US'); expect(result).to.be.true; }); }); });