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
437dbb94
Commit
437dbb94
authored
Aug 06, 2021
by
xujianxue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增日志模块,新增应用管理模块,配置文件增加企业云oms配置
parent
57bf1f3f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
143 additions
and
6 deletions
+143
-6
config.py
+19
-0
service/login.py
+23
-3
test_case/bmy/conftest.py
+8
-2
test_case/bmy/test_ApplicationManagement.py
+52
-0
test_case/bmy/test_login.py
+2
-1
test_case/bmy/test_logrecord.py
+38
-0
test_case/bmy/test_riskMonitar.py
+1
-0
No files found.
config.py
View file @
437dbb94
...
...
@@ -119,6 +119,25 @@ class BmyConfig(BaseConfig):
headers
=
{
"Content-Type"
:
"application/json"
}
class
BmyomsConfig
(
BaseConfig
):
"""企业云oms的配置类"""
name
=
"bmyoms"
test_case_dir
=
"test_case/bmy/"
test_case_data_dir
=
"test_case_data/bmy/"
# 获取token和密码加密原始密钥
key
=
"Jv+h&c0A"
# 获取token 原始token
defaultToken
=
"Basic aHpjcF93ZWI6MTIzNDU2"
# 测试环境host
test_host
=
"http://testoms.banmago.com/api"
# 登录账号
test_name_password
=
{
"username"
:
"888888"
,
"password"
:
"bmy123456"
,
"grant_type"
:
"intranet"
}
# 企业云接口的Authorization
bmy_token
=
''
headers
=
{
"Content-Type"
:
"application/json"
,
"Authorization"
:
bmy_token
}
class
SSOConfig
(
BaseConfig
):
"""SSO配置类"""
...
...
service/login.py
View file @
437dbb94
...
...
@@ -6,7 +6,7 @@ from common.utils.encryption import Encryption
# from common.utils.getExcelData import get_excelData
from
common.tools
import
request_main
from
common.db
import
RedisString
from
config
import
BmyConfig
from
config
import
BmyConfig
,
BmyomsConfig
from
config
import
BMCConfig
...
...
@@ -86,6 +86,26 @@ class BMY():
else
:
return
resp
.
json
()
def
bmyoms_login
(
self
,
indata
,
getToken
=
True
):
"""企业云登录"""
# token加密
authorization
=
BMY
()
.
get_authorization
()
header
=
{
"Authorization"
:
authorization
}
payload
=
{
"username"
:
""
,
"password"
:
""
,
"grant_type"
:
"intranet"
}
# 账号
payload
[
'username'
]
=
indata
[
'username'
]
# 密码加密
password_Encrypted
=
BMY
()
.
pwd_encrypted
(
indata
[
'password'
])
payload
[
'password'
]
=
password_Encrypted
resp
=
requests
.
post
(
f
"{BmyomsConfig().test_host}/auth/login"
,
data
=
payload
,
headers
=
header
)
if
getToken
:
token
=
resp
.
json
()[
'data'
][
'token'
]
# 数据权限会藏在token中
return
BMY
()
.
get_authorization
(
defaultToken
=
token
)
else
:
return
resp
.
json
()
class
BMC
():
def
bmc_login
(
self
,
indata
):
"""斑马信用登录获取token"""
...
...
@@ -113,8 +133,8 @@ class BMC():
if
__name__
==
'__main__'
:
indata
=
{
"username"
:
"15150000000"
,
"password"
:
"A123456"
,
"Register-Origin"
:
"yun
"
}
token
=
BMY
()
.
bmy_login
(
indata
,
getToken
=
False
)
indata
=
{
"username"
:
"888888"
,
"password"
:
"bmy123456
"
}
token
=
BMY
()
.
bmyoms_login
(
indata
)
print
(
token
)
# LIST1=BMY().get_imageCode( '15150000000', '8e4b595babec901009ff84f269ee5147')
# print(LIST1)
test_case/bmy/conftest.py
View file @
437dbb94
...
...
@@ -3,15 +3,21 @@
#编码: -- coding: utf-8 --
#版本: !python3.7
from
service.login
import
BMY
from
config
import
BmyConfig
from
config
import
BmyConfig
,
BmyomsConfig
import
pytest
@pytest.fixture
(
scope
=
'module'
,
autouse
=
True
)
def
bmy_login
():
"""BMY登录获取token"""
res
=
BMY
()
.
bmy_login
(
BmyConfig
.
test_name_password
)
setattr
(
BmyConfig
,
'bmy_token'
,
res
)
setattr
(
BmyConfig
,
'bmy_token'
,
res
)
@pytest.fixture
(
scope
=
'module'
,
autouse
=
True
)
def
bmyoms_login
():
"""BMYoms登录获取token"""
res
=
BMY
()
.
bmyoms_login
(
BmyomsConfig
.
test_name_password
)
# setattr(object, name, value) object -- 对象。 name -- 字符串,对象属性。value -- 属性值。
setattr
(
BmyomsConfig
,
'bmy_token'
,
res
)
# BmyomsConfig这个类里面的的bmy_token这个变量的值设置为res
# res= BMY().get_authorization()
# setattr(BmyConfig, 'bmy_token', res)
test_case/bmy/test_ApplicationManagement.py
0 → 100644
View file @
437dbb94
import
pytest
,
allure
,
xlrd
,
requests
,
os
from
common.utils.getExcelData
import
get_excelData
from
service.login
import
BMY
from
common.tools
import
request_main
from
config
import
BmyomsConfig
from
service.login
import
BMY
#@allure.epic("斑马企业云oms")
@allure.feature
(
"应用管理"
)
class
TestApplicationManagement
():
workBook
=
xlrd
.
open_workbook
(
f
'{BmyomsConfig.root_path}/test_case_data/bmy/bmy_oms_ApplicationManagement_20210806.xlsx'
)
@allure.story
(
"查询应用"
)
@allure.title
(
"{inData[testPoint]}"
)
@allure.testcase
(
"http://yapi.hikcreate.com/project/364/interface/api/cat_15990"
)
@allure.description
(
"查询应用信息"
)
@pytest.mark.parametrize
(
"inData"
,
get_excelData
(
workBook
,
'应用管理'
,
'ApplicationSearch'
))
def
test_logrecord
(
self
,
inData
):
url
=
f
"{BmyomsConfig().test_host}{inData['url']}"
headers
=
inData
[
'headers'
]
method
=
inData
[
'method'
]
data
=
inData
[
'reqData'
]
expectData
=
inData
[
'expectData'
]
res
=
request_main
(
url
,
headers
,
method
,
data
)
allure
.
attach
(
f
"{res}"
,
"响应结果"
,
allure
.
attachment_type
.
TEXT
)
assert
res
[
'code'
]
==
expectData
[
'code'
]
@allure.story
(
"新增应用"
)
@allure.title
(
"{inData[testPoint]}"
)
@allure.testcase
(
"http://yapi.hikcreate.com/project/364/interface/api/cat_15990"
)
@allure.description
(
"新增一个应用"
)
@pytest.mark.parametrize
(
"inData"
,
get_excelData
(
workBook
,
'应用管理'
,
'ApplicationNew'
))
def
test_logrecord
(
self
,
inData
):
url
=
f
"{BmyomsConfig().test_host}{inData['url']}"
headers
=
inData
[
'headers'
]
method
=
inData
[
'method'
]
data
=
inData
[
'reqData'
]
expectData
=
inData
[
'expectData'
]
res
=
request_main
(
url
,
headers
,
method
,
data
)
allure
.
attach
(
f
"{res}"
,
"响应结果"
,
allure
.
attachment_type
.
TEXT
)
assert
res
[
'code'
]
==
expectData
[
'code'
]
if
__name__
==
'__main__'
:
for
one
in
os
.
listdir
(
'../../report/tmp'
):
# 列出对应文件夹的数据
if
'json'
in
one
:
os
.
remove
(
f
'../../report/tmp/{one}'
)
pytest
.
main
([
'test_ApplicationManagement.py'
,
'-s'
,
'--alluredir'
,
'../../report/tmp'
])
# # 启动默认浏览器打开报告
os
.
system
(
'allure serve ../../report/tmp'
)
test_case/bmy/test_login.py
View file @
437dbb94
...
...
@@ -24,7 +24,7 @@ class TestLogin():
def
test_login
(
self
,
inData
):
res
=
BMY
()
.
bmy_login
(
inData
[
'reqData'
],
getToken
=
False
)
#
print(res)
print
(
res
)
assert
res
[
'code'
]
==
inData
[
'expectData'
][
'code'
]
...
...
@@ -35,3 +35,4 @@ if __name__ == '__main__':
pytest
.
main
([
'test_login.py'
,
'-s'
,
'--alluredir'
,
'../../report/tmp'
])
# # 启动默认浏览器打开报告
os
.
system
(
'allure serve ../../report/tmp'
)
test_case/bmy/test_logrecord.py
0 → 100644
View file @
437dbb94
import
pytest
,
allure
,
xlrd
,
requests
,
os
from
common.utils.getExcelData
import
get_excelData
from
service.login
import
BMY
from
common.tools
import
request_main
from
config
import
BmyomsConfig
from
service.login
import
BMY
#@allure.epic("斑马企业云oms")
@allure.feature
(
"日志模块"
)
class
TestLogRecord
():
workBook
=
xlrd
.
open_workbook
(
f
'{BmyomsConfig.root_path}/test_case_data/bmy/bmy_oms_logging_20210803.xlsx'
)
@allure.story
(
"查询日志"
)
@allure.title
(
"{inData[testPoint]}"
)
@allure.testcase
(
"http://yapi.hikcreate.com/project/364/interface/api/cat_17412"
)
@allure.description
(
"查询日记记录"
)
@pytest.mark.parametrize
(
"inData"
,
get_excelData
(
workBook
,
'日志'
,
'logging'
))
def
test_logrecord
(
self
,
inData
):
url
=
f
"{BmyomsConfig().test_host}{inData['url']}"
headers
=
inData
[
'headers'
]
method
=
inData
[
'method'
]
data
=
inData
[
'reqData'
]
expectData
=
inData
[
'expectData'
]
res
=
request_main
(
url
,
headers
,
method
,
data
)
allure
.
attach
(
f
"{res}"
,
"响应结果"
,
allure
.
attachment_type
.
TEXT
)
assert
res
[
'code'
]
==
expectData
[
'code'
]
if
__name__
==
'__main__'
:
for
one
in
os
.
listdir
(
'../../report/tmp'
):
# 列出对应文件夹的数据
if
'json'
in
one
:
os
.
remove
(
f
'../../report/tmp/{one}'
)
pytest
.
main
([
'test_logrecord.py'
,
'-s'
,
'--alluredir'
,
'../../report/tmp'
])
# # 启动默认浏览器打开报告
os
.
system
(
'allure serve ../../report/tmp'
)
test_case/bmy/test_riskMonitar.py
View file @
437dbb94
...
...
@@ -38,6 +38,7 @@ class TestMonitor():
def
teardown_class
(
self
):
"""清除"""
pass
if
__name__
==
'__main__'
:
for
one
in
os
.
listdir
(
'../../report/tmp'
):
# 列出对应文件夹的数据
...
...
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