11 changed files with 146 additions and 40 deletions
Unified View
Diff Options
-
2DA_data.yaml
-
10Login/DA_data.yaml
-
20Login/Login-interface.robot
-
2Login/phone-test.txt
-
92Login/resource.robot
-
2LoginUI/Login.robot
-
0LoginUI/LoginResource.robot
-
0LoginUI/__init__.robot
-
5WriteInfo/DA_data.yaml
-
23WriteInfo/InfoResource.robot
-
30WriteInfo/Infomation.robot
@ -0,0 +1,10 @@ |
|||||
|
婚介: |
||||
|
dating域名: https://dating-agency-api-test.qniao.cn |
||||
|
Client域名: |
||||
|
CHeader: {'Content-Type':'application/json','X-APP-ID':'50325897884795880'} |
||||
|
AHeader: {'Content-Type':'application/json','X-APP-ID':'50325897884795881'} |
||||
|
|
||||
|
|
||||
|
用户: |
||||
|
手机号: 15014242835 |
||||
|
验证码: 888888 |
||||
@ -0,0 +1,20 @@ |
|||||
|
*** Settings *** |
||||
|
Documentation 接口:短信验证码登录认证 |
||||
|
Suite Setup Import Variables ${CURDIR}\\DA_data.yaml |
||||
|
Resource resource.robot |
||||
|
|
||||
|
*** Test Cases *** |
||||
|
手机号验证码登录 |
||||
|
#登录婚介平台 |
||||
|
Given 读取TXT文件 |
||||
|
When 用户获取婚介平台短信验证码 |
||||
|
Then 数据库查询用户生效且未过期的验证码 |
||||
|
And 用户手机号验证码登录婚介平台 |
||||
|
And 查询用户的婚介组织 |
||||
|
|
||||
|
手机号验证码已过期登录 |
||||
|
#验证码已过期 |
||||
|
Given 读取TXT文件 |
||||
|
When 用户获取婚介平台短信验证码 |
||||
|
Then 数据库查询用户生效且已过期的验证码 |
||||
|
And 用户手机号验证码登录婚介平台 |
||||
@ -0,0 +1,2 @@ |
|||||
|
手机号 |
||||
|
19128859944 |
||||
@ -0,0 +1,92 @@ |
|||||
|
*** Settings *** |
||||
|
Library urllib3 |
||||
|
Library String |
||||
|
Library DateTime |
||||
|
Library Collections |
||||
|
Library RequestsLibrary |
||||
|
Library DatabaseLibrary |
||||
|
Library OperatingSystem |
||||
|
|
||||
|
*** Keywords *** |
||||
|
读取TXT文件 |
||||
|
#读取TXT文件 |
||||
|
${file} Get File ${CURDIR}\\phone-test.txt #读取文件 |
||||
|
${skip-line} Set Variable 1 #跳过第一行 |
||||
|
${lines} Set Variable -1 #读取整个文件,从第二行开始 |
||||
|
${content} Get Lines Containing String ${file} ${skip-line} ${lines} |
||||
|
FOR ${id} IN ${content} |
||||
|
${id} String.Split String ${id} \n |
||||
|
END |
||||
|
Set Global Variable ${id} |
||||
|
|
||||
|
用户获取${dating}平台短信验证码 |
||||
|
#用户获取婚介平台短信验证码 |
||||
|
Disable Warnings |
||||
|
FOR ${account} IN @{id} |
||||
|
Create Session dating ${${dating}.dating域名} ${${dating}.AHeader} |
||||
|
${data} Set Variable { \ \ \ \ "purpose": 1, \ \ \ \ "verifiableAccount": "${account}", \ \ \ \ "verifiableAccountType": 1 } #获取短信验证码请求参数 |
||||
|
${reps} POST On Session dating /dating-agency-uec/authorize/get/auth-captcha ${data.encode('utf-8')} |
||||
|
${message} Get From Dictionary ${reps.json()} message #获取接口相应的message |
||||
|
END |
||||
|
Should Be Equal As Strings ${message} successful #断言是否相等 |
||||
|
Sleep 2 |
||||
|
|
||||
|
数据库查询用户生效且未过期的验证码 |
||||
|
#数据库中查询手机号验证码 |
||||
|
${captcha_list} Create List |
||||
|
FOR ${account} IN @{id} |
||||
|
${Time} Get Current Date result_format=%Y-%m-%d %H:%M:%S |
||||
|
Connect To Database Using Custom Params pymysql database='dating-agency-uec',user='root',password='qniaothreetwoonego',host='8.135.8.221' |
||||
|
${check} Query SELECT code FROM da_captcha WHERE verifiable_account = '${account}' AND status = 1 AND is_delete = 0 AND expired_time > '${Time}' #查询手机号获取的验证码 |
||||
|
${captcha} Set Variable ${check[0][0]} |
||||
|
Append To List ${captcha_list} ${captcha} |
||||
|
END |
||||
|
Disconnect From Database |
||||
|
Set Global Variable ${captcha} |
||||
|
Set Global Variable ${captcha_list} |
||||
|
|
||||
|
数据库查询用户生效且已过期的验证码 |
||||
|
#数据库中查询手机号验证码 |
||||
|
${captcha_list} Create List |
||||
|
FOR ${account} IN @{id} |
||||
|
${Time} Get Current Date result_format=%Y-%m-%d %H:%M:%S |
||||
|
Connect To Database Using Custom Params pymysql database='dating-agency-uec',user='root',password='qniaothreetwoonego',host='8.135.8.221' |
||||
|
${check} Query SELECT code FROM da_captcha WHERE verifiable_account = '${account}' AND status = 1 AND is_delete = 0 AND expired_time < '${Time}' #查询手机号获取的验证码 |
||||
|
${captcha} Set Variable ${check[0][0]} |
||||
|
Append To List ${captcha_list} ${captcha} |
||||
|
END |
||||
|
Disconnect From Database |
||||
|
Set Global Variable ${captcha} |
||||
|
Set Global Variable ${captcha_list} |
||||
|
|
||||
|
依次获取验证码 |
||||
|
#多用户时依次获取对应的验证码 |
||||
|
FOR ${captcha} IN @{captcha_list} |
||||
|
Set Global Variable ${captcha} |
||||
|
END |
||||
|
|
||||
|
用户手机号验证码登录${dating}平台 |
||||
|
#用户手机号验证码登录婚介平台 |
||||
|
FOR ${account} IN @{id} |
||||
|
Disable Warnings |
||||
|
Create Session dating ${${dating}.dating域名} ${${dating}.AHeader} |
||||
|
${data} Set Variable { \ \ "account":"${account}", \ \ "accountType":2, \ \ "captcha":"${captcha}" } #手机号验证码登录参数 |
||||
|
${reps} POST On Session dating /dating-agency-uec/authorize/by-captcha ${data.encode('utf-8')} |
||||
|
${code} Get From Dictionary ${reps.json()} code #获取相应状态码 |
||||
|
${token} Get From Dictionary ${reps.json()['data']} token #获取token |
||||
|
${userId} Get From Dictionary ${reps.json()['data']} userId #获取用户id |
||||
|
${message} Get From Dictionary ${reps.json()} message |
||||
|
${login_header} Set Variable {'Content-Type':'application/json','X-APP-ID':'50325897884795881','Authorization':'QNT ${token}'} #更新header |
||||
|
Run Keyword If ${code}==0 Should Be Equal As Strings ${message} successful |
||||
|
... ELSE Should Be Equal As Strings ${message} 验证码错误或无效验证码,请重试! |
||||
|
END |
||||
|
Set Global Variable ${userId} |
||||
|
Set Global Variable ${login_header} |
||||
|
|
||||
|
查询用户的${dating}组织 |
||||
|
#查询用户在婚介的组织数据 |
||||
|
Disable Warnings |
||||
|
Create Session dating ${${dating}.dating域名} ${login_header} |
||||
|
${reps} GET On Session dating /dating-agency-uec/user/list/own-organization params=userId=${userid} |
||||
|
${message} Get From Dictionary ${reps.json()} message |
||||
|
Should Be Equal As Strings ${message} successful |
||||
Write
Preview
Loading…
Cancel
Save