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
922e33c2
Commit
922e33c2
authored
May 08, 2021
by
fanxun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SSO登录修改
parent
a93f0ea3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
21 deletions
+33
-21
config.py
+12
-3
service/login.py
+21
-18
No files found.
config.py
View file @
922e33c2
...
...
@@ -3,14 +3,23 @@
class
BaseConfig
():
"""基础配置类"""
# 请求头
headers
=
{
'Content-Type'
:
'application/json
; charset=utf-8
'
}
headers
=
{
'Content-Type'
:
'application/json'
}
# 当前运行的产品名
name
=
"auto"
test_case_dir
=
"test_case/"
salt
=
'hikcreate_xj'
# SSO 登录的东西
secs
=
0.1
# 测试用例间隔运行时间
test_redis
=
{
"host"
:
"10.197.236.197"
,
"port"
:
6379
,
"password"
:
"123456"
}
# 钉钉相关
webhook
=
''
# SSO相关
username
=
'fanxun'
# SSO登录名
password
=
'fx123456'
# sso密码
sso_url
=
r'http://testtbdzj.hikcreate.com/web/auth/users/login'
# sso登录地址
salt
=
'hikcreate_xj'
# SSO盐值
class
BMCConfig
(
BaseConfig
):
"""斑马信用app的配置类"""
...
...
@@ -18,7 +27,6 @@ class BMCConfig(BaseConfig):
name
=
"bmc"
test_case_dir
=
"test_case/bmc/"
test_case_data_dir
=
"test_case_data/bmc/"
webhook
=
''
class
BmyConfig
(
BaseConfig
):
...
...
@@ -31,3 +39,4 @@ class BmyConfig(BaseConfig):
# 测试环境
test_host
=
"http://testyun.banmago.com/api"
service/login.py
View file @
922e33c2
...
...
@@ -10,14 +10,19 @@ from config import BmyConfig
@pytest.fixture
(
scope
=
'session'
)
def
sso_login
(
url
,
headers
,
method
,
data
):
class
SSOLogin
(
):
"""SSO登录"""
req_data
=
{
"loginName"
:
"fanxun"
,
"password"
:
"fx123456"
}
password
=
req_data
[
'password'
]
md5_password
=
Encryption
()
.
get_md5
(
password
,
salt
=
BaseConfig
.
salt
)
req_data
[
'password'
]
=
md5_password
res
=
request_main
(
url
,
headers
,
method
,
req_data
)
print
(
res
)
def
_sso_pwd_encrypted
(
self
,
org_pwd
):
"""md5加密"""
encrypted_password
=
Encryption
()
.
get_md5
(
org_pwd
,
salt
=
BaseConfig
.
salt
)
return
encrypted_password
def
sso_login
(
self
,
url
,
method
,
headers
=
None
):
"""SSO登录获取token"""
encrypted_password
=
self
.
_sso_pwd_encrypted
(
BaseConfig
.
password
)
req_data
=
{
f
"loginName"
:
BaseConfig
.
username
,
"password"
:
encrypted_password
}
res
=
request_main
(
url
,
headers
,
method
,
req_data
)
return
res
[
'data'
][
'token'
]
class
BMY
():
...
...
@@ -108,14 +113,12 @@ class BMY():
if
__name__
==
'__main__'
:
# login = request_main(url=r'http://testtbdzj.hikcreate.com/web/auth/users/login',
# method='post',
# data={"loginName":"fanxun","password":"d67fac1d71943576b6c397d0cca166cb"},
# headers=getattr(BaseConfig, 'headers'))
# sso_login(r'http://testtbdzj.hikcreate.com/web/auth/users/login',
# headers=getattr(BaseConfig, 'headers'),
# method='post',
# data=None)
indata
=
{
"username"
:
"15150000000"
,
"password"
:
"A123456"
}
token
=
BMY
()
.
bmy_login
(
indata
,
getToken
=
False
)
print
(
token
)
# SSO登录测试
sso_token
=
SSOLogin
()
.
sso_login
(
url
=
BaseConfig
.
sso_url
,
method
=
'post'
,)
print
(
sso_token
)
# indata= {"username":"15150000000","password":"A123456"}
# token= BMY().bmy_login(indata,getToken=False)
# print(token)
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