mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 18:11:21 +08:00
98 lines
2.3 KiB
YAML
98 lines
2.3 KiB
YAML
- api:
|
|
def: get_token($user_agent, $device_sn, $os_platform, $app_version)
|
|
request:
|
|
url: /api/get-token
|
|
method: POST
|
|
headers:
|
|
user_agent: $user_agent
|
|
device_sn: $device_sn
|
|
os_platform: $os_platform
|
|
app_version: $app_version
|
|
json:
|
|
sign: ${get_sign($user_agent, $device_sn, $os_platform, $app_version)}
|
|
validate:
|
|
- eq: ["status_code", 0]
|
|
- len_eq: ["content.token", 12]
|
|
- contains: [{"a": 1, "b": 2}, "a"]
|
|
|
|
- api:
|
|
def: create_user($uid, $user_name, $user_password, $token)
|
|
request:
|
|
url: /api/users/$uid
|
|
method: POST
|
|
headers:
|
|
token: $token
|
|
json:
|
|
name: $user_name
|
|
password: $user_password
|
|
validate:
|
|
- eq: ["status_code", 201]
|
|
|
|
- api:
|
|
def: get_user($uid, $token)
|
|
request:
|
|
url: /api/users/$uid
|
|
method: GET
|
|
headers:
|
|
token: $token
|
|
validate:
|
|
- eq: ["status_code", 200]
|
|
|
|
- api:
|
|
def: update_user($uid, $user_name, $user_password, $token)
|
|
request:
|
|
url: /api/users/$uid
|
|
method: PUT
|
|
headers:
|
|
token: $token
|
|
json:
|
|
name: $user_name
|
|
password: $user_password
|
|
validate:
|
|
- eq: ["status_code", 200]
|
|
|
|
- api:
|
|
def: delete_user($uid, $token)
|
|
request:
|
|
url: /api/users/$uid
|
|
method: DELETE
|
|
headers:
|
|
token: $token
|
|
validate:
|
|
- eq: ["status_code", 200]
|
|
|
|
- api:
|
|
def: get_users($token)
|
|
request:
|
|
url: /api/users
|
|
method: GET
|
|
headers:
|
|
token: $token
|
|
validate:
|
|
- eq: ["status_code", 200]
|
|
|
|
- api:
|
|
def: reset_all($token)
|
|
request:
|
|
url: /api/reset-all
|
|
method: GET
|
|
headers:
|
|
token: $token
|
|
validate:
|
|
- eq: ["status_code", 200]
|
|
- eq: ["content.success", true]
|
|
|
|
- api:
|
|
def: get_headers($n_secs)
|
|
request:
|
|
url: /headers
|
|
method: GET
|
|
setup_hooks:
|
|
- ${setup_hook_add_kwargs($request)}
|
|
- ${setup_hook_remove_kwargs($request)}
|
|
teardown_hooks:
|
|
- ${teardown_hook_sleep_N_secs($response, $n_secs)}
|
|
validate:
|
|
- eq: ["status_code", 200]
|
|
- contained_by: [content.headers.Host, "${get_httpbin_server()}"]
|