Skip to content

Mock Interface Task

Mock interfaces are used to quickly generate and simulate APIs that your system depends on, enabling development and testing to proceed independently. Using mock interfaces for testing also avoids the issue of dirty data caused by direct integration with production systems.

AngusTester Mock Interfaces Allow You To:

  • Advance Development Testing - Complete integration without relying on backend services
  • Construct Exception Scenarios - Simulate various errors and delays
  • Verify Asynchronous Processes - Test callback logic through pushback mechanisms
  • Ensure Security Isolation - Prevent test data from polluting production environments

Usage Tip

Before use, create and start a Mock Service in the AngusTester Mock application, and load scripts via the Import Interface feature.

Primary Parameter List

Field NameTypeRequiredLength/Quantity LimitDescription
namestringYes<=400Mock interface name.
descriptionstringNo<=800Mock interface description.
methodenumYes/Request method, supported values: POST, GET, PUT, PATCH, DELETE, HEAD, OPTIONS, TRACE.
endpointbooleanYes<=800Request endpoint.
responsesarray[object]Yes1 ~ 50Response matching rules and content.

A complete configuration example:

yaml
mockApis:  
  name: Business processing delay  
  description: Mock different business processing delays. Used to return corresponding fixed delays based on client's time requirements.  
  method: GET  
  endpoint: /business  
  responses:  
    - name: Mock 1 millisecond business processing delay response  
      match:  
        path:  
          condition: REG_MATCH  
          expression: \/business  
        parameters:  
          - name: delay  
            in: query  
            condition: EQUAL  
            expected: 1  
        body:  
          condition: IS_EMPTY  
        priority: 1  
      content:  
        status: 200  
        headers:  
          - name: Content-Type  
            value: application/json  
        content: '{  
                    "code": "S",  
                    "msg": "Respond with a delay of 1 millisecond."  
                }'  
        delay:  
          mode: FIXED  
          fixedTime: 1ms  
          minRandomTime: 1ms  
          maxRandomTime: 1ms  
      pushback:  
        autoPush: true  
        method: GET  
        url: http://serv02-sample.angusmock.cloud:30010/business  
        parameters:  
          - name: x-pushback-test  
            in: header  
            enabled: true  
            type: string  
            value: "true"  
        body:  
          rawContent: This is a pushback body content

Response Matching Rules and Content (responses)

Field NameTypeRequiredLength LimitDescription
namestringYes<=400Response name.
matchobjectNo/Response matching conditions. The response is returned only when conditions are met. If empty, treated as always matching.
contentobjectYes/Response content returned when conditions are met.
pushbackobjectNo/Pushback request configuration. Automatically sends an HTTP request to a specified URL upon receiving a mock request (e.g., payment callback).
yaml
responses:  
- name: Mock 1 millisecond business processing delay response  
  match:  
    # Matching configuration conditions  
  content:  
    # Response content configuration  
  pushback:  
    # Pushback configuration

Response Matching Conditions (match)

Matching Rules: Specify the request conditions required to return the current response.

Notes

When multiple responses match the conditions, the one with the highest priority is returned. If no conditions are configured or priorities are equal, the first condition (earliest configured) is returned.

Field NameTypeRequiredQuantity/Size LimitDescription
pathobjectNo/Path matching. Matches based on request path. See "Path Matching" below.
parametersarray[object]No1 ~ 20Parameter matching. Matches based on request parameters. See "Parameter Matching" below.
bodyobjectNo/Request body matching. Matches based on request body. See "Request Body Matching" below.
priorityintNo<=2147483647Matching priority. Higher values take precedence when multiple conditions match.

The following example returns the response content only when the path matches the regex \/business, the query parameter delay=1, and the request body is empty:

yaml
match:  
  path:  
    condition: REG_MATCH  
    expression: \/business  
  parameters:  
  - name: delay  
    in: query  
    condition: EQUAL  
    expected: 1  
  body:  
    condition: IS_EMPTY  
  priority: 1

Path Matching (path)

