v0.1
This commit is contained in:
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
from ddms_compliance_suite.test_framework_core import BaseAPITestCase, TestSeverity, ValidationResult, APIRequestContext, APIResponseContext
|
||||
import logging
|
||||
from typing import Dict, Any, Optional # 确保引入 Optional
|
||||
|
||||
class StatusCode200Check(BaseAPITestCase):
|
||||
# 1. 元数据
|
||||
@@ -11,13 +12,14 @@ class StatusCode200Check(BaseAPITestCase):
|
||||
# 适用于所有方法和路径 (默认)
|
||||
# applicable_methods = None
|
||||
# applicable_paths_regex = None
|
||||
execution_order = 10 # 示例执行顺序
|
||||
use_llm_for_body: bool = True
|
||||
use_llm_for_path_params: bool = True
|
||||
use_llm_for_query_params: bool = True
|
||||
use_llm_for_headers: bool = True
|
||||
|
||||
def __init__(self, endpoint_spec: dict, global_api_spec: dict):
|
||||
super().__init__(endpoint_spec, global_api_spec)
|
||||
def __init__(self, endpoint_spec: Dict[str, Any], global_api_spec: Dict[str, Any], json_schema_validator: Optional[Any] = None):
|
||||
super().__init__(endpoint_spec, global_api_spec, json_schema_validator=json_schema_validator)
|
||||
self.logger.info(f"测试用例 {self.id} ({self.name}) 已针对端点 '{self.endpoint_spec.get('method')} {self.endpoint_spec.get('path')}' 初始化。")
|
||||
|
||||
def validate_response(self, response_context: APIResponseContext, request_context: APIRequestContext) -> list[ValidationResult]:
|
||||
@@ -55,12 +57,13 @@ class HeaderExistenceCheck(BaseAPITestCase):
|
||||
description = "验证 API 响应是否包含 'X-Request-ID' 头。"
|
||||
severity = TestSeverity.MEDIUM
|
||||
tags = ["header", "observability"]
|
||||
execution_order = 10 # 示例执行顺序
|
||||
use_llm_for_body = False
|
||||
|
||||
EXPECTED_HEADER = "X-Request-ID" # 示例,可以根据实际需要修改
|
||||
|
||||
def __init__(self, endpoint_spec: dict, global_api_spec: dict):
|
||||
super().__init__(endpoint_spec, global_api_spec)
|
||||
def __init__(self, endpoint_spec: Dict[str, Any], global_api_spec: Dict[str, Any], json_schema_validator: Optional[Any] = None):
|
||||
super().__init__(endpoint_spec, global_api_spec, json_schema_validator=json_schema_validator)
|
||||
self.logger.info(f"测试用例 {self.id} ({self.name}) 已初始化 for endpoint {self.endpoint_spec.get('path')}")
|
||||
|
||||
def validate_response(self, response_context: APIResponseContext, request_context: APIRequestContext) -> list[ValidationResult]:
|
||||
|
||||
Reference in New Issue
Block a user