Files
apiautotest/interface/gitlink/test_login.yaml

125 lines
3.4 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 公共参数
case_common:
allure_epic: GitLink接口 # 敏捷里面的概念定义史诗相当于module级的标签, 往下是 feature
allure_feature: 登录模块 # 功能点的描述相当于class级的标签, 理解成模块往下是 story
allure_story: 登录接口 # 故事可以理解为场景相当于method级的标签, 往下是 title
case_markers: # pytest框架的标记 pytest.mark.
- gitlink
- login: 登录接口
# 用例数据
case_info:
-
id: gitlink_login_01
title: 用户名密码正确,登录成功(不校验数据库)
run: True
severity: normal
url: /api/accounts/login.json
method: POST
headers:
Content-Type: application/json; charset=utf-8;
cookies:
request_type: json
payload:
login: ${login}
password: ${password}
autologin: 1
files:
assert_response:
status_code: 200
user_id:
message: 断言接口返回的user_id
expect_value: ${user_id}
assert_type: ==
type_jsonpath: $.user_id
login:
message: 断言接口返回的login
expect_value: ${login}
assert_type: ==
type_jsonpath: $.login
assert_sql:
extract:
type_re:
nickname: \"username":"(.*?)"
login: \"login":"(.*?)"
user_id: \"user_id":(.*?),
type_response:
cookies: response.cookies
-
id: case_login_02
title: 用户名密码正确,登录成功(校验数据库)
run: false
severity: minor
url: /api/accounts/login.json
method: POST
headers:
Content-Type: application/json; charset=utf-8;
cookies:
request_type: json
payload:
login: ${login}
password: ${password}
autologin: 1
files:
assert_response:
status_code: 200
user_id:
expect_value: ${user_id}
assert_type: ==
type_jsonpath: $.user_id
login:
message: 断言接口返回的login
expect_value: ${login}
assert_type: ==
type_jsonpath: $.login
assert_sql:
contains_user:
message: 断言数据库查询tokens表表中存在该登录用户记录预期查询结果的长度为1
sql: select * from tokens where user_id=${user_id};
expect_value: 1
assert_type: len_eq
contains_user2:
message: 断言数据库查询tokens表表中存在该登录用户记录;预期 ${user_id} in 查询结果jsonpath式匹配后的结果
sql: select * from tokens where user_id=${user_id};
type_jsonpath: $..user_id
expect_value: ${user_id}
assert_type: ==
contains_user3:
message: 断言数据库查询tokens表表中存在该登录用户记录预期 ${user_id} in 查询结果(正则表达式匹配后的结果)
sql: select * from tokens;
type_re: "'user_id': (.*?),"
expect_value: ${user_id}
assert_type: contains
extract:
type_jsonpath:
nickname: $.username
login: $.login
user_id: $.user_id
-
id: case_login_03
title: 用户名正确,密码错误,登录失败
severity: critical
run: true
url: /api/accounts/login.json
method: POST
headers:
Content-Type: application/json; charset=utf-8;
cookies:
request_type: json
payload:
login: ${login}
password: 12345678900
autologin: 1
files:
assert_response:
status_code: 200
user_id:
message: 断言接口返回的status
expect_value: -2
assert_type: ==
type_jsonpath: $.status
assert_sql:
extract: