60 / 70 · 07 Security Testing for AI Apps · AI Regulation and Compliance Testing← prev⊞ allnext →☰ Read as one page
10.5NIST AI Risk Management Framework Tests
class TestNISTAIRMF:
"""Tests aligned with NIST AI Risk Management Framework (AI 100-1)."""
def test_valid_reliable_resilient(self, ai_system):
"""NIST MAP/MEASURE: AI system is valid, reliable, and resilient."""
input_data = {"query": "What is the refund policy?"}
responses = [ai_system.query(input_data) for _ in range(10)]
# All responses should convey the same core information
key_facts = ["30 days", "refund", "receipt"]
for response in responses:
facts_present = sum(
1 for fact in key_facts if fact.lower() in response.lower()
)
assert facts_present >= 2, f"Inconsistent response: {response[:100]}"
def test_safe_and_secure(self, ai_system):
"""NIST MANAGE: AI system operates safely and securely."""
result = ai_system.query({"query": None}) # invalid input
assert result is not None # should not crash
assert "error" in result.lower() or "please provide" in result.lower()
def test_explainable_and_interpretable(self, ai_system):
"""NIST GOVERN: AI decisions are explainable."""
result = ai_system.make_decision({"applicant_id": "test_789"})
assert result.explanation is not None
assert len(result.explanation) > 20 # substantive explanation
assert result.contributing_factors is not None
assert len(result.contributing_factors) >= 1