DeepTeam is a framework to red team LLMs and AI agents.
updated old tests
A-Vamshi55763413164b
diff --git a/tests/test_core/test_attacks/test_all.py b/tests/test_core/test_attacks/test_all.pyindex 33f15d63..f4e15d29 100644--- a/tests/test_core/test_attacks/test_all.py+++ b/tests/test_core/test_attacks/test_all.py@@ -46,6 +46,7 @@ def test_red_teaming():attacks=attacks,attacks_per_vulnerability_type=1,max_concurrent=20,+ ignore_errors=False)# assert len(risk_assessment.test_cases) > len(vulnerabilities) * len(attacks)assert risk_assessment is not Nonediff --git a/tests/test_core/test_model_callback.py b/tests/test_core/test_model_callback.pyindex d810d29b..43704eed 100644--- a/tests/test_core/test_model_callback.py+++ b/tests/test_core/test_model_callback.py@@ -1,12 +1,25 @@import pytestimport inspectimport asyncio-from deepteam.red_teamer.utils import resolve_model_callback+from pydantic import ValidationError+from deepteam.test_case import RTTurn+from deepteam.red_teamer.utils import resolve_model_callback, wrap_model_callbackfrom deepeval.models import GPTModelfrom deepteam.vulnerabilities import Bias-from deepteam.attacks.single_turn import Roleplayfrom deepteam import red_team+def custom_model_callback(input: str, turns=None):+ return f"Cannot respond to {input}"++async def custom_async_model_callback(input: str, turns=None):+ return f"Cannot respond to {input}"++def custom_invalid_model_callback(input: str, turns=None):+ return {"res": f"Cannot respond to {input}"}++async def custom_invalid_async_model_callback(input: str, turns=None):+ return {"res": f"Cannot respond to {input}"}+class TestModelCallbackVariations:@@ -34,13 +47,39 @@ class TestModelCallbackVariations:assert inspect.iscoroutinefunction(model_callback)assert asyncio.run(model_callback("Hello")) is not None+ def test_sync_wrapper_returns_valid_model_callback(self):+ model_callback = wrap_model_callback(custom_model_callback, False)+ response = model_callback("Hello this is a test")++ assert inspect.iscoroutinefunction(model_callback) is False+ assert isinstance(response, RTTurn)+ assert response.role == "assistant"++ def test_async_wrapper_returns_valid_model_callback(self):+ model_callback = wrap_model_callback(custom_async_model_callback, True)+ response = asyncio.run(model_callback("Hello this is a test"))++ assert inspect.iscoroutinefunction(model_callback) is True+ assert isinstance(response, RTTurn)+ assert response.role == "assistant"++ def test_sync_wrapper_raises_error_for_invalid_response(self):+ model_callback = wrap_model_callback(custom_invalid_model_callback, False)+ with pytest.raises(ValidationError):+ model_callback("Hello this is a test")++ def test_async_wrapper_raises_error_for_invalid_response(self):+ model_callback = wrap_model_callback(custom_invalid_async_model_callback, True)+ with pytest.raises(ValidationError):+ asyncio.run(model_callback("Hello this is a test"))+def test_simple_red_teaming_async(self):OPENAI_MODEL = "openai/gpt-4.1"risk_assessment = red_team(model_callback=OPENAI_MODEL,- attacks=[Roleplay()],vulnerabilities=[Bias(types=["gender"])],async_mode=True,+ ignore_errors=False)assert risk_assessment is not None@@ -48,8 +87,8 @@ class TestModelCallbackVariations:OPENAI_MODEL = "openai/gpt-4.1"risk_assessment = red_team(model_callback=OPENAI_MODEL,- attacks=[Roleplay()],vulnerabilities=[Bias(types=["gender"])],async_mode=False,+ ignore_errors=False)assert risk_assessment is not Nonediff --git a/tests/test_core/test_red_teaming.py b/tests/test_core/test_red_teaming.pyindex c0a0d552..78a8c998 100644--- a/tests/test_core/test_red_teaming.py+++ b/tests/test_core/test_red_teaming.py@@ -74,6 +74,7 @@ def test_red_teaming():attacks=attacks,attacks_per_vulnerability_type=1,max_concurrent=20,+ ignore_errors=False)assert risk_assessment is not Noneassert len(risk_assessment.test_cases) > len(vulnerabilities) * len(attacks)diff --git a/tests/test_core/test_vulnerabilities/test_all.py b/tests/test_core/test_vulnerabilities/test_all.pyindex 3ac3ad23..713d5eb1 100644--- a/tests/test_core/test_vulnerabilities/test_all.py+++ b/tests/test_core/test_vulnerabilities/test_all.py@@ -37,6 +37,8 @@ def test_red_teaming():Competition(),GraphicContent(),PersonalSafety(),+ CrossContextRetrieval(),+ SystemReconnaissance(),# Agentic vulnerabilitiesGoalTheft(),RecursiveHijacking(),@@ -49,6 +51,8 @@ def test_red_teaming():UnexpectedCodeExecution(),InsecureInterAgentCommunication(),AutonomousAgentDrift(),+ ExploitToolAgent(),+ ExternalSystemAbuse(),custom_vulnerability,]@@ -60,6 +64,7 @@ def test_red_teaming():attacks=attacks,attacks_per_vulnerability_type=1,max_concurrent=20,+ ignore_errors=False)assert risk_assessment is not Noneassert len(risk_assessment.test_cases) > len(vulnerabilities) * len(attacks)diff --git a/tests/test_frameworks/test_aegis.py b/tests/test_frameworks/test_aegis.pyindex cfc04d91..c5693411 100644--- a/tests/test_frameworks/test_aegis.py+++ b/tests/test_frameworks/test_aegis.py@@ -35,7 +35,7 @@ class TestAegis:model_callback=mock_model_callback,framework=Aegis(num_attacks=5),async_mode=False,- ignore_errors=True,+ ignore_errors=False,)assert risk_assessment is not None@@ -53,7 +53,7 @@ class TestAegis:model_callback=mock_async_model_callback,framework=Aegis(num_attacks=5),async_mode=True,- ignore_errors=True,+ ignore_errors=False,)assert risk_assessment is not Nonediff --git a/tests/test_frameworks/test_beavertails.py b/tests/test_frameworks/test_beavertails.pyindex 55192aad..4b21c11c 100644--- a/tests/test_frameworks/test_beavertails.py+++ b/tests/test_frameworks/test_beavertails.py@@ -35,7 +35,7 @@ class TestBeaverTails:model_callback=mock_model_callback,framework=BeaverTails(num_attacks=5),async_mode=False,- ignore_errors=True,+ ignore_errors=False,)assert risk_assessment is not None@@ -53,7 +53,7 @@ class TestBeaverTails:model_callback=mock_async_model_callback,framework=BeaverTails(num_attacks=5),async_mode=True,- ignore_errors=True,+ ignore_errors=False,)assert risk_assessment is not Nonediff --git a/tests/test_frameworks/test_mitre.py b/tests/test_frameworks/test_mitre.pyindex 281bb1aa..41e74ebc 100644--- a/tests/test_frameworks/test_mitre.py+++ b/tests/test_frameworks/test_mitre.py@@ -180,7 +180,7 @@ class TestMITRE:model_callback=mock_model_callback,framework=MITRE(categories=[random_category]),async_mode=False,- ignore_errors=True,+ ignore_errors=False,)assert isinstance(risk_assessment, RiskAssessment)assert risk_assessment is not Nonediff --git a/tests/test_frameworks/test_nist.py b/tests/test_frameworks/test_nist.pyindex c7cb3dfe..67a4998f 100644--- a/tests/test_frameworks/test_nist.py+++ b/tests/test_frameworks/test_nist.py@@ -188,7 +188,7 @@ class TestNIST:model_callback=mock_model_callback,framework=NIST(categories=[random_category]),async_mode=False,- ignore_errors=True,+ ignore_errors=False,)assert isinstance(risk_assessment, RiskAssessment)diff --git a/tests/test_frameworks/test_owasp_top_10.py b/tests/test_frameworks/test_owasp_top_10.pyindex fdc82df5..4e3421b1 100644--- a/tests/test_frameworks/test_owasp_top_10.py+++ b/tests/test_frameworks/test_owasp_top_10.py@@ -209,7 +209,7 @@ class TestOWASP:model_callback=mock_model_callback,framework=OWASPTop10(categories=[random_category]),async_mode=False,- ignore_errors=True,+ ignore_errors=False,)assert isinstance(risk_assessment, RiskAssessment)diff --git a/tests/test_frameworks/test_owasp_top_10_asi.py b/tests/test_frameworks/test_owasp_top_10_asi.pyindex df11f492..b2c50a37 100644--- a/tests/test_frameworks/test_owasp_top_10_asi.py+++ b/tests/test_frameworks/test_owasp_top_10_asi.py@@ -211,7 +211,7 @@ class TestOWASP:model_callback=mock_model_callback,framework=OWASP_ASI_2026(categories=[random_category]),async_mode=False,- ignore_errors=True,+ ignore_errors=False,)assert isinstance(risk_assessment, RiskAssessment)