mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-13 04:30:41 +08:00
doc: add docs to repo
This commit is contained in:
4
docs/data/account.csv
Normal file
4
docs/data/account.csv
Normal file
@@ -0,0 +1,4 @@
|
||||
username,password,phone
|
||||
test1,111111,18600000001
|
||||
test2,222222,18600000002
|
||||
test3,333333,18600000003
|
||||
|
223
docs/data/api_server.py
Normal file
223
docs/data/api_server.py
Normal file
@@ -0,0 +1,223 @@
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
import random
|
||||
import string
|
||||
from functools import wraps
|
||||
|
||||
from flask import Flask, make_response, request
|
||||
|
||||
SECRET_KEY = "DebugTalk"
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
""" storage all users' data
|
||||
data structure:
|
||||
users_dict = {
|
||||
'uid1': {
|
||||
'name': 'name1',
|
||||
'password': 'pwd1'
|
||||
},
|
||||
'uid2': {
|
||||
'name': 'name2',
|
||||
'password': 'pwd2'
|
||||
}
|
||||
}
|
||||
"""
|
||||
users_dict = {}
|
||||
|
||||
""" storage all token data
|
||||
data structure:
|
||||
token_dict = {
|
||||
'device_sn1': 'token1',
|
||||
'device_sn2': 'token1'
|
||||
}
|
||||
"""
|
||||
token_dict = {}
|
||||
|
||||
|
||||
def gen_random_string(str_len):
|
||||
""" generate random string with specified length
|
||||
"""
|
||||
return ''.join(
|
||||
random.choice(string.ascii_letters + string.digits) for _ in range(str_len))
|
||||
|
||||
def get_sign(*args):
|
||||
content = ''.join(args).encode('ascii')
|
||||
sign_key = SECRET_KEY.encode('ascii')
|
||||
sign = hmac.new(sign_key, content, hashlib.sha1).hexdigest()
|
||||
return sign
|
||||
|
||||
def gen_md5(*args):
|
||||
return hashlib.md5("".join(args).encode('utf-8')).hexdigest()
|
||||
|
||||
|
||||
def validate_request(func):
|
||||
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
device_sn = request.headers.get('device_sn', "")
|
||||
token = request.headers.get('token', "")
|
||||
|
||||
if not device_sn or not token:
|
||||
result = {
|
||||
'success': False,
|
||||
'msg': "device_sn or token is null."
|
||||
}
|
||||
response = make_response(json.dumps(result), 401)
|
||||
response.headers["Content-Type"] = "application/json"
|
||||
return response
|
||||
|
||||
if token_dict.get(device_sn) != token:
|
||||
result = {
|
||||
'success': False,
|
||||
'msg': "Authorization failed!"
|
||||
}
|
||||
response = make_response(json.dumps(result), 403)
|
||||
response.headers["Content-Type"] = "application/json"
|
||||
return response
|
||||
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return "Hello World!"
|
||||
|
||||
@app.route('/api/get-token', methods=['POST'])
|
||||
def get_token():
|
||||
device_sn = request.headers.get('device_sn', "")
|
||||
os_platform = request.headers.get('os_platform', "")
|
||||
app_version = request.headers.get('app_version', "")
|
||||
data = request.get_json()
|
||||
sign = data.get('sign', "")
|
||||
|
||||
expected_sign = get_sign(device_sn, os_platform, app_version)
|
||||
|
||||
if expected_sign != sign:
|
||||
result = {
|
||||
'success': False,
|
||||
'msg': "Authorization failed!"
|
||||
}
|
||||
response = make_response(json.dumps(result), 403)
|
||||
else:
|
||||
token = gen_random_string(16)
|
||||
token_dict[device_sn] = token
|
||||
|
||||
result = {
|
||||
'success': True,
|
||||
'token': token
|
||||
}
|
||||
response = make_response(json.dumps(result))
|
||||
|
||||
response.headers["Content-Type"] = "application/json"
|
||||
return response
|
||||
|
||||
@app.route('/api/users')
|
||||
@validate_request
|
||||
def get_users():
|
||||
users_list = [user for uid, user in users_dict.items()]
|
||||
users = {
|
||||
'success': True,
|
||||
'count': len(users_list),
|
||||
'items': users_list
|
||||
}
|
||||
response = make_response(json.dumps(users))
|
||||
response.headers["Content-Type"] = "application/json"
|
||||
return response
|
||||
|
||||
@app.route('/api/reset-all')
|
||||
@validate_request
|
||||
def clear_users():
|
||||
users_dict.clear()
|
||||
result = {
|
||||
'success': True
|
||||
}
|
||||
response = make_response(json.dumps(result))
|
||||
response.headers["Content-Type"] = "application/json"
|
||||
return response
|
||||
|
||||
@app.route('/api/users/<int:uid>', methods=['POST'])
|
||||
@validate_request
|
||||
def create_user(uid):
|
||||
user = request.get_json()
|
||||
if uid not in users_dict:
|
||||
result = {
|
||||
'success': True,
|
||||
'msg': "user created successfully."
|
||||
}
|
||||
status_code = 201
|
||||
users_dict[uid] = user
|
||||
else:
|
||||
result = {
|
||||
'success': False,
|
||||
'msg': "user already existed."
|
||||
}
|
||||
status_code = 500
|
||||
|
||||
response = make_response(json.dumps(result), status_code)
|
||||
response.headers["Content-Type"] = "application/json"
|
||||
return response
|
||||
|
||||
@app.route('/api/users/<int:uid>')
|
||||
@validate_request
|
||||
def get_user(uid):
|
||||
user = users_dict.get(uid, {})
|
||||
if user:
|
||||
result = {
|
||||
'success': True,
|
||||
'data': user
|
||||
}
|
||||
status_code = 200
|
||||
else:
|
||||
result = {
|
||||
'success': False,
|
||||
'data': user
|
||||
}
|
||||
status_code = 404
|
||||
|
||||
response = make_response(json.dumps(result), status_code)
|
||||
response.headers["Content-Type"] = "application/json"
|
||||
return response
|
||||
|
||||
@app.route('/api/users/<int:uid>', methods=['PUT'])
|
||||
@validate_request
|
||||
def update_user(uid):
|
||||
user = users_dict.get(uid, {})
|
||||
if user:
|
||||
user = request.get_json()
|
||||
success = True
|
||||
status_code = 200
|
||||
users_dict[uid] = user
|
||||
else:
|
||||
success = False
|
||||
status_code = 404
|
||||
|
||||
result = {
|
||||
'success': success,
|
||||
'data': user
|
||||
}
|
||||
response = make_response(json.dumps(result), status_code)
|
||||
response.headers["Content-Type"] = "application/json"
|
||||
return response
|
||||
|
||||
@app.route('/api/users/<int:uid>', methods=['DELETE'])
|
||||
@validate_request
|
||||
def delete_user(uid):
|
||||
user = users_dict.pop(uid, {})
|
||||
if user:
|
||||
success = True
|
||||
status_code = 200
|
||||
else:
|
||||
success = False
|
||||
status_code = 404
|
||||
|
||||
result = {
|
||||
'success': success,
|
||||
'data': user
|
||||
}
|
||||
response = make_response(json.dumps(result), status_code)
|
||||
response.headers["Content-Type"] = "application/json"
|
||||
return response
|
||||
3
docs/data/app_version.csv
Normal file
3
docs/data/app_version.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
app_version
|
||||
2.8.5
|
||||
2.8.6
|
||||
|
48
docs/data/debugtalk.py
Normal file
48
docs/data/debugtalk.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import hashlib
|
||||
import hmac
|
||||
import random
|
||||
import string
|
||||
import time
|
||||
|
||||
SECRET_KEY = "DebugTalk"
|
||||
|
||||
def gen_random_string(str_len):
|
||||
random_char_list = []
|
||||
for _ in range(str_len):
|
||||
random_char = random.choice(string.ascii_letters + string.digits)
|
||||
random_char_list.append(random_char)
|
||||
|
||||
random_string = ''.join(random_char_list)
|
||||
return random_string
|
||||
|
||||
def get_sign(*args):
|
||||
content = ''.join(args).encode('ascii')
|
||||
sign_key = SECRET_KEY.encode('ascii')
|
||||
sign = hmac.new(sign_key, content, hashlib.sha1).hexdigest()
|
||||
return sign
|
||||
|
||||
def gen_user_id():
|
||||
return int(time.time() * 1000)
|
||||
|
||||
def get_user_id():
|
||||
return [
|
||||
{"user_id": 1001},
|
||||
{"user_id": 1002},
|
||||
{"user_id": 1003},
|
||||
{"user_id": 1004}
|
||||
]
|
||||
|
||||
def get_account(num):
|
||||
accounts = []
|
||||
for index in range(1, num+1):
|
||||
accounts.append(
|
||||
{"username": "user%s" % index, "password": str(index) * 6},
|
||||
)
|
||||
|
||||
return accounts
|
||||
|
||||
def get_os_platform():
|
||||
return [
|
||||
{"os_platform": "ios"},
|
||||
{"os_platform": "android"}
|
||||
]
|
||||
10
docs/data/demo-parameters-get-token.yml
Normal file
10
docs/data/demo-parameters-get-token.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
config:
|
||||
name: get token with parameters
|
||||
|
||||
testcases:
|
||||
get token with $user_agent, $app_version, $os_platform:
|
||||
testcase: demo-testcase-get-token.yml
|
||||
parameters:
|
||||
user_agent: ["iOS/10.1", "iOS/10.2", "iOS/10.3"]
|
||||
app_version: ${P(app_version.csv)}
|
||||
os_platform: ${get_os_platform()}
|
||||
58
docs/data/demo-quickstart-0.json
Normal file
58
docs/data/demo-quickstart-0.json
Normal file
@@ -0,0 +1,58 @@
|
||||
[
|
||||
{
|
||||
"config": {
|
||||
"name": "testcase description",
|
||||
"variables": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "/api/get-token",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/get-token",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"User-Agent": "python-requests/2.18.4",
|
||||
"device_sn": "FwgRiO7CNA50DSU",
|
||||
"os_platform": "ios",
|
||||
"app_version": "2.8.6",
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"sign": "9c0c7e51c91ae963c833a4ccbab8d683c4a90c98"
|
||||
}
|
||||
},
|
||||
"validate": [
|
||||
{"eq": ["status_code", 200]},
|
||||
{"eq": ["headers.Content-Type", "application/json"]},
|
||||
{"eq": ["content.success", true]},
|
||||
{"eq": ["content.token", "baNLX1zhFYP11Seb"]}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "/api/users/1000",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/users/1000",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"User-Agent": "python-requests/2.18.4",
|
||||
"device_sn": "FwgRiO7CNA50DSU",
|
||||
"token": "baNLX1zhFYP11Seb",
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"validate": [
|
||||
{"eq": ["status_code", 201]},
|
||||
{"eq": ["headers.Content-Type", "application/json"]},
|
||||
{"eq": ["content.success", true]},
|
||||
{"eq": ["content.msg", "user created successfully."]}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
41
docs/data/demo-quickstart-0.yml
Normal file
41
docs/data/demo-quickstart-0.yml
Normal file
@@ -0,0 +1,41 @@
|
||||
- config:
|
||||
name: testcase description
|
||||
variables: {}
|
||||
|
||||
- test:
|
||||
name: /api/get-token
|
||||
request:
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
User-Agent: python-requests/2.18.4
|
||||
app_version: 2.8.6
|
||||
device_sn: FwgRiO7CNA50DSU
|
||||
os_platform: ios
|
||||
json:
|
||||
sign: 9c0c7e51c91ae963c833a4ccbab8d683c4a90c98
|
||||
method: POST
|
||||
url: http://127.0.0.1:5000/api/get-token
|
||||
validate:
|
||||
- eq: [status_code, 200]
|
||||
- eq: [headers.Content-Type, application/json]
|
||||
- eq: [content.success, true]
|
||||
- eq: [content.token, baNLX1zhFYP11Seb]
|
||||
|
||||
- test:
|
||||
name: /api/users/1000
|
||||
request:
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
User-Agent: python-requests/2.18.4
|
||||
device_sn: FwgRiO7CNA50DSU
|
||||
token: baNLX1zhFYP11Seb
|
||||
json:
|
||||
name: user1
|
||||
password: '123456'
|
||||
method: POST
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
validate:
|
||||
- eq: [status_code, 201]
|
||||
- eq: [headers.Content-Type, application/json]
|
||||
- eq: [content.success, true]
|
||||
- eq: [content.msg, user created successfully.]
|
||||
57
docs/data/demo-quickstart-1.json
Normal file
57
docs/data/demo-quickstart-1.json
Normal file
@@ -0,0 +1,57 @@
|
||||
[
|
||||
{
|
||||
"config": {
|
||||
"name": "testcase description",
|
||||
"variables": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "/api/get-token",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/get-token",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"User-Agent": "python-requests/2.18.4",
|
||||
"device_sn": "FwgRiO7CNA50DSU",
|
||||
"os_platform": "ios",
|
||||
"app_version": "2.8.6",
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"sign": "9c0c7e51c91ae963c833a4ccbab8d683c4a90c98"
|
||||
}
|
||||
},
|
||||
"validate": [
|
||||
{"eq": ["status_code", 200]},
|
||||
{"eq": ["headers.Content-Type", "application/json"]},
|
||||
{"eq": ["content.success", true]}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "/api/users/1000",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/users/1000",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"User-Agent": "python-requests/2.18.4",
|
||||
"device_sn": "FwgRiO7CNA50DSU",
|
||||
"token": "baNLX1zhFYP11Seb",
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"validate": [
|
||||
{"eq": ["status_code", 201]},
|
||||
{"eq": ["headers.Content-Type", "application/json"]},
|
||||
{"eq": ["content.success", true]},
|
||||
{"eq": ["content.msg", "user created successfully."]}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
40
docs/data/demo-quickstart-1.yml
Normal file
40
docs/data/demo-quickstart-1.yml
Normal file
@@ -0,0 +1,40 @@
|
||||
- config:
|
||||
name: testcase description
|
||||
variables: {}
|
||||
|
||||
- test:
|
||||
name: /api/get-token
|
||||
request:
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
User-Agent: python-requests/2.18.4
|
||||
app_version: 2.8.6
|
||||
device_sn: FwgRiO7CNA50DSU
|
||||
os_platform: ios
|
||||
json:
|
||||
sign: 9c0c7e51c91ae963c833a4ccbab8d683c4a90c98
|
||||
method: POST
|
||||
url: http://127.0.0.1:5000/api/get-token
|
||||
validate:
|
||||
- eq: [status_code, 200]
|
||||
- eq: [headers.Content-Type, application/json]
|
||||
- eq: [content.success, true]
|
||||
|
||||
- test:
|
||||
name: /api/users/1000
|
||||
request:
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
User-Agent: python-requests/2.18.4
|
||||
device_sn: FwgRiO7CNA50DSU
|
||||
token: baNLX1zhFYP11Seb
|
||||
json:
|
||||
name: user1
|
||||
password: '123456'
|
||||
method: POST
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
validate:
|
||||
- eq: [status_code, 201]
|
||||
- eq: [headers.Content-Type, application/json]
|
||||
- eq: [content.success, true]
|
||||
- eq: [content.msg, user created successfully.]
|
||||
60
docs/data/demo-quickstart-2.json
Normal file
60
docs/data/demo-quickstart-2.json
Normal file
@@ -0,0 +1,60 @@
|
||||
[
|
||||
{
|
||||
"config": {
|
||||
"name": "testcase description",
|
||||
"variables": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "/api/get-token",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/get-token",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"User-Agent": "python-requests/2.18.4",
|
||||
"device_sn": "FwgRiO7CNA50DSU",
|
||||
"os_platform": "ios",
|
||||
"app_version": "2.8.6",
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"sign": "9c0c7e51c91ae963c833a4ccbab8d683c4a90c98"
|
||||
}
|
||||
},
|
||||
"extract": [
|
||||
{"token": "content.token"}
|
||||
],
|
||||
"validate": [
|
||||
{"eq": ["status_code", 200]},
|
||||
{"eq": ["headers.Content-Type", "application/json"]},
|
||||
{"eq": ["content.success", true]}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "/api/users/1000",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/users/1000",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"User-Agent": "python-requests/2.18.4",
|
||||
"device_sn": "FwgRiO7CNA50DSU",
|
||||
"token": "$token",
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"validate": [
|
||||
{"eq": ["status_code", 201]},
|
||||
{"eq": ["headers.Content-Type", "application/json"]},
|
||||
{"eq": ["content.success", true]},
|
||||
{"eq": ["content.msg", "user created successfully."]}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
42
docs/data/demo-quickstart-2.yml
Normal file
42
docs/data/demo-quickstart-2.yml
Normal file
@@ -0,0 +1,42 @@
|
||||
- config:
|
||||
name: testcase description
|
||||
variables: {}
|
||||
|
||||
- test:
|
||||
name: /api/get-token
|
||||
request:
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
User-Agent: python-requests/2.18.4
|
||||
app_version: 2.8.6
|
||||
device_sn: FwgRiO7CNA50DSU
|
||||
os_platform: ios
|
||||
json:
|
||||
sign: 9c0c7e51c91ae963c833a4ccbab8d683c4a90c98
|
||||
method: POST
|
||||
url: http://127.0.0.1:5000/api/get-token
|
||||
extract:
|
||||
token: content.token
|
||||
validate:
|
||||
- eq: [status_code, 200]
|
||||
- eq: [headers.Content-Type, application/json]
|
||||
- eq: [content.success, true]
|
||||
|
||||
- test:
|
||||
name: /api/users/1000
|
||||
request:
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
User-Agent: python-requests/2.18.4
|
||||
device_sn: FwgRiO7CNA50DSU
|
||||
token: $token
|
||||
json:
|
||||
name: user1
|
||||
password: '123456'
|
||||
method: POST
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
validate:
|
||||
- eq: [status_code, 201]
|
||||
- eq: [headers.Content-Type, application/json]
|
||||
- eq: [content.success, true]
|
||||
- eq: [content.msg, user created successfully.]
|
||||
61
docs/data/demo-quickstart-3.json
Normal file
61
docs/data/demo-quickstart-3.json
Normal file
@@ -0,0 +1,61 @@
|
||||
[
|
||||
{
|
||||
"config": {
|
||||
"name": "testcase description",
|
||||
"base_url": "http://127.0.0.1:5000",
|
||||
"variables": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "/api/get-token",
|
||||
"request": {
|
||||
"url": "/api/get-token",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"User-Agent": "python-requests/2.18.4",
|
||||
"device_sn": "FwgRiO7CNA50DSU",
|
||||
"os_platform": "ios",
|
||||
"app_version": "2.8.6",
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"sign": "9c0c7e51c91ae963c833a4ccbab8d683c4a90c98"
|
||||
}
|
||||
},
|
||||
"extract": [
|
||||
{"token": "content.token"}
|
||||
],
|
||||
"validate": [
|
||||
{"eq": ["status_code", 200]},
|
||||
{"eq": ["headers.Content-Type", "application/json"]},
|
||||
{"eq": ["content.success", true]}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "/api/users/1000",
|
||||
"request": {
|
||||
"url": "/api/users/1000",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"User-Agent": "python-requests/2.18.4",
|
||||
"device_sn": "FwgRiO7CNA50DSU",
|
||||
"token": "$token",
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"validate": [
|
||||
{"eq": ["status_code", 201]},
|
||||
{"eq": ["headers.Content-Type", "application/json"]},
|
||||
{"eq": ["content.success", true]},
|
||||
{"eq": ["content.msg", "user created successfully."]}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
43
docs/data/demo-quickstart-3.yml
Normal file
43
docs/data/demo-quickstart-3.yml
Normal file
@@ -0,0 +1,43 @@
|
||||
- config:
|
||||
name: testcase description
|
||||
base_url: http://127.0.0.1:5000
|
||||
variables: {}
|
||||
|
||||
- test:
|
||||
name: /api/get-token
|
||||
request:
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
User-Agent: python-requests/2.18.4
|
||||
app_version: 2.8.6
|
||||
device_sn: FwgRiO7CNA50DSU
|
||||
os_platform: ios
|
||||
json:
|
||||
sign: 9c0c7e51c91ae963c833a4ccbab8d683c4a90c98
|
||||
method: POST
|
||||
url: /api/get-token
|
||||
extract:
|
||||
token: content.token
|
||||
validate:
|
||||
- eq: [status_code, 200]
|
||||
- eq: [headers.Content-Type, application/json]
|
||||
- eq: [content.success, true]
|
||||
|
||||
- test:
|
||||
name: /api/users/1000
|
||||
request:
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
User-Agent: python-requests/2.18.4
|
||||
device_sn: FwgRiO7CNA50DSU
|
||||
token: $token
|
||||
json:
|
||||
name: user1
|
||||
password: '123456'
|
||||
method: POST
|
||||
url: /api/users/1000
|
||||
validate:
|
||||
- eq: [status_code, 201]
|
||||
- eq: [headers.Content-Type, application/json]
|
||||
- eq: [content.success, true]
|
||||
- eq: [content.msg, user created successfully.]
|
||||
70
docs/data/demo-quickstart-4.json
Normal file
70
docs/data/demo-quickstart-4.json
Normal file
@@ -0,0 +1,70 @@
|
||||
[
|
||||
{
|
||||
"config": {
|
||||
"name": "testcase description",
|
||||
"base_url": "http://127.0.0.1:5000",
|
||||
"variables": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "/api/get-token",
|
||||
"variables": {
|
||||
"device_sn": "FwgRiO7CNA50DSU",
|
||||
"os_platform": "ios",
|
||||
"app_version": "2.8.6"
|
||||
},
|
||||
"request": {
|
||||
"url": "/api/get-token",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"User-Agent": "python-requests/2.18.4",
|
||||
"device_sn": "$device_sn",
|
||||
"os_platform": "$os_platform",
|
||||
"app_version": "$app_version",
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"sign": "9c0c7e51c91ae963c833a4ccbab8d683c4a90c98"
|
||||
}
|
||||
},
|
||||
"extract": [
|
||||
{"token": "content.token"}
|
||||
],
|
||||
"validate": [
|
||||
{"eq": ["status_code", 200]},
|
||||
{"eq": ["headers.Content-Type", "application/json"]},
|
||||
{"eq": ["content.success", true]}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "/api/users/$user_id",
|
||||
"variables": {
|
||||
"device_sn": "FwgRiO7CNA50DSU",
|
||||
"user_id": "1000"
|
||||
},
|
||||
"request": {
|
||||
"url": "/api/users/$user_id",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"User-Agent": "python-requests/2.18.4",
|
||||
"device_sn": "$device_sn",
|
||||
"token": "$token",
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"validate": [
|
||||
{"eq": ["status_code", 201]},
|
||||
{"eq": ["headers.Content-Type", "application/json"]},
|
||||
{"eq": ["content.success", true]},
|
||||
{"eq": ["content.msg", "user created successfully."]}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
50
docs/data/demo-quickstart-4.yml
Normal file
50
docs/data/demo-quickstart-4.yml
Normal file
@@ -0,0 +1,50 @@
|
||||
- config:
|
||||
name: testcase description
|
||||
base_url: http://127.0.0.1:5000
|
||||
variables: {}
|
||||
|
||||
- test:
|
||||
name: /api/get-token
|
||||
variables:
|
||||
app_version: 2.8.6
|
||||
device_sn: FwgRiO7CNA50DSU
|
||||
os_platform: ios
|
||||
request:
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
User-Agent: python-requests/2.18.4
|
||||
app_version: $app_version
|
||||
device_sn: $device_sn
|
||||
os_platform: $os_platform
|
||||
json:
|
||||
sign: 9c0c7e51c91ae963c833a4ccbab8d683c4a90c98
|
||||
method: POST
|
||||
url: /api/get-token
|
||||
extract:
|
||||
token: content.token
|
||||
validate:
|
||||
- eq: [status_code, 200]
|
||||
- eq: [headers.Content-Type, application/json]
|
||||
- eq: [content.success, true]
|
||||
|
||||
- test:
|
||||
name: /api/users/$user_id
|
||||
variables:
|
||||
device_sn: FwgRiO7CNA50DSU
|
||||
user_id: 1000
|
||||
request:
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
User-Agent: python-requests/2.18.4
|
||||
device_sn: $device_sn
|
||||
token: $token
|
||||
json:
|
||||
name: user1
|
||||
password: '123456'
|
||||
method: POST
|
||||
url: /api/users/$user_id
|
||||
validate:
|
||||
- eq: [status_code, 201]
|
||||
- eq: [headers.Content-Type, application/json]
|
||||
- eq: [content.success, true]
|
||||
- eq: [content.msg, user created successfully.]
|
||||
70
docs/data/demo-quickstart-5.json
Normal file
70
docs/data/demo-quickstart-5.json
Normal file
@@ -0,0 +1,70 @@
|
||||
[
|
||||
{
|
||||
"config": {
|
||||
"name": "testcase description",
|
||||
"base_url": "http://127.0.0.1:5000",
|
||||
"variables": {
|
||||
"device_sn": "FwgRiO7CNA50DSU"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "/api/get-token",
|
||||
"variables": {
|
||||
"os_platform": "ios",
|
||||
"app_version": "2.8.6"
|
||||
},
|
||||
"request": {
|
||||
"url": "/api/get-token",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"User-Agent": "python-requests/2.18.4",
|
||||
"device_sn": "$device_sn",
|
||||
"os_platform": "$os_platform",
|
||||
"app_version": "$app_version",
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"sign": "9c0c7e51c91ae963c833a4ccbab8d683c4a90c98"
|
||||
}
|
||||
},
|
||||
"extract": [
|
||||
{"token": "content.token"}
|
||||
],
|
||||
"validate": [
|
||||
{"eq": ["status_code", 200]},
|
||||
{"eq": ["headers.Content-Type", "application/json"]},
|
||||
{"eq": ["content.success", true]}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "/api/users/$user_id",
|
||||
"variables": {
|
||||
"user_id": "1000"
|
||||
},
|
||||
"request": {
|
||||
"url": "/api/users/$user_id",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"User-Agent": "python-requests/2.18.4",
|
||||
"device_sn": "$device_sn",
|
||||
"token": "$token",
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"validate": [
|
||||
{"eq": ["status_code", 201]},
|
||||
{"eq": ["headers.Content-Type", "application/json"]},
|
||||
{"eq": ["content.success", true]},
|
||||
{"eq": ["content.msg", "user created successfully."]}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
49
docs/data/demo-quickstart-5.yml
Normal file
49
docs/data/demo-quickstart-5.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
- config:
|
||||
name: testcase description
|
||||
base_url: http://127.0.0.1:5000
|
||||
variables:
|
||||
device_sn: FwgRiO7CNA50DSU
|
||||
|
||||
- test:
|
||||
name: /api/get-token
|
||||
variables:
|
||||
app_version: 2.8.6
|
||||
os_platform: ios
|
||||
request:
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
User-Agent: python-requests/2.18.4
|
||||
app_version: $app_version
|
||||
device_sn: $device_sn
|
||||
os_platform: $os_platform
|
||||
json:
|
||||
sign: 9c0c7e51c91ae963c833a4ccbab8d683c4a90c98
|
||||
method: POST
|
||||
url: /api/get-token
|
||||
extract:
|
||||
token: content.token
|
||||
validate:
|
||||
- eq: [status_code, 200]
|
||||
- eq: [headers.Content-Type, application/json]
|
||||
- eq: [content.success, true]
|
||||
|
||||
- test:
|
||||
name: /api/users/$user_id
|
||||
variables:
|
||||
user_id: 1000
|
||||
request:
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
User-Agent: python-requests/2.18.4
|
||||
device_sn: $device_sn
|
||||
token: $token
|
||||
json:
|
||||
name: user1
|
||||
password: '123456'
|
||||
method: POST
|
||||
url: /api/users/$user_id
|
||||
validate:
|
||||
- eq: [status_code, 201]
|
||||
- eq: [headers.Content-Type, application/json]
|
||||
- eq: [content.success, true]
|
||||
- eq: [content.msg, user created successfully.]
|
||||
70
docs/data/demo-quickstart-6.json
Normal file
70
docs/data/demo-quickstart-6.json
Normal file
@@ -0,0 +1,70 @@
|
||||
[
|
||||
{
|
||||
"config": {
|
||||
"name": "testcase description",
|
||||
"base_url": "http://127.0.0.1:5000",
|
||||
"variables": {
|
||||
"device_sn": "${gen_random_string(15)}"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "/api/get-token",
|
||||
"variables": {
|
||||
"os_platform": "ios",
|
||||
"app_version": "2.8.6"
|
||||
},
|
||||
"request": {
|
||||
"url": "/api/get-token",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"User-Agent": "python-requests/2.18.4",
|
||||
"device_sn": "$device_sn",
|
||||
"os_platform": "$os_platform",
|
||||
"app_version": "$app_version",
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"sign": "${get_sign($device_sn, $os_platform, $app_version)}"
|
||||
}
|
||||
},
|
||||
"extract": [
|
||||
{"token": "content.token"}
|
||||
],
|
||||
"validate": [
|
||||
{"eq": ["status_code", 200]},
|
||||
{"eq": ["headers.Content-Type", "application/json"]},
|
||||
{"eq": ["content.success", true]}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "/api/users/$user_id",
|
||||
"variables": {
|
||||
"user_id": "${gen_user_id()}"
|
||||
},
|
||||
"request": {
|
||||
"url": "/api/users/$user_id",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"User-Agent": "python-requests/2.18.4",
|
||||
"device_sn": "$device_sn",
|
||||
"token": "$token",
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"validate": [
|
||||
{"eq": ["status_code", 201]},
|
||||
{"eq": ["headers.Content-Type", "application/json"]},
|
||||
{"eq": ["content.success", true]},
|
||||
{"eq": ["content.msg", "user created successfully."]}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
49
docs/data/demo-quickstart-6.yml
Normal file
49
docs/data/demo-quickstart-6.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
- config:
|
||||
name: testcase description
|
||||
base_url: http://127.0.0.1:5000
|
||||
variables:
|
||||
device_sn: ${gen_random_string(15)}
|
||||
|
||||
- test:
|
||||
name: /api/get-token
|
||||
variables:
|
||||
app_version: 2.8.6
|
||||
os_platform: ios
|
||||
request:
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
User-Agent: python-requests/2.18.4
|
||||
app_version: $app_version
|
||||
device_sn: $device_sn
|
||||
os_platform: $os_platform
|
||||
json:
|
||||
sign: ${get_sign($device_sn, $os_platform, $app_version)}
|
||||
method: POST
|
||||
url: /api/get-token
|
||||
extract:
|
||||
token: content.token
|
||||
validate:
|
||||
- eq: [status_code, 200]
|
||||
- eq: [headers.Content-Type, application/json]
|
||||
- eq: [content.success, true]
|
||||
|
||||
- test:
|
||||
name: /api/users/$user_id
|
||||
variables:
|
||||
user_id: ${gen_user_id()}
|
||||
request:
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
User-Agent: python-requests/2.18.4
|
||||
device_sn: $device_sn
|
||||
token: $token
|
||||
json:
|
||||
name: user1
|
||||
password: '123456'
|
||||
method: POST
|
||||
url: /api/users/$user_id
|
||||
validate:
|
||||
- eq: [status_code, 201]
|
||||
- eq: [headers.Content-Type, application/json]
|
||||
- eq: [content.success, true]
|
||||
- eq: [content.msg, user created successfully.]
|
||||
13
docs/data/demo-quickstart-7.json
Normal file
13
docs/data/demo-quickstart-7.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"config": {
|
||||
"name": "create users with parameters"
|
||||
},
|
||||
"testcases": {
|
||||
"create user $user_id": {
|
||||
"testcase": "demo-quickstart-6.yml",
|
||||
"parameters": {
|
||||
"user_id": [1001, 1002, 1003, 1004]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
docs/data/demo-quickstart-7.yml
Normal file
8
docs/data/demo-quickstart-7.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
config:
|
||||
name: testcase description
|
||||
|
||||
testcases:
|
||||
create user $user_id:
|
||||
testcase: demo-quickstart-6.yml
|
||||
parameters:
|
||||
user_id: [1001, 1002, 1003, 1004]
|
||||
221
docs/data/demo-quickstart.har
Normal file
221
docs/data/demo-quickstart.har
Normal file
@@ -0,0 +1,221 @@
|
||||
{
|
||||
"log": {
|
||||
"version": "1.2",
|
||||
"creator": {
|
||||
"name": "Charles Proxy",
|
||||
"version": "4.2.1"
|
||||
},
|
||||
"entries": [
|
||||
{
|
||||
"startedDateTime": "2018-02-19T17:30:00.904+08:00",
|
||||
"time": 3,
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"url": "http://127.0.0.1:5000/api/get-token",
|
||||
"httpVersion": "HTTP/1.1",
|
||||
"cookies": [],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Host",
|
||||
"value": "127.0.0.1:5000"
|
||||
},
|
||||
{
|
||||
"name": "User-Agent",
|
||||
"value": "python-requests/2.18.4"
|
||||
},
|
||||
{
|
||||
"name": "Accept-Encoding",
|
||||
"value": "gzip, deflate"
|
||||
},
|
||||
{
|
||||
"name": "Accept",
|
||||
"value": "*/*"
|
||||
},
|
||||
{
|
||||
"name": "Connection",
|
||||
"value": "keep-alive"
|
||||
},
|
||||
{
|
||||
"name": "device_sn",
|
||||
"value": "FwgRiO7CNA50DSU"
|
||||
},
|
||||
{
|
||||
"name": "os_platform",
|
||||
"value": "ios"
|
||||
},
|
||||
{
|
||||
"name": "app_version",
|
||||
"value": "2.8.6"
|
||||
},
|
||||
{
|
||||
"name": "Content-Length",
|
||||
"value": "52"
|
||||
},
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"queryString": [],
|
||||
"postData": {
|
||||
"mimeType": "application/json",
|
||||
"text": "{\"sign\": \"9c0c7e51c91ae963c833a4ccbab8d683c4a90c98\"}"
|
||||
},
|
||||
"headersSize": 299,
|
||||
"bodySize": 52
|
||||
},
|
||||
"response": {
|
||||
"_charlesStatus": "COMPLETE",
|
||||
"status": 200,
|
||||
"statusText": "OK",
|
||||
"httpVersion": "HTTP/1.0",
|
||||
"cookies": [],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"name": "Content-Length",
|
||||
"value": "46"
|
||||
},
|
||||
{
|
||||
"name": "Server",
|
||||
"value": "Werkzeug/0.14.1 Python/3.6.4"
|
||||
},
|
||||
{
|
||||
"name": "Date",
|
||||
"value": "Mon, 19 Feb 2018 09:30:00 GMT"
|
||||
},
|
||||
{
|
||||
"name": "Proxy-Connection",
|
||||
"value": "Close"
|
||||
}
|
||||
],
|
||||
"content": {
|
||||
"size": 46,
|
||||
"mimeType": "application/json",
|
||||
"text": "eyJzdWNjZXNzIjogdHJ1ZSwgInRva2VuIjogImJhTkxYMXpoRllQMTFTZWIifQ==",
|
||||
"encoding": "base64"
|
||||
},
|
||||
"redirectURL": null,
|
||||
"headersSize": 175,
|
||||
"bodySize": 46
|
||||
},
|
||||
"serverIPAddress": "127.0.0.1",
|
||||
"cache": {},
|
||||
"timings": {
|
||||
"dns": 1,
|
||||
"connect": 0,
|
||||
"ssl": -1,
|
||||
"send": 0,
|
||||
"wait": 1,
|
||||
"receive": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"startedDateTime": "2018-02-19T17:30:00.911+08:00",
|
||||
"time": 3,
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"url": "http://127.0.0.1:5000/api/users/1000",
|
||||
"httpVersion": "HTTP/1.1",
|
||||
"cookies": [],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Host",
|
||||
"value": "127.0.0.1:5000"
|
||||
},
|
||||
{
|
||||
"name": "User-Agent",
|
||||
"value": "python-requests/2.18.4"
|
||||
},
|
||||
{
|
||||
"name": "Accept-Encoding",
|
||||
"value": "gzip, deflate"
|
||||
},
|
||||
{
|
||||
"name": "Accept",
|
||||
"value": "*/*"
|
||||
},
|
||||
{
|
||||
"name": "Connection",
|
||||
"value": "keep-alive"
|
||||
},
|
||||
{
|
||||
"name": "device_sn",
|
||||
"value": "FwgRiO7CNA50DSU"
|
||||
},
|
||||
{
|
||||
"name": "token",
|
||||
"value": "baNLX1zhFYP11Seb"
|
||||
},
|
||||
{
|
||||
"name": "Content-Length",
|
||||
"value": "39"
|
||||
},
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"queryString": [],
|
||||
"postData": {
|
||||
"mimeType": "application/json",
|
||||
"text": "{\"name\": \"user1\", \"password\": \"123456\"}"
|
||||
},
|
||||
"headersSize": 265,
|
||||
"bodySize": 39
|
||||
},
|
||||
"response": {
|
||||
"_charlesStatus": "COMPLETE",
|
||||
"status": 201,
|
||||
"statusText": "CREATED",
|
||||
"httpVersion": "HTTP/1.0",
|
||||
"cookies": [],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"name": "Content-Length",
|
||||
"value": "54"
|
||||
},
|
||||
{
|
||||
"name": "Server",
|
||||
"value": "Werkzeug/0.14.1 Python/3.6.4"
|
||||
},
|
||||
{
|
||||
"name": "Date",
|
||||
"value": "Mon, 19 Feb 2018 09:30:00 GMT"
|
||||
},
|
||||
{
|
||||
"name": "Proxy-Connection",
|
||||
"value": "Close"
|
||||
}
|
||||
],
|
||||
"content": {
|
||||
"size": 54,
|
||||
"mimeType": "application/json",
|
||||
"text": "eyJzdWNjZXNzIjogdHJ1ZSwgIm1zZyI6ICJ1c2VyIGNyZWF0ZWQgc3VjY2Vzc2Z1bGx5LiJ9",
|
||||
"encoding": "base64"
|
||||
},
|
||||
"redirectURL": null,
|
||||
"headersSize": 77,
|
||||
"bodySize": 54
|
||||
},
|
||||
"serverIPAddress": "127.0.0.1",
|
||||
"cache": {},
|
||||
"timings": {
|
||||
"dns": 0,
|
||||
"connect": 0,
|
||||
"ssl": -1,
|
||||
"send": 0,
|
||||
"wait": 3,
|
||||
"receive": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
98
docs/data/demo-quickstart.json
Normal file
98
docs/data/demo-quickstart.json
Normal file
@@ -0,0 +1,98 @@
|
||||
[
|
||||
{
|
||||
"config": {
|
||||
"name": "testcase description",
|
||||
"variables": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "/api/get-token",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/get-token",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"User-Agent": "python-requests/2.18.4",
|
||||
"device_sn": "FwgRiO7CNA50DSU",
|
||||
"os_platform": "ios",
|
||||
"app_version": "2.8.6",
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"sign": "9c0c7e51c91ae963c833a4ccbab8d683c4a90c98"
|
||||
}
|
||||
},
|
||||
"validate": [
|
||||
{
|
||||
"eq": [
|
||||
"status_code",
|
||||
200
|
||||
]
|
||||
},
|
||||
{
|
||||
"eq": [
|
||||
"headers.Content-Type",
|
||||
"application/json"
|
||||
]
|
||||
},
|
||||
{
|
||||
"eq": [
|
||||
"content.success",
|
||||
true
|
||||
]
|
||||
},
|
||||
{
|
||||
"eq": [
|
||||
"content.token",
|
||||
"baNLX1zhFYP11Seb"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "/api/users/1000",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/users/1000",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"User-Agent": "python-requests/2.18.4",
|
||||
"device_sn": "FwgRiO7CNA50DSU",
|
||||
"token": "baNLX1zhFYP11Seb",
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"validate": [
|
||||
{
|
||||
"eq": [
|
||||
"status_code",
|
||||
201
|
||||
]
|
||||
},
|
||||
{
|
||||
"eq": [
|
||||
"headers.Content-Type",
|
||||
"application/json"
|
||||
]
|
||||
},
|
||||
{
|
||||
"eq": [
|
||||
"content.success",
|
||||
true
|
||||
]
|
||||
},
|
||||
{
|
||||
"eq": [
|
||||
"content.msg",
|
||||
"user created successfully."
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
55
docs/data/demo-quickstart.yml
Normal file
55
docs/data/demo-quickstart.yml
Normal file
@@ -0,0 +1,55 @@
|
||||
- config:
|
||||
name: testcase description
|
||||
variables: {}
|
||||
- test:
|
||||
name: /api/get-token
|
||||
request:
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
User-Agent: python-requests/2.18.4
|
||||
app_version: 2.8.6
|
||||
device_sn: FwgRiO7CNA50DSU
|
||||
os_platform: ios
|
||||
json:
|
||||
sign: 9c0c7e51c91ae963c833a4ccbab8d683c4a90c98
|
||||
method: POST
|
||||
url: http://127.0.0.1:5000/api/get-token
|
||||
validate:
|
||||
- eq:
|
||||
- status_code
|
||||
- 200
|
||||
- eq:
|
||||
- headers.Content-Type
|
||||
- application/json
|
||||
- eq:
|
||||
- content.success
|
||||
- true
|
||||
- eq:
|
||||
- content.token
|
||||
- baNLX1zhFYP11Seb
|
||||
- test:
|
||||
name: /api/users/1000
|
||||
request:
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
User-Agent: python-requests/2.18.4
|
||||
device_sn: FwgRiO7CNA50DSU
|
||||
token: baNLX1zhFYP11Seb
|
||||
json:
|
||||
name: user1
|
||||
password: '123456'
|
||||
method: POST
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
validate:
|
||||
- eq:
|
||||
- status_code
|
||||
- 201
|
||||
- eq:
|
||||
- headers.Content-Type
|
||||
- application/json
|
||||
- eq:
|
||||
- content.success
|
||||
- true
|
||||
- eq:
|
||||
- content.msg
|
||||
- user created successfully.
|
||||
27
docs/data/demo-testcase-get-token.yml
Normal file
27
docs/data/demo-testcase-get-token.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
- config:
|
||||
name: get token
|
||||
base_url: http://127.0.0.1:5000
|
||||
variables:
|
||||
device_sn: ${gen_random_string(15)}
|
||||
os_platform: 'ios'
|
||||
app_version: '2.8.6'
|
||||
|
||||
- test:
|
||||
name: get token with $device_sn, $os_platform, $app_version
|
||||
request:
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
User-Agent: python-requests/2.18.4
|
||||
app_version: $app_version
|
||||
device_sn: $device_sn
|
||||
os_platform: $os_platform
|
||||
json:
|
||||
sign: ${get_sign($device_sn, $os_platform, $app_version)}
|
||||
method: POST
|
||||
url: /api/get-token
|
||||
extract:
|
||||
token: content.token
|
||||
validate:
|
||||
- eq: [status_code, 200]
|
||||
- eq: [headers.Content-Type, application/json]
|
||||
- eq: [content.success, true]
|
||||
34
docs/data/demo_parameters.yml
Normal file
34
docs/data/demo_parameters.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
- config:
|
||||
name: "user management testcase."
|
||||
parameters:
|
||||
- user_agent: ["iOS/10.1", "iOS/10.2", "iOS/10.3"]
|
||||
- app_version: ${P(app_version.csv)}
|
||||
- os_platform: ${get_os_platform()}
|
||||
variables:
|
||||
- user_agent: 'iOS/10.3'
|
||||
- device_sn: ${gen_random_string(15)}
|
||||
- os_platform: 'ios'
|
||||
- app_version: '2.8.6'
|
||||
request:
|
||||
base_url: http://127.0.0.1:5000
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
device_sn: $device_sn
|
||||
|
||||
- test:
|
||||
name: get token with $user_agent, $os_platform, $app_version
|
||||
request:
|
||||
url: /api/get-token
|
||||
method: POST
|
||||
headers:
|
||||
app_version: $app_version
|
||||
os_platform: $os_platform
|
||||
user_agent: $user_agent
|
||||
json:
|
||||
sign: ${get_sign($user_agent, $device_sn, $os_platform, $app_version)}
|
||||
extract:
|
||||
- token: content.token
|
||||
validate:
|
||||
- eq: [status_code, 200]
|
||||
- eq: [headers.Content-Type, application/json]
|
||||
- eq: [content.success, true]
|
||||
1
docs/data/testerhome-login.har
Normal file
1
docs/data/testerhome-login.har
Normal file
File diff suppressed because one or more lines are too long
66
docs/data/testerhome-login.yml
Normal file
66
docs/data/testerhome-login.yml
Normal file
@@ -0,0 +1,66 @@
|
||||
- config:
|
||||
name: testcase description
|
||||
variables: {}
|
||||
verify: False
|
||||
|
||||
- test:
|
||||
name: /account/sign_in
|
||||
request:
|
||||
headers:
|
||||
If-None-Match: W/"bc9ae267fdcbd89bf1dfaea10dea2b0e"
|
||||
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36
|
||||
(KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
|
||||
method: GET
|
||||
url: https://testerhome.com/account/sign_in
|
||||
extract:
|
||||
X_CSRF_Token: <meta name="csrf-token" content="(.*)" />
|
||||
validate:
|
||||
- eq: [status_code, 200]
|
||||
- eq: [headers.Content-Type, text/html; charset=utf-8]
|
||||
|
||||
- test:
|
||||
name: /assets/big_logo-cd32144f74c18746f3dce33e1040e7dfe4c07c8e611e37f3868b1c16b5095da3.png
|
||||
request:
|
||||
headers:
|
||||
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36
|
||||
(KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
|
||||
method: GET
|
||||
url: https://testerhome.com/assets/big_logo-cd32144f74c18746f3dce33e1040e7dfe4c07c8e611e37f3868b1c16b5095da3.png
|
||||
validate:
|
||||
- eq: [status_code, 200]
|
||||
- eq: [headers.Content-Type, image/png]
|
||||
|
||||
- test:
|
||||
name: /account/sign_in
|
||||
request:
|
||||
data:
|
||||
commit: Sign In
|
||||
user[login]: debugtalk
|
||||
user[password]: XXXXXXXX
|
||||
user[remember_me]: '1'
|
||||
utf8: ✓
|
||||
headers:
|
||||
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
|
||||
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36
|
||||
(KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
|
||||
X-CSRF-Token: $X_CSRF_Token
|
||||
X-Requested-With: XMLHttpRequest
|
||||
method: POST
|
||||
url: https://testerhome.com/account/sign_in
|
||||
validate:
|
||||
- eq: [status_code, 200]
|
||||
- eq: [headers.Content-Type, text/javascript; charset=utf-8]
|
||||
|
||||
- test:
|
||||
name: /
|
||||
request:
|
||||
headers:
|
||||
If-None-Match: W/"bad62c68dac27b01151516aad5c7f0be"
|
||||
Turbolinks-Referrer: https://testerhome.com/account/sign_in
|
||||
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36
|
||||
(KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
|
||||
method: GET
|
||||
url: https://testerhome.com/
|
||||
validate:
|
||||
- eq: [status_code, 200]
|
||||
- eq: [headers.Content-Type, text/html; charset=utf-8]
|
||||
5
docs/data/user_id.csv
Normal file
5
docs/data/user_id.csv
Normal file
@@ -0,0 +1,5 @@
|
||||
user_id
|
||||
1001
|
||||
1002
|
||||
1003
|
||||
1004
|
||||
|
Reference in New Issue
Block a user