mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-25 01:59:52 +08:00
update tests
This commit is contained in:
@@ -24,3 +24,46 @@
|
|||||||
json:
|
json:
|
||||||
name: $user_name
|
name: $user_name
|
||||||
password: $user_password
|
password: $user_password
|
||||||
|
|
||||||
|
- api:
|
||||||
|
def: get_user($uid, $token)
|
||||||
|
request:
|
||||||
|
url: /api/users/$uid
|
||||||
|
method: GET
|
||||||
|
headers:
|
||||||
|
token: $token
|
||||||
|
|
||||||
|
- 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
|
||||||
|
|
||||||
|
- api:
|
||||||
|
def: delete_user($uid, $token)
|
||||||
|
request:
|
||||||
|
url: /api/users/$uid
|
||||||
|
method: DELETE
|
||||||
|
headers:
|
||||||
|
token: $token
|
||||||
|
|
||||||
|
- api:
|
||||||
|
def: get_users($token)
|
||||||
|
request:
|
||||||
|
url: /api/users
|
||||||
|
method: GET
|
||||||
|
headers:
|
||||||
|
token: $token
|
||||||
|
|
||||||
|
- api:
|
||||||
|
def: reset_all($token)
|
||||||
|
request:
|
||||||
|
url: /api/reset-all
|
||||||
|
method: GET
|
||||||
|
headers:
|
||||||
|
token: $token
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import hmac
|
|
||||||
import json
|
import json
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
- config:
|
- config:
|
||||||
name: "create user testsets."
|
name: "user management testset."
|
||||||
variable_binds:
|
variable_binds:
|
||||||
- user_agent: 'iOS/10.3'
|
- user_agent: 'iOS/10.3'
|
||||||
- device_sn: ${gen_random_string(15)}
|
- device_sn: ${gen_random_string(15)}
|
||||||
@@ -20,14 +20,18 @@
|
|||||||
- token: content.token
|
- token: content.token
|
||||||
|
|
||||||
- test:
|
- test:
|
||||||
name: create user which does not exist
|
name: reset all users
|
||||||
variable_binds:
|
api: reset_all($token)
|
||||||
- user_name: "user1"
|
|
||||||
- user_password: "123456"
|
|
||||||
api: create_user(1000, $user_name, $user_password, $token)
|
|
||||||
validators:
|
validators:
|
||||||
- {"check": "status_code", "comparator": "eq", "expected": 201}
|
- {"check": "status_code", "expected": 200}
|
||||||
- {"check": "content.success", "comparator": "eq", "expected": true}
|
- {"check": "content.success", "expected": true}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: get user that does not exist
|
||||||
|
api: get_user(1000, $token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 404}
|
||||||
|
- {"check": "content.success", "expected": false}
|
||||||
|
|
||||||
- test:
|
- test:
|
||||||
name: create user which does not exist
|
name: create user which does not exist
|
||||||
@@ -36,5 +40,79 @@
|
|||||||
- user_password: "123456"
|
- user_password: "123456"
|
||||||
api: create_user(1000, $user_name, $user_password, $token)
|
api: create_user(1000, $user_name, $user_password, $token)
|
||||||
validators:
|
validators:
|
||||||
- {"check": "status_code", "comparator": "eq", "expected": 500}
|
- {"check": "status_code", "expected": 201}
|
||||||
- {"check": "content.success", "comparator": "eq", "expected": false}
|
- {"check": "content.success", "expected": true}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: get user that has been created
|
||||||
|
api: get_user(1000, $token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 200}
|
||||||
|
- {"check": "content.success", "expected": true}
|
||||||
|
- {"check": "content.data.password", "expected": "123456"}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: create user which exists
|
||||||
|
variable_binds:
|
||||||
|
- user_name: "user1"
|
||||||
|
- user_password: "123456"
|
||||||
|
api: create_user(1000, $user_name, $user_password, $token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 500}
|
||||||
|
- {"check": "content.success", "expected": false}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: update user which exists
|
||||||
|
variable_binds:
|
||||||
|
- user_name: "user1"
|
||||||
|
- user_password: "654321"
|
||||||
|
api: update_user(1000, $user_name, $user_password, $token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 200}
|
||||||
|
- {"check": "content.success", "expected": true}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: get user that has been updated
|
||||||
|
api: get_user(1000, $token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 200}
|
||||||
|
- {"check": "content.success", "expected": true}
|
||||||
|
- {"check": "content.data.password", "expected": "654321"}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: get users
|
||||||
|
api: get_users($token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 200}
|
||||||
|
- {"check": "content.count", "expected": 1}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: delete user that exists
|
||||||
|
api: delete_user(1000, $token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 200}
|
||||||
|
- {"check": "content.success", "expected": true}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: get users
|
||||||
|
api: get_users($token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 200}
|
||||||
|
- {"check": "content.count", "expected": 0}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: create user which has been deleted
|
||||||
|
variable_binds:
|
||||||
|
- user_name: "user1"
|
||||||
|
- user_password: "123456"
|
||||||
|
api: create_user(1000, $user_name, $user_password, $token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 201}
|
||||||
|
- {"check": "content.success", "expected": true}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: get users
|
||||||
|
api: get_users($token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 200}
|
||||||
|
- {"check": "content.count", "expected": 1}
|
||||||
|
|||||||
Reference in New Issue
Block a user