duplicateToken.py 1.62 KB
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import urllib3
from commons import common as com
from commons.MySession import my,s1,s2
import requests
from  requests.cookies import remove_cookie_by_name

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)


class duplicateToken():
    url = "http://test.gateway.diligrp.com:8285/jmsf-web/appCommon/duplicateToken.action"
    header = {
            "UAP_accessToken": "demo",
            "UAP_refreshToken": "demo",
            "UAP_firmId": "9",
            "Host": "test.gateway.diligrp.com:8285",
            "Connection":"Keep-Alive"}

    def __init__(self):
        self.url = duplicateToken.url.replace("http://test.", com.get_global_config("global_data", "environment", "en"))
        self.header = duplicateToken.header
        self.header["UAP_accessToken"] = s2.cookies["UAP_accessToken"]
        self.header["UAP_refreshToken"] = s2.cookies["UAP_refreshToken"]
        self.header["UAP_firmId"] = s2.cookies["UAP_firmId"]
        self.header["Host"] = com.get_global_config("global_data", "host", "gateway")

    def jmsf_duplicate_commit_token(self):
        re = s2.get(url=self.url, headers=self.header)
        print(s2.cookies)
        print(s2.cookies.list_domains())
        print(s2.cookies.list_paths())
        # remove_cookie_by_name(s2.cookies,domain="",name="UAP_accessToken")
        # remove_cookie_by_name(s2.cookies,domain="",name="UAP_refreshToken")
        # print(s2.cookies)
        return re.json()["data"]


# print(s1.headers)
du=duplicateToken()
du.jmsf_duplicate_commit_token()
# print(du.jmsf_duplicate_commit_token())
# print(re.json())
# print(re.headers)