知识卡片

结构图卡 · 2275.as.6.f.3.c.9.b.1.c.1.a · 生成模型:未记录

验证代理复用已有用例

理解等级:中级

验证代理是放在已有 API 测试和提供方之间的观察点。测试请求先到代理,再转发到真实入口。代理取得上游响应后,根据预设版本的 OpenAPI 判断状态及消息模式。可让测试失败并报告具体的响应位置、字段和规则,用日志分辨上游 HTTP 状态和代理的验证失败。

适合已有端到端测试、想快速加入规格核对的团队。覆盖范围随原有用例走,新增端点、遗漏的错误分支和测试数据仍需自行补齐。

结构图:

flowchart LR
  T[现有用例] -->|请求| P[验证代理]
  P -->|转发请求| A[真实 API 入口]
  A -->|实际响应| P
  S[OpenAPI 定义] -->|提供断言依据| P
  P -->|响应或违规报告| T
这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 用模式测试检查 API 遵约 7.5 Using a validating proxy for consistency · 查看原书依据

      One way to validate that a schema matches the API behavior is to channel the requests and responses to the API through an intermediary server so that the intermediary server validates the response from the API server against the expected API definition. The intermediary or proxy server can report an error if the API server response doesn’t match the expected schema. To do this, the proxy server needs a reference to the OpenAPI definition containing the response schema.

    参考来源

    - 位置:《Automating API Delivery APIOps with OpenAPI》《第 07 章 用模式测试检查 API 遵约》(7.5 Using a validating proxy for consistency;来源项目 book-source,extracted/Automating API Delivery APIOps with OpenAPI/_epub-src/OEBPS/Text/chapter-7.xhtml#p93) - 结论依据:解释为什么代理能在不重写已有场景的情况下增加对响应模式的断言。 - 原始内容:One way to validate that a schema matches the API behavior is to channel the requests and responses to the API through an intermediary server so that the intermediary server validates the response from the API server against the expected API definition. The intermediary or proxy server can report an error if the API server response doesn’t match the expected schema. To do this, the proxy server needs a reference to the OpenAPI definition containing the response schema.