mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 18:11:21 +08:00
123 lines
3.5 KiB
YAML
123 lines
3.5 KiB
YAML
- config:
|
|
name: "user management testcase."
|
|
variables:
|
|
- user_agent: 'iOS/10.3'
|
|
- device_sn: ${gen_random_string(15)}
|
|
- os_platform: 'ios'
|
|
- app_version: '2.8.6'
|
|
request:
|
|
base_url: $BASE_URL
|
|
headers:
|
|
Content-Type: application/json
|
|
device_sn: $device_sn
|
|
output:
|
|
- token
|
|
|
|
- test:
|
|
name: get token with $user_agent, $app_version
|
|
api: get_token($user_agent, $device_sn, $os_platform, $app_version)
|
|
extract:
|
|
- token: content.token
|
|
validate:
|
|
- "eq": ["status_code", 200]
|
|
- "len_eq": ["content.token", 16]
|
|
- "contains": [{"a": 1, "b": 2}, "b"]
|
|
|
|
- test:
|
|
name: reset all users
|
|
api: reset_all($token)
|
|
validate:
|
|
- {"check": "status_code", "expect": 200}
|
|
- {"check": "content.success", "expect": true}
|
|
|
|
- test:
|
|
name: get user that does not exist
|
|
api: get_user(1000, $token)
|
|
validate:
|
|
- {"check": "status_code", "expect": 404}
|
|
- {"check": "content.success", "expect": false}
|
|
|
|
- test:
|
|
name: create user which does not exist
|
|
variables:
|
|
- user_name: "user1"
|
|
- user_password: "123456"
|
|
api: create_user(1000, $user_name, $user_password, $token)
|
|
validate:
|
|
- {"check": "status_code", "expect": 201}
|
|
- {"check": "content.success", "expect": true}
|
|
|
|
- test:
|
|
name: get user that has been created
|
|
api: get_user(1000, $token)
|
|
validate:
|
|
- {"check": "status_code", "expect": 200}
|
|
- {"check": "content.success", "expect": true}
|
|
- {"check": "content.data.password", "expect": "123456"}
|
|
|
|
- test:
|
|
name: create user which exists
|
|
variables:
|
|
- user_name: "user1"
|
|
- user_password: "123456"
|
|
api: create_user(1000, $user_name, $user_password, $token)
|
|
validate:
|
|
- {"check": "status_code", "expect": 500}
|
|
- {"check": "content.success", "expect": false}
|
|
|
|
- test:
|
|
name: update user which exists
|
|
variables:
|
|
- user_name: "user1"
|
|
- user_password: "654321"
|
|
api: update_user(1000, $user_name, $user_password, $token)
|
|
validate:
|
|
- {"check": "status_code", "expect": 200}
|
|
- {"check": "content.success", "expect": true}
|
|
|
|
- test:
|
|
name: get user that has been updated
|
|
api: get_user(1000, $token)
|
|
validate:
|
|
- {"check": "status_code", "expect": 200}
|
|
- {"check": "content.success", "expect": true}
|
|
- {"check": "content.data.password", "expect": "654321"}
|
|
|
|
- test:
|
|
name: get users
|
|
api: get_users($token)
|
|
validate:
|
|
- {"check": "status_code", "expect": 200}
|
|
- {"check": "content.count", "expect": 1}
|
|
|
|
- test:
|
|
name: delete user that exists
|
|
api: delete_user(1000, $token)
|
|
validate:
|
|
- {"check": "status_code", "expect": 200}
|
|
- {"check": "content.success", "expect": true}
|
|
|
|
- test:
|
|
name: get users
|
|
api: get_users($token)
|
|
validate:
|
|
- {"check": "status_code", "expect": 200}
|
|
- {"check": "content.count", "expect": 0}
|
|
|
|
- test:
|
|
name: create user which has been deleted
|
|
variables:
|
|
- user_name: "user1"
|
|
- user_password: "123456"
|
|
api: create_user(1000, $user_name, $user_password, $token)
|
|
validate:
|
|
- {"check": "status_code", "expect": 201}
|
|
- {"check": "content.success", "expect": true}
|
|
|
|
- test:
|
|
name: get users
|
|
api: get_users($token)
|
|
validate:
|
|
- {"check": "status_code", "expect": 200}
|
|
- {"check": "content.count", "expect": 1}
|