ace-ai
Version:
ACE SDK for generating synthetic data and ensuring security and compliance with PII and HIPAA regulations. Includes MCP server protection.
102 lines (88 loc) • 3.25 kB
JavaScript
const { expect } = require('chai');
const { Client } = require('../index');
describe('ACE SDK Client', function() {
let client;
beforeEach(function() {
client = new Client();
});
describe('generateSyntheticData', function() {
it('should generate an empty object when no schema is provided', function() {
const data = client.generateSyntheticData({});
expect(data).to.be.an('object');
});
it('should generate synthetic data based on a schema', function() {
const schema = {
name: 'name',
email: 'email',
age: 'number'
};
const data = client.generateSyntheticData(schema);
expect(data).to.be.an('object');
expect(data.name).to.be.a('string');
expect(data.email).to.be.a('string');
expect(data.age).to.be.a('number');
});
});
describe('scanForSecrets', function() {
it('should return false when no secrets are found', function() {
const text = 'This is a test';
const hasSecrets = client.scanForSecrets(text);
expect(hasSecrets).to.be.false;
});
});
describe('containsPII', function() {
it('should return false when no PII is found', function() {
const text = 'This is a test';
const hasPII = client.containsPII(text);
expect(hasPII).to.be.false;
});
});
describe('containsHIPAA', function() {
it('should return false when no HIPAA data is found', function() {
const text = 'This is a test';
const hasHIPAA = client.containsHIPAA(text);
expect(hasHIPAA).to.be.false;
});
});
describe('sanitizeText', function() {
it('should return the same text when no PII or HIPAA data is found', function() {
const text = 'This is a test';
const sanitizedText = client.sanitizeText(text);
expect(sanitizedText).to.equal(text);
});
});
describe('protectMCPHost', function() {
it('should return false for invalid request', function() {
const result = client.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 = client.protectMCPHost(request);
expect(result).to.be.true;
});
});
describe('validateDataBeforeLLM', function() {
it('should return error for invalid data', function() {
const result = client.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 = client.validateDataBeforeLLM(data);
expect(result.isValid).to.be.true;
expect(result.sanitizedData).to.equal(data);
});
});
describe('ensureUSDataResidency', function() {
it('should return true for no data', function() {
const result = client.ensureUSDataResidency(null, 'US');
expect(result).to.be.true;
});
it('should return true for non-HIPAA data to any destination', function() {
const result = client.ensureUSDataResidency('normal data', 'CA');
expect(result).to.be.true;
});
});
});