This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
dongxiaoyan-tsg-autotest/05-Other/variable/LoginRestrictions.py

39 lines
1.2 KiB
Python
Raw Normal View History

#/user/bin/python
#-*-coding:utf-8-*-
import requests
import json
#获取密码加密信息
def encryptpwd():
url1 = "http://192.168.44.71:8080/v1/user/encryptpwd"
content = {"password":"1"}
web = requests.get(url=url1,params=content)
#print(web.text)
ty = web.text
a = json.loads(ty)
#print(a["data"]['encryptpwd'])
encryptpwd = a["data"]['encryptpwd']
return encryptpwd
#获取token
def token():
url2 = "http://192.168.44.71:8080/v1/user/login"
content = {"username":"lyf","password":encryptpwd(),"authMode":1}
web = requests.post(url=url2,params=content)
#print(web.text)
ty1 = web.text
a1 = json.loads(ty1)
token = a1["data"]["token"]
return token
#获取索引值
def index1(id):
url3 = "http://192.168.44.71/v1/user/login/restictions"
headers = {"Content-Type":"application/json;charset=UTF-8","Authorization":token()}
web = requests.get(url=url3,headers=headers)
#print(web.text)
ty2 = web.text
a2 = json.loads(ty2)
loginAddrWhitelist = a2["data"]["list"][0]["loginAddrWhitelist"]
index2=loginAddrWhitelist.index(id)
return index2
if __name__ == '__main__':
index1(id)