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 Name | Type | Required | Length/Quantity Limit | Description |
---|---|---|---|---|
name | string | Yes | <=400 | Mock interface name. |
description | string | No | <=800 | Mock interface description. |
method | enum | Yes | / | Request method, supported values: POST, GET, PUT, PATCH, DELETE, HEAD, OPTIONS, TRACE. |
endpoint | boolean | Yes | <=800 | Request endpoint. |
responses | array[object] | Yes | 1 ~ 50 | Response matching rules and content. |
A complete configuration example:
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 Name | Type | Required | Length Limit | Description |
---|---|---|---|---|
name | string | Yes | <=400 | Response name. |
match | object | No | / | Response matching conditions. The response is returned only when conditions are met. If empty, treated as always matching. |
content | object | Yes | / | Response content returned when conditions are met. |
pushback | object | No | / | Pushback request configuration. Automatically sends an HTTP request to a specified URL upon receiving a mock request (e.g., payment callback). |
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 Name | Type | Required | Quantity/Size Limit | Description |
---|---|---|---|---|
path | object | No | / | Path matching. Matches based on request path. See "Path Matching" below. |
parameters | array[object] | No | 1 ~ 20 | Parameter matching. Matches based on request parameters. See "Parameter Matching" below. |
body | object | No | / | Request body matching. Matches based on request body. See "Request Body Matching" below. |
priority | int | No | <=2147483647 | Matching 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:
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 Name | Type | Required | Length Limit | Description |
---|---|---|---|---|
condition | enum | Yes | / | Matching condition. Values are the same as "Assertion Conditions" above. |
expression | string | No | <=1024 | Matching expression. Required for regex, XPath, or JSONPath conditions. |
expected | string | No | <=4096 | Expected value. Required for non-empty value conditions. |
The following example returns the response content only when the path matches the regex \/business
:
path:
condition: REG_MATCH
expression: \/business
Parameter Matching (parameters)
Field Name | Type | Required | Length Limit | Description |
---|---|---|---|---|
name | string | Yes | <=400 | Parameter name to match. |
in | enum | Yes | / | Parameter location. Supported values: QUERY, PATH, COOKIE, HEADER. |
condition | enum | Yes | / | Matching condition. Values are the same as "Assertion Conditions" above. |
expression | string | No | <=1024 | Matching expression. Required for regex, XPath, or JSONPath conditions. |
expected | string | No | <=4096 | Expected value. Required for non-empty value conditions. |
The following example returns the response content only when the query parameter delay=1
:
parameters:
- name: delay
in: query
condition: EQUAL
expected: 1
Request Body Matching (body)
Field Name | Type | Required | Length Limit | Description |
---|---|---|---|---|
condition | enum | Yes | / | Matching condition. Values are the same as "Assertion Conditions" above. |
expression | string | No | <=1024 | Matching expression. Required for regex, XPath, or JSONPath conditions. |
expected | string | No | <=4096 | Expected value. Required for non-empty value conditions. |
The following example returns the response only when the request body is empty:
body:
condition: IS_EMPTY
Response Content (content)
Field Name | Type | Required | Length/Quantity Limit | Description |
---|---|---|---|---|
status | integer | Yes | / | Response status code. |
headers | array[object] | No | 1 ~ 200 | Response headers. |
contentEncoding | string | No | <=4096 | Request body encoding format. Supports base64 and gzip_base64. Required for binary content. |
content | string | No | / | Response content. Raw or encoded (base64/gzip_base64) content must not exceed 20MB. |
delay | object | No | / | Response delay configuration. |
The following example delays the response by a fixed 1ms
before returning the content
:
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 Name | Type | Required | Size Limit | Description |
---|---|---|---|---|
mode | enum | Yes | / | Delay mode. Supported values: NONE, FIXED, RANDOM. |
fixedTime | string | No | 1 ~ 7200000ms | Fixed delay duration. Required for FIXED mode. |
minRandomTime | string | No | 1 ~ 7200000ms | Minimum delay duration. Required for RANDOM mode. |
maxRandomTime | string | No | 1 ~ 7200000ms | Maximum delay duration. Required for RANDOM mode. |
The following example delays the response by a fixed 1ms
before returning:
delay:
mode: FIXED
fixedTime: 1ms
Pushback Request Configuration (pushback)
Field Name | Type | Required | Length/Quantity Limit | Description |
---|---|---|---|---|
autoPush | boolean | Yes | / | Whether to auto-trigger pushback upon receiving a request. If disabled, manually click "Push Manually" to send. |
method | enum | Yes | / | Request method. Supported values: POST, GET, PUT, PATCH, DELETE, HEAD, OPTIONS, TRACE. |
url | string | Yes | <=800 | Pushback target URL. |
parameters | object | No | 1 ~ 200 | Pushback request parameters. See "Parameters" in HTTP request configuration. |
body | object | No | / | Pushback request body. See "Request Body" in HTTP configuration. |
delay | object | No | / | 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
.
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