Skip to main content

基础模板

此模板请求 URL 的 / 路径并匹配响应中的字符串。
id: basic-example

info:
  name: Test HTTP Template
  author: pdteam
  severity: info

http:
  - method: GET
    path:
      - "{{BaseURL}}"
    matchers:
      - type: word
        words:
          - "This is test matcher text"

多个匹配器

此模板请求 URL 的 / 路径并对响应运行多个基于 OR 的匹配器。
id: http-multiple-matchers

info:
  name: Test HTTP Template
  author: pdteam
  severity: info

http:
  - method: GET
    path:
      - "{{BaseURL}}"

    matchers:
      - type: word
        name: php
        words:
          - "X-Powered-By: PHP"
          - "PHPSESSID"
        part: header

      - type: word
        name: node
        words:
          - "Server: NodeJS"
          - "X-Powered-By: nodejs"
        condition: or
        part: header

      - type: word
        name: python
        words:
          - "Python/2."
          - "Python/3."
        part: header

带条件的匹配器

此模板请求 URL 的 / 路径并运行两个匹配器,一个带有 AND 条件的头部字符串匹配,另一个匹配器针对响应体。
id: matchers-conditions

info:
  name: Test HTTP Template
  author: pdteam
  severity: info

http:
  - method: GET
    path:
      - "{{BaseURL}}"

    matchers:
      - type: word
        words:
          - "X-Powered-By: PHP"
          - "PHPSESSID"
        condition: and
        part: header

      - type: word
        words:
          - "PHP"
        part: body

多匹配器条件

此模板请求 URL 的 / 路径并运行两个带有 AND 条件的匹配器,一个带有 OR 条件的头部字符串匹配,另一个匹配器针对响应体,两个条件都必须为真才能匹配此模板。
id: multiple-matchers-conditions

info:
  name: Test HTTP Template
  author: pdteam
  severity: info

http:
  - method: GET
    path:
      - "{{BaseURL}}"

    matchers-condition: and
    matchers:

      - type: word
        words:
          - "X-Powered-By: PHP"
          - "PHPSESSID"
        condition: or
        part: header

      - type: word
        words:
          - PHP
        part: body

自定义头部

此模板以 GET 请求方式请求 URL 的 / 路径,并在模板中定义了额外的自定义头部。
id: custom-headers

info:
  name: Test HTTP Template
  author: pdteam
  severity: info

http:
  - method: GET

    # 向服务器发送一些头部的示例

    headers:

      X-Client-IP: 127.0.0.1
      X-Remote-IP: 127.0.0.1
      X-Remote-Addr: 127.0.0.1
      X-Forwarded-For: 127.0.0.1
      X-Originating-IP: 127.0.0.1

    path:
      - "{{BaseURL}}/server-status"

    matchers:
      - type: word
        words:
          - Apache Server Status
          - Server Version
        condition: and

POST 请求

此模板向 /admin 端点发送 POST 请求,在模板中定义了主体参数数据。
id: post-request

info:
  name: Test HTTP Template
  author: pdteam
  severity: info

http:
  - method: POST
    path:
      - "{{BaseURL}}/admin"

    body: 'admin=test'

    matchers:
      - type: word
        words:
          - Welcome Admin

基于时间的匹配器

此模板是基于 DSL 的持续时间匹配器示例,当响应时间匹配定义的持续时间时返回 true,在这种情况下为 6 秒或超过 6 秒。
id: time-based-matcher

info:
  name: DSL based response time matcher
  author: pdteam
  severity: info

http:
  - raw:
      - |
        GET /slow HTTP/1.1

    matchers:
      - type: dsl
        dsl:
          - 'duration>=6'