From e18aa9072370b85a023270b9059fc4753d4c8a9c Mon Sep 17 00:00:00 2001 From: LG_lai Date: Tue, 12 Mar 2024 16:16:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=9A=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81=E7=99=BB=E5=BD=95=E8=AE=A4=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DA_data.yaml | 2 +- Login/DA_data.yaml | 10 +++ Login/Login-interface.robot | 20 ++++++ Login/phone-test.txt | 2 + Login/resource.robot | 92 ++++++++++++++++++++++++++ {Login => LoginUI}/Login.robot | 2 +- {Login => LoginUI}/LoginResource.robot | 0 {Login => LoginUI}/__init__.robot | 0 WriteInfo/DA_data.yaml | 5 +- WriteInfo/InfoResource.robot | 23 ++----- WriteInfo/Infomation.robot | 30 +++------ 11 files changed, 146 insertions(+), 40 deletions(-) create mode 100644 Login/DA_data.yaml create mode 100644 Login/Login-interface.robot create mode 100644 Login/phone-test.txt create mode 100644 Login/resource.robot rename {Login => LoginUI}/Login.robot (95%) rename {Login => LoginUI}/LoginResource.robot (100%) rename {Login => LoginUI}/__init__.robot (100%) diff --git a/DA_data.yaml b/DA_data.yaml index 4d13c6c..ac7c17c 100644 --- a/DA_data.yaml +++ b/DA_data.yaml @@ -1,6 +1,6 @@ 婚介: UEC域名: http://dating-agency-api-test.qniao.cn - Header: {'Content-Type':'application/json','X-APP-ID':'50325897884795880'} + Header: {'Content-Type':'application/json','X-APP-ID':'50325897884795880','Authorization':'iHP4V/g6O5DXHixyNrf7tqm9NQUY2iykUwyijwv+6CYAmPXOz5yLZBPGAo6w2T84i0dM06R0EX8AG62EJziGfg=='} Admin_Header: {'Content-Type':'application/json','X-APP-ID':'50325897884795880'} diff --git a/Login/DA_data.yaml b/Login/DA_data.yaml new file mode 100644 index 0000000..c48254c --- /dev/null +++ b/Login/DA_data.yaml @@ -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 \ No newline at end of file diff --git a/Login/Login-interface.robot b/Login/Login-interface.robot new file mode 100644 index 0000000..a739f0a --- /dev/null +++ b/Login/Login-interface.robot @@ -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 用户手机号验证码登录婚介平台 diff --git a/Login/phone-test.txt b/Login/phone-test.txt new file mode 100644 index 0000000..443de94 --- /dev/null +++ b/Login/phone-test.txt @@ -0,0 +1,2 @@ +手机号 +19128859944 \ No newline at end of file diff --git a/Login/resource.robot b/Login/resource.robot new file mode 100644 index 0000000..c543bfa --- /dev/null +++ b/Login/resource.robot @@ -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 diff --git a/Login/Login.robot b/LoginUI/Login.robot similarity index 95% rename from Login/Login.robot rename to LoginUI/Login.robot index b01a7a1..231ce35 100644 --- a/Login/Login.robot +++ b/LoginUI/Login.robot @@ -21,4 +21,4 @@ WLogin open Given 读取TXT文件 - Then 数据库操作 + #Then 数据库操作 diff --git a/Login/LoginResource.robot b/LoginUI/LoginResource.robot similarity index 100% rename from Login/LoginResource.robot rename to LoginUI/LoginResource.robot diff --git a/Login/__init__.robot b/LoginUI/__init__.robot similarity index 100% rename from Login/__init__.robot rename to LoginUI/__init__.robot diff --git a/WriteInfo/DA_data.yaml b/WriteInfo/DA_data.yaml index 013bb02..763f3a5 100644 --- a/WriteInfo/DA_data.yaml +++ b/WriteInfo/DA_data.yaml @@ -1,7 +1,8 @@ 婚介: - UEC域名: https://dating-agency-api-test.qniao.cn + dating域名: https://dating-agency-api-test.qniao.cn Client域名: - Header: {'Content-Type':'application/json','X-APP-ID':'50325897884795880'} + CHeader: {'Content-Type':'application/json','X-APP-ID':'50325897884795880'} + AHeader: {'Content-Type':'application/json','X-APP-ID':'50325897884795881'} diff --git a/WriteInfo/InfoResource.robot b/WriteInfo/InfoResource.robot index 1f70670..57f9221 100644 --- a/WriteInfo/InfoResource.robot +++ b/WriteInfo/InfoResource.robot @@ -12,8 +12,9 @@ Library OperatingSystem 用户首次填写${dating}资料 Disable Warnings #获取首次婚介资料信息 + Import Variables ${CURDIR}\\DA_data.yaml Create Session dating ${${dating}.UEC域名} ${${dating}.Header} - ${reps} GET On Session dating /dating-agency-service/user/get/first/fill/marriage/information/details params=userId=808374438260248576 + ${reps} GET On Session dating /dating-agency-service/user/get/first/fill/marriage/information/details params=userId=8576 ${Data} Get From Dictionary ${reps.json()} data log ${Data} ${id} Get From Dictionary ${reps.json()['data']} id #资料id @@ -31,7 +32,6 @@ Library OperatingSystem ${educationCode} Get From Dictionary ${reps.json()['data']} educationCode #证婚人学历编码 ${fillSerialNumber} Get From Dictionary ${reps.json()['data']} fillSerialNumber #资料填写序号 ${maritalStatusCode} Get From Dictionary ${reps.json()['data']} maritalStatusCode #证婚人婚姻状况,0:未婚,1:离异,2:丧偶的 0:未婚,1:离异,2:丧偶的 - #${Information} Create Dictionary Set Global Variable ${id} Set Global Variable ${Data} Set Global Variable ${height} @@ -218,19 +218,8 @@ Library OperatingSystem ${id} Get From Dictionary ${reps.json()} data Should Be Equal ${id} ${DataId} -返回上一步 - -测试${dating}资料填写 - #选择性别 +查询首次填写的${dating}资料信息 + #获取用户首次填写的资料 Create Session dating ${${dating}.UEC域名} ${${dating}.Header} - ${sex_data} Evaluate 1 - ${data} Set Variable {"id":null,"fillSerialNumber":0,"genderCode":1} - ${reps} POST On Session dating dating-agency-service/user/save/first/fill/marriage/Information ${data.encode('utf-8')} - ${id} Get From Dictionary ${reps.json()} data - #选择城市 - ${city_data} Set Variable { \ \ \ \ "id": "${id}", \ \ \ \ "fillSerialNumber": 1, \ \ \ \ "provinceCode": 440000, \ \ \ \ "provinceName": "广东省", \ \ \ \ "cityCode": 440100, \ \ \ \ "cityName": "广州市", \ \ \ \ "districtCode": 440106, \ \ \ \ "districtName": "天河区" } - ${reps} POST On Session dating dating-agency-service/user/save/first/fill/marriage/Information ${city_data.encode('utf-8')} - sleep 2 - #获取首次婚介资料信息 - ${reps} GET On Session dating dating-agency-service/user/get/first/fill/marriage/information/details params=userId=808374438260248576 - log ${reps.json()['data']} + ${reps} GET On Session dating /dating-agency-service/user/get/first/fill/marriage/information/details params=userId=8576 + ${} diff --git a/WriteInfo/Infomation.robot b/WriteInfo/Infomation.robot index aba1e3b..8d23f31 100644 --- a/WriteInfo/Infomation.robot +++ b/WriteInfo/Infomation.robot @@ -6,16 +6,16 @@ Library Collections Library RequestsLibrary *** Test Cases *** -Info - Given 用户打开小程序 - Then 选择${dating}性别资料 - And 选择${dating}证婚人的城市 - And 选择${dating}征婚人的出生年份 - And 选择${dating}征婚人的身高 - And 选择${dating}征婚人的学历 - And 选择${dating}征婚人的婚姻状况 - And 月收入 - And 选择${dating}征婚人的昵称 +WritebaseInfo + Given 用户首次填写婚介资料 + Then 选择婚介性别资料 + And 选择婚介征婚人的城市 + And 选择婚介征婚人的出生年份 + And 选择婚介征婚人的身高 + And 选择婚介征婚人的学历 + And 选择婚介征婚人的婚姻状况 + And 选择婚介征婚人的婚姻状况 + And 选择婚介征婚人的昵称 sex_info #选择性别 @@ -94,12 +94,4 @@ region Set Global Variable ${provinceName} test - Given 用户首次填写婚介资料 - Then 选择婚介性别资料 - And 选择婚介征婚人的城市 - And 选择婚介征婚人的出生年份 - And 选择婚介征婚人的身高 - And 选择婚介征婚人的学历 - And 选择婚介征婚人的婚姻状况 - And 选择婚介征婚人的婚姻状况 - And 选择婚介征婚人的昵称 + 查询首次填写的婚介资料信息