Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

rot13.test.ts 1.2 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  1. import { addRot13 } from '../../../src/redteam/strategies/rot13';
  2. import type { TestCase } from '../../../src/types';
  3. describe('addRot13', () => {
  4. const mockTestCases: TestCase[] = [
  5. {
  6. vars: { query: 'Hello, world!' },
  7. assert: [{ type: 'equals', value: 'Expected output', metric: 'Harmful' }],
  8. },
  9. {
  10. vars: { userInput: 'Test input' },
  11. assert: [{ type: 'contains', value: 'test', metric: 'DebugAccess' }],
  12. },
  13. ];
  14. it('should encode the inject variable using ROT13', () => {
  15. const result = addRot13(mockTestCases, 'query');
  16. expect(result[0].vars?.query).toBe('Uryyb, jbeyq!');
  17. });
  18. it('should handle uppercase and lowercase letters', () => {
  19. const testCase: TestCase = {
  20. vars: { text: 'HELLO hello' },
  21. assert: [{ type: 'equals', value: 'Test', metric: 'Test' }],
  22. };
  23. const result = addRot13([testCase], 'text');
  24. expect(result[0].vars?.text).toBe('URYYB uryyb');
  25. });
  26. it('should not change non-alphabetic characters', () => {
  27. const testCase: TestCase = {
  28. vars: { text: 'Hello, World! 123' },
  29. assert: [{ type: 'equals', value: 'Test', metric: 'Test' }],
  30. };
  31. const result = addRot13([testCase], 'text');
  32. expect(result[0].vars?.text).toBe('Uryyb, Jbeyq! 123');
  33. });
  34. });
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...