Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
InterfaceAutoTest
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TestAuto
InterfaceAutoTest
Commits
6e0b252f
Commit
6e0b252f
authored
Jul 20, 2021
by
taoke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调试企业云登录
parent
96e6d581
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
38 deletions
+12
-38
config.py
+1
-1
run.py
+0
-0
service/login.py
+6
-6
test_case/bmy/test_login.py
+5
-31
test_case_data/bmy/bmy_case.xlsx
+0
-0
No files found.
config.py
View file @
6e0b252f
...
@@ -113,7 +113,7 @@ class BmyConfig(BaseConfig):
...
@@ -113,7 +113,7 @@ class BmyConfig(BaseConfig):
# 测试环境host
# 测试环境host
test_host
=
"http://testyun.banmago.com/api"
test_host
=
"http://testyun.banmago.com/api"
# 登录账号
# 登录账号
test_name_password
=
{
"username"
:
"15151500000"
,
"password"
:
"bmy123456"
}
test_name_password
=
{
"username"
:
"15151500000"
,
"password"
:
"bmy123456"
,
"Register-Origin"
:
"yun"
}
# 企业云接口的Authorization
# 企业云接口的Authorization
bmy_token
=
''
bmy_token
=
''
headers
=
{
"Content-Type"
:
"application/json"
}
headers
=
{
"Content-Type"
:
"application/json"
}
...
...
run.py
View file @
6e0b252f
service/login.py
View file @
6e0b252f
...
@@ -64,7 +64,7 @@ class BMY():
...
@@ -64,7 +64,7 @@ class BMY():
"""企业云登录"""
"""企业云登录"""
# token加密
# token加密
authorization
=
BMY
()
.
get_authorization
()
authorization
=
BMY
()
.
get_authorization
()
header
=
{
"Authorization"
:
authorization
}
header
=
{
"Authorization"
:
authorization
,
"Register-Origin"
:
indata
[
'Register-Origin'
]
}
payload
=
{
"username"
:
""
,
"password"
:
""
,
"imageId"
:
""
,
"grant_type"
:
"passwordImageCode"
,
"imageCode"
:
""
}
payload
=
{
"username"
:
""
,
"password"
:
""
,
"imageId"
:
""
,
"grant_type"
:
"passwordImageCode"
,
"imageCode"
:
""
}
# 账号
# 账号
payload
[
'username'
]
=
indata
[
'username'
]
payload
[
'username'
]
=
indata
[
'username'
]
...
@@ -113,8 +113,8 @@ class BMC():
...
@@ -113,8 +113,8 @@ class BMC():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
# indata= {"username":"15150000000","password":"A123456
"}
indata
=
{
"username"
:
"15150000000"
,
"password"
:
"A123456"
,
"Register-Origin"
:
"yun
"
}
#
token= BMY().bmy_login(indata,getToken=False)
token
=
BMY
()
.
bmy_login
(
indata
,
getToken
=
False
)
#
print(token)
print
(
token
)
LIST1
=
BMY
()
.
get_imageCode
(
'15150000000'
,
'8e4b595babec901009ff84f269ee5147'
)
#
LIST1=BMY().get_imageCode( '15150000000', '8e4b595babec901009ff84f269ee5147')
print
(
LIST1
)
#
print(LIST1)
test_case/bmy/test_login.py
View file @
6e0b252f
...
@@ -8,6 +8,7 @@ from common.utils.getExcelData import get_excelData
...
@@ -8,6 +8,7 @@ from common.utils.getExcelData import get_excelData
from
service.login
import
BMY
from
service.login
import
BMY
from
common.tools
import
request_main
from
common.tools
import
request_main
from
config
import
BmyConfig
from
config
import
BmyConfig
from
service.login
import
BMY
@allure.epic
(
"登录模块"
)
@allure.epic
(
"登录模块"
)
...
@@ -20,39 +21,12 @@ class TestLogin():
...
@@ -20,39 +21,12 @@ class TestLogin():
@allure.testcase
(
"http://yapi.hikcreate.com/"
)
@allure.testcase
(
"http://yapi.hikcreate.com/"
)
@allure.description
(
"url:/auth/login 。。。。"
)
@allure.description
(
"url:/auth/login 。。。。"
)
@pytest.mark.parametrize
(
"inData"
,
get_excelData
(
workBook
,
'登录模块'
,
'Login'
))
@pytest.mark.parametrize
(
"inData"
,
get_excelData
(
workBook
,
'登录模块'
,
'Login'
))
def
test_login
(
self
,
inData
):
url
=
f
"{BmyConfig().test_host}{inData['url']}"
method
=
inData
[
'method'
]
req_data
=
inData
[
'reqData'
]
expectData
=
inData
[
'expectData'
]
headers
=
inData
[
'headers'
]
"""处理"""
req_data
[
'grant_type'
]
=
"passwordImageCode"
# 请求体中的固定值
authorization
=
BMY
()
.
get_authorization
()
# 获取当前时间戳的Authorization
headers
[
"Authorization"
]
=
authorization
password_Encrypted
=
BMY
()
.
pwd_encrypted
(
req_data
[
'password'
])
# 密码加密
req_data
[
'password'
]
=
password_Encrypted
imageinfo
=
BMY
()
.
get_imageCode
(
req_data
[
'username'
],
req_data
[
'password'
])
# 获取图片信息
req_data
[
'imageId'
]
=
imageinfo
[
0
]
req_data
[
'imageCode'
]
=
imageinfo
[
1
]
# """请求"""
# res = request_main(url, headers, method, req_data)
# # print(res)
# """断言"""
# assert res['code'] == expectData['code']
""" 请求和断言若不使用通用方法"""
def
test_login
(
self
,
inData
):
res
=
requests
.
post
(
f
"http://testyun.banmago.com/api{url}"
,
data
=
req_data
,
headers
=
headers
)
res
=
BMY
()
.
bmy_login
(
inData
[
'reqData'
],
getToken
=
False
)
print
(
"我是headers"
,
headers
)
# print(res)
print
(
"我是data"
,
req_data
)
assert
res
[
'code'
]
==
inData
[
'expectData'
][
'code'
]
print
(
res
.
json
())
assert
res
.
json
()[
'code'
]
==
expectData
[
'code'
]
def
teardown_class
(
self
):
"""清除"""
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
for
one
in
os
.
listdir
(
'../../report/tmp'
):
# 列出对应文件夹的数据
for
one
in
os
.
listdir
(
'../../report/tmp'
):
# 列出对应文件夹的数据
...
...
test_case_data/bmy/bmy_case.xlsx
View file @
6e0b252f
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment