logout.py 1.56 KB
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import requests
import json
from commons import common as com


class logout():
    url="http://test.uap.diligrp.com/login/logout.action"
    header={
    "Host": "test.uap.diligrp.com",
    "Connection": "keep-alive",
    "Content-Length": "33",
    "X-Requested-With": "XMLHttpRequest",
    "Origin": "http://test.uap.diligrp.com",
    "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
    "User-Agent": "Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/90.0.4430.212Safari/537.36",
    "Accept": "*/*",
    "Referer": "http://test.uap.diligrp.com/login/index.html",
    "Accept-Encoding": "gzip,deflate",
    "Accept-Language": "zh-CN,zh-TW;q=0.9,zh;q=0.8,en;q=0.7",
    "Cookie": "UAP_accessToken=;UAP_refreshToken=;UAP_loginPath="}
    body="systemCode=UAP&userId=210"
    
    def __init__(self):
        #如下代码,可以通过配置文件来控制测试环境和灰度环境,http和https
        self.url=logout.url.replace("http://test.",com.get_global_config("global_data", "environment", "en") )
        self.header=logout.header
        self.body=logout.body

    def post(self,session,account,**kwargs):
        #需要用专用的测试账户来测试,否则会影响其他用例
        self.body=self.body.replace("210", com.get_global_config("global_data", "userId", account))
        re=session.post(url=self.url, headers=self.header,data=self.body,**kwargs)
        return re
        



# t=logout()
# re=t.post("user01",proxies={'http': 'http://localhost:8888'})
# print(re.json())