Skip to content

DeepTeam is a framework to red team LLMs and AI agents.

tests added

A-Vamshi68b04795b3b0
diff --git a/tests/test_core/test_attacks/test_context_flooding.py b/tests/test_core/test_attacks/test_context_flooding.py
new file mode 100644
index 00000000..7427d327
--- /dev/null
+++ b/tests/test_core/test_attacks/test_context_flooding.py
@@ -0,0 +1,40 @@
+import pytest
+from deepteam.attacks.single_turn import ContextFlooding
+
+
+class TestContextFlooding:
+
+ def test_context_flooding_initialization(self):
+ attack = ContextFlooding()
+ assert attack.weight == 1
+ assert attack.get_name() == "ContextFlooding"
+
+ def test_context_flooding_initialization_with_weight(self):
+ attack = ContextFlooding(weight=5)
+ assert attack.weight == 5
+ assert attack.get_name() == "ContextFlooding"
+
+ def test_context_flooding_enhance(self):
+ attack = ContextFlooding()
+ original_text = "Hello, world!"
+ enhanced = attack.enhance(original_text)
+ assert len(enhanced) > (4000 + len(original_text) // 4)
+
+ def test_context_flooding_enhance_special_characters(self):
+ attack = ContextFlooding()
+ original_text = "!@#$%^&*()_+"
+ enhanced = attack.enhance(original_text)
+ assert len(enhanced) > (4000 + len(original_text) // 4)
+
+ def test_context_flooding_enhance_unicode(self):
+ attack = ContextFlooding()
+ original_text = "Hello 世界 🌍"
+ enhanced = attack.enhance(original_text)
+ assert len(enhanced) > (4000 + len(original_text) // 4)
+
+ def test_context_flooding_enhance_with_prefix(self):
+ attack = ContextFlooding(prefix="This is a test" * 10)
+ original_text = "Hello 世界 🌍"
+ enhanced = attack.enhance(original_text)
+ assert len(enhanced) > (4000 + len(original_text) // 4)
+ assert "This is a test" in enhanced
diff --git a/tests/test_core/test_attacks/test_embedded_instruction_json.py b/tests/test_core/test_attacks/test_embedded_instruction_json.py
new file mode 100644
index 00000000..4b7e4bd0
--- /dev/null
+++ b/tests/test_core/test_attacks/test_embedded_instruction_json.py
@@ -0,0 +1,33 @@
+import pytest
+from deepteam.attacks.single_turn import EmbeddedInstructionJSON
+
+
+class TestEmbeddedInstructionJSON:
+
+ def test_embedded_instruction_json_initialization(self):
+ attack = EmbeddedInstructionJSON()
+ assert attack.weight == 1
+ assert attack.get_name() == "EmbeddedInstructionJSON"
+
+ def test_embedded_instruction_json_initialization_with_weight(self):
+ attack = EmbeddedInstructionJSON(weight=5)
+ assert attack.weight == 5
+ assert attack.get_name() == "EmbeddedInstructionJSON"
+
+ def test_embedded_instruction_json_enhance(self):
+ attack = EmbeddedInstructionJSON()
+ original_text = "Hello, world!"
+ enhanced = attack.enhance(original_text)
+ assert len(enhanced) > (2000 + len(original_text) // 4)
+
+ def test_embedded_instruction_json_enhance_special_characters(self):
+ attack = EmbeddedInstructionJSON()
+ original_text = "!@#$%^&*()_+"
+ enhanced = attack.enhance(original_text)
+ assert len(enhanced) > (2000 + len(original_text) // 4)
+
+ def test_embedded_instruction_json_enhance_unicode(self):
+ attack = EmbeddedInstructionJSON()
+ original_text = "Hello 世界 🌍"
+ enhanced = attack.enhance(original_text)
+ assert len(enhanced) > (2000 + len(original_text) // 4)