Field NameTypeRequiredLength LimitDescription
conditionenumYes/Matching condition. Values are the same as "Assertion Conditions" above.
expressionstringNo<=1024Matching expression. Required for regex, XPath, or JSONPath conditions.
expectedstringNo<=4096Expected value. Required for non-empty value conditions.

The following example returns the response content only when the path matches the regex \/business:

yaml
path:  
  condition: REG_MATCH  
  expression: \/business

Parameter Matching (parameters)

Field NameTypeRequiredLength LimitDescription
namestringYes<=400Parameter name to match.
inenumYes/Parameter location. Supported values: QUERY, PATH, COOKIE, HEADER.
conditionenumYes/Matching condition. Values are the same as "Assertion Conditions" above.
expressionstringNo<=1024Matching expression. Required for regex, XPath, or JSONPath conditions.
expectedstringNo<=4096Expected value. Required for non-empty value conditions.

The following example returns the response content only when the query parameter delay=1:

yaml
parameters:  
- name: delay  
  in: query  
  condition: EQUAL  
  expected: 1

Request Body Matching (body)

Field NameTypeRequiredLength LimitDescription
conditionenumYes/Matching condition. Values are the same as "Assertion Conditions" above.
expressionstringNo<=1024Matching expression. Required for regex, XPath, or JSONPath conditions.
expectedstringNo<=4096Expected value. Required for non-empty value conditions.

The following example returns the response only when the request body is empty:

yaml
body:  
  condition: IS_EMPTY

Response Content (content)

Field NameTypeRequiredLength/Quantity LimitDescription
statusintegerYes/Response status code.
headersarray[object]No1 ~ 200Response headers.
contentEncodingstringNo<=4096Request body encoding format. Supports base64 and gzip_base64. Required for binary content.
contentstringNo/Response content. Raw or encoded (base64/gzip_base64) content must not exceed 20MB.
delayobjectNo/Response delay configuration.

The following example delays the response by a fixed 1ms before returning the content:

yaml
content:  
  status: 200  
  headers:  
  - name: Content-Type  
    value: application/json  
  content: '{  
              "code": "S",  
              "msg": "Respond with a delay of 1 millisecond."  
          }'  
  delay:  
    mode: FIXED  
    fixedTime: 1ms

Response Delay (delay)

Field NameTypeRequiredSize LimitDescription
modeenumYes/Delay mode. Supported values: NONE, FIXED, RANDOM.
fixedTimestringNo1 ~ 7200000msFixed delay duration. Required for FIXED mode.
minRandomTimestringNo1 ~ 7200000msMinimum delay duration. Required for RANDOM mode.
maxRandomTimestringNo1 ~ 7200000msMaximum delay duration. Required for RANDOM mode.

The following example delays the response by a fixed 1ms before returning:

yaml
delay:  
  mode: FIXED  
  fixedTime: 1ms

Pushback Request Configuration (pushback)

Field NameTypeRequiredLength/Quantity LimitDescription
autoPushbooleanYes/Whether to auto-trigger pushback upon receiving a request. If disabled, manually click "Push Manually" to send.
methodenumYes/Request method. Supported values: POST, GET, PUT, PATCH, DELETE, HEAD, OPTIONS, TRACE.
urlstringYes<=800Pushback target URL.
parametersobjectNo1 ~ 200Pushback request parameters. See "Parameters" in HTTP request configuration.
bodyobjectNo/Pushback request body. See "Request Body" in HTTP configuration.
delayobjectNo/Pushback delay configuration. See "Response Delay" in mock response configuration.

The following example automatically sends a pushback request upon receiving a request:

  • Method: POST
  • URL: http://serv02-sample.angusmock.cloud:30010/business
  • Request content: This is a pushback body content.
yaml
pushback:  
  autoPush: true  
  method: POST  
  url: http://serv02-sample.angusmock.cloud:30010/business  
  parameters:  
  - name: x-pushback-test  
    in: header  
    enabled: true  
    type: string  
    value: "true"  
  body:  
    rawContent: This is a pushback body content

Typical Use Cases

  • Payment success callback verification
  • Message notification testing
  • Asynchronous task status updates

Released under the GPL-3.0 License.