More tests
This commit is contained in:
@@ -54,7 +54,7 @@ class CrossToolComprehensiveTest(BaseSimulatorTest):
|
|||||||
self.setup_test_files()
|
self.setup_test_files()
|
||||||
|
|
||||||
# Create short test files for quick testing
|
# Create short test files for quick testing
|
||||||
python_code = '''def login(user, pwd):
|
python_code = """def login(user, pwd):
|
||||||
# Security issue: plain text password
|
# Security issue: plain text password
|
||||||
if user == "admin" and pwd == "123":
|
if user == "admin" and pwd == "123":
|
||||||
return True
|
return True
|
||||||
@@ -63,7 +63,7 @@ class CrossToolComprehensiveTest(BaseSimulatorTest):
|
|||||||
def hash_pwd(pwd):
|
def hash_pwd(pwd):
|
||||||
# Weak hashing
|
# Weak hashing
|
||||||
return str(hash(pwd))
|
return str(hash(pwd))
|
||||||
'''
|
"""
|
||||||
|
|
||||||
config_file = """{
|
config_file = """{
|
||||||
"db_password": "weak123",
|
"db_password": "weak123",
|
||||||
@@ -90,7 +90,7 @@ def hash_pwd(pwd):
|
|||||||
chat_params = {
|
chat_params = {
|
||||||
"prompt": "Please give me a quick one line reply. I have an authentication module that needs review. Can you help me understand potential issues?",
|
"prompt": "Please give me a quick one line reply. I have an authentication module that needs review. Can you help me understand potential issues?",
|
||||||
"files": [auth_file],
|
"files": [auth_file],
|
||||||
"thinking_mode": "low"
|
"thinking_mode": "low",
|
||||||
}
|
}
|
||||||
|
|
||||||
response1, continuation_id1 = self.call_mcp_tool("chat", chat_params)
|
response1, continuation_id1 = self.call_mcp_tool("chat", chat_params)
|
||||||
@@ -107,7 +107,7 @@ def hash_pwd(pwd):
|
|||||||
analyze_params = {
|
analyze_params = {
|
||||||
"files": [auth_file],
|
"files": [auth_file],
|
||||||
"question": "Please give me a quick one line reply. What are the security vulnerabilities and architectural issues in this authentication code?",
|
"question": "Please give me a quick one line reply. What are the security vulnerabilities and architectural issues in this authentication code?",
|
||||||
"thinking_mode": "low"
|
"thinking_mode": "low",
|
||||||
}
|
}
|
||||||
|
|
||||||
response2, continuation_id2 = self.call_mcp_tool("analyze", analyze_params)
|
response2, continuation_id2 = self.call_mcp_tool("analyze", analyze_params)
|
||||||
@@ -126,7 +126,7 @@ def hash_pwd(pwd):
|
|||||||
"continuation_id": current_continuation_id,
|
"continuation_id": current_continuation_id,
|
||||||
"prompt": "Please give me a quick one line reply. I also have this configuration file. Can you analyze it alongside the authentication code?",
|
"prompt": "Please give me a quick one line reply. I also have this configuration file. Can you analyze it alongside the authentication code?",
|
||||||
"files": [auth_file, config_file_path], # Old + new file
|
"files": [auth_file, config_file_path], # Old + new file
|
||||||
"thinking_mode": "low"
|
"thinking_mode": "low",
|
||||||
}
|
}
|
||||||
|
|
||||||
response3, _ = self.call_mcp_tool("chat", chat_continue_params)
|
response3, _ = self.call_mcp_tool("chat", chat_continue_params)
|
||||||
@@ -142,7 +142,7 @@ def hash_pwd(pwd):
|
|||||||
debug_params = {
|
debug_params = {
|
||||||
"files": [auth_file, config_file_path],
|
"files": [auth_file, config_file_path],
|
||||||
"error_description": "Please give me a quick one line reply. The authentication system has security vulnerabilities. Help me identify and fix the main issues.",
|
"error_description": "Please give me a quick one line reply. The authentication system has security vulnerabilities. Help me identify and fix the main issues.",
|
||||||
"thinking_mode": "low"
|
"thinking_mode": "low",
|
||||||
}
|
}
|
||||||
|
|
||||||
response4, continuation_id4 = self.call_mcp_tool("debug", debug_params)
|
response4, continuation_id4 = self.call_mcp_tool("debug", debug_params)
|
||||||
@@ -162,7 +162,7 @@ def hash_pwd(pwd):
|
|||||||
"continuation_id": continuation_id4,
|
"continuation_id": continuation_id4,
|
||||||
"files": [auth_file, config_file_path],
|
"files": [auth_file, config_file_path],
|
||||||
"error_description": "Please give me a quick one line reply. What specific code changes would you recommend to fix the password hashing vulnerability?",
|
"error_description": "Please give me a quick one line reply. What specific code changes would you recommend to fix the password hashing vulnerability?",
|
||||||
"thinking_mode": "low"
|
"thinking_mode": "low",
|
||||||
}
|
}
|
||||||
|
|
||||||
response5, _ = self.call_mcp_tool("debug", debug_continue_params)
|
response5, _ = self.call_mcp_tool("debug", debug_continue_params)
|
||||||
@@ -175,7 +175,7 @@ def hash_pwd(pwd):
|
|||||||
codereview_params = {
|
codereview_params = {
|
||||||
"files": [auth_file, config_file_path],
|
"files": [auth_file, config_file_path],
|
||||||
"context": "Please give me a quick one line reply. Comprehensive security-focused code review for production readiness",
|
"context": "Please give me a quick one line reply. Comprehensive security-focused code review for production readiness",
|
||||||
"thinking_mode": "low"
|
"thinking_mode": "low",
|
||||||
}
|
}
|
||||||
|
|
||||||
response6, continuation_id6 = self.call_mcp_tool("codereview", codereview_params)
|
response6, continuation_id6 = self.call_mcp_tool("codereview", codereview_params)
|
||||||
@@ -192,7 +192,7 @@ def hash_pwd(pwd):
|
|||||||
self.logger.info(" Step 7: precommit tool - Pre-commit validation")
|
self.logger.info(" Step 7: precommit tool - Pre-commit validation")
|
||||||
|
|
||||||
# Create a short improved version
|
# Create a short improved version
|
||||||
improved_code = '''import hashlib
|
improved_code = """import hashlib
|
||||||
|
|
||||||
def secure_login(user, pwd):
|
def secure_login(user, pwd):
|
||||||
# Better: hashed password check
|
# Better: hashed password check
|
||||||
@@ -200,7 +200,7 @@ def secure_login(user, pwd):
|
|||||||
if user == "admin" and hashed == "expected_hash":
|
if user == "admin" and hashed == "expected_hash":
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
'''
|
"""
|
||||||
|
|
||||||
improved_file = self.create_additional_test_file("auth_improved.py", improved_code)
|
improved_file = self.create_additional_test_file("auth_improved.py", improved_code)
|
||||||
|
|
||||||
|
|||||||
@@ -82,12 +82,12 @@ class PerToolDeduplicationTest(BaseSimulatorTest):
|
|||||||
self.setup_test_files()
|
self.setup_test_files()
|
||||||
|
|
||||||
# Create a short dummy file for quick testing
|
# Create a short dummy file for quick testing
|
||||||
dummy_content = '''def add(a, b):
|
dummy_content = """def add(a, b):
|
||||||
return a + b # Missing type hints
|
return a + b # Missing type hints
|
||||||
|
|
||||||
def divide(x, y):
|
def divide(x, y):
|
||||||
return x / y # No zero check
|
return x / y # No zero check
|
||||||
'''
|
"""
|
||||||
dummy_file_path = self.create_additional_test_file("dummy_code.py", dummy_content)
|
dummy_file_path = self.create_additional_test_file("dummy_code.py", dummy_content)
|
||||||
|
|
||||||
# Get timestamp for log filtering
|
# Get timestamp for log filtering
|
||||||
@@ -125,7 +125,7 @@ def divide(x, y):
|
|||||||
codereview_params = {
|
codereview_params = {
|
||||||
"files": [dummy_file_path],
|
"files": [dummy_file_path],
|
||||||
"context": "Please give me a quick one line reply. General code review for quality and best practices",
|
"context": "Please give me a quick one line reply. General code review for quality and best practices",
|
||||||
"thinking_mode": "low"
|
"thinking_mode": "low",
|
||||||
}
|
}
|
||||||
|
|
||||||
response2, _ = self.call_mcp_tool("codereview", codereview_params)
|
response2, _ = self.call_mcp_tool("codereview", codereview_params)
|
||||||
@@ -137,12 +137,12 @@ def divide(x, y):
|
|||||||
|
|
||||||
# Step 3: Create new file and continue with precommit
|
# Step 3: Create new file and continue with precommit
|
||||||
self.logger.info(" Step 3: precommit continuation with old + new file")
|
self.logger.info(" Step 3: precommit continuation with old + new file")
|
||||||
new_file_content = '''def multiply(x, y):
|
new_file_content = """def multiply(x, y):
|
||||||
return x * y
|
return x * y
|
||||||
|
|
||||||
def subtract(a, b):
|
def subtract(a, b):
|
||||||
return a - b
|
return a - b
|
||||||
'''
|
"""
|
||||||
new_file_path = self.create_additional_test_file("new_feature.py", new_file_content)
|
new_file_path = self.create_additional_test_file("new_feature.py", new_file_content)
|
||||||
|
|
||||||
# Continue precommit with both files
|
# Continue precommit with both files
|
||||||
|
|||||||
Reference in New Issue
Block a user