Exemplo n.º 1
0
 def test_webservice_inf(self, values):
     u'API接口上线验证'
     self.intdiscrp = u'测试RT接口令牌无效1'
     self.log.info(values['testcaseID'] + "---------start---------" +
                   values['testcaseID'])
     # self.url = "http://172.29.50.67:7060/sbe"
     # self.data = expath
     # self.caseName=testname
     self.data = values['except_path']
     self.caseName = values['tscase_name']
     self.excelPath = os.path.join(self.data, self.caseName)
     self.f = open(self.excelPath)
     self.data = self.f.read()
     # print data
     self.f.close()
     # self.payload =json.loads(self.data)
     self.payload = json.loads(self.data, encoding='GB2312')
     self.payload["token"] = token
     # print "tihuan%s"%self.payload
     # MD5加密拿到skybusAuth
     self.ttestdMD5 = API_skybusauth()
     self.md5dd = self.ttestdMD5.skybus_md5(token, self.payload)
     print "skybusAuth:%s" % self.md5dd
     self.headers = {
         "Content-Type": "application/json;charset=utf-8",
         "skybusAuth": self.md5dd
     }
     self.r = requests.post(self.url,
                            json=self.payload,
                            headers=self.headers,
                            allow_redirects=False,
                            verify=False)
     # 判断返回是否正确,正则表达式去提取"pnrcode":"HT4DKY"
     # print type(self.r.content)
     # self.t = re.findall(r'"class":"(.+?)",', self.r.content)
     # # print "t=%s"%self.t
     # self.ACTresults = self.t[0]
     # # print self.t[0]
     # 期望值
     self.log.info(values['testcaseID'] + "-接口的返回--" + self.r.content)
     self.hope = values['hope']
     # self.hope =hope
     if self.hope in self.r.content:
         a = True
         self.log.info(values['testcaseID'] + "测试结果----" + "pass" + "-----")
     else:
         a = False
         self.log.info(values['testcaseID'] + "测试结果-----" + "false" +
                       "-----")
     # print a
     self.log.info(values['testcaseID'] + "---期待值--" + self.hope)
     try:
         self.aa = self.assertTrue(a, msg="预期结果和实际结果不符")
     except () as e:
         self.log.info(self.intdiscrp + str(e))
         raise
     self.log.info(values['testcaseID'] +
                   "------------end--------------------")
Exemplo n.º 2
0
    def test_RT(self):
        u'测试RT令牌无效1'
        now = time.strftime("%Y-%m-%d %H:%M:%S")
        aa = EXCEL.rowlist(0)
        bda=EXCEL.dict_api(5,0)
        if bda['isResult'] == 1:
            bda['isResult'] = "true"
        else:
            bda['isResult'] = "false"
        bda['token']=token
        bda['timestamp']=now
        # bda['ibeFlag']=""
        # bda['type']=""
        bb =bda
        self.intdiscrp =aa[1]
        # print self.intdiscrp
        self.log.info(self.intdiscrp + "---------start---------")
        # self.url = aa[1]
        self.url ="http://172.29.50.67:7060/sbe"
        # print self.url
        self.payload =bb
        # print self.payload
        # self.payload2=json.load(self.payload)
        # self.ccmytoken = eval(self.payload.replace("self.token", token))
        # print "990000000000"
        # print "ccmytoken:%s"%self.ccmytoken
        # MD5加密拿到skybusAuth
        self.ttestdMD5 = API_skybusauth()
        self.md5dd = self.ttestdMD5.skybus_md5(token,self.payload)
        # print self.md5dd
        self.headers = {"Content-Type": "application/json;charset=utf-8",
                        "skybusAuth": self.md5dd
                        }
        self.r = requests.post(self.url, json=self.payload, headers=self.headers, allow_redirects=False, verify=False)

        # 判断返回是否正确,正则表达式去提取"pnrcode":"HT4DKY"

        # print self.r.content
        jkd=self.r.json()
        io8=jkd["airsegs"]
        print "respone:%s"%jkd
        print type(io8)
        print io8
        self.log.info(self.intdiscrp + "--"+self.r.content)
        self.t = re.findall(r'"resultCode":(.+?),', self.r.content)
        self.ACTresults = self.t[0]
        # print self.t[0]
        # 期望值
        self.hope ="0"
        # print self.hope
        try:
            self.aa = self.assertEqual(self.t[0], self.hope, msg="预期结果和实际结果不符")
        except() as e:
            self.log.info(self.intdiscrp + str(e))

            raise

        self.log.info(self.intdiscrp + "------------end--------------------")
Exemplo n.º 3
0
    def test_RT2(self):
        u'测试RT令牌无效2'

        self.intdiscrp = u'测试RT接口令牌无效2'
        self.log.info(self.intdiscrp + "---------start---------")
        self.url = "http://172.29.50.67:7060/sbe"
        self.payload = {"class": "com.travelsky.sbeclient.obe.request.PNRRequest",
                        "ibeFlag": "",
                        "isResult": "true",
                        "officeNo": "ufo099",
                        "pnrNo": "HT4DKY",
                        "serviceName": "SBE_RT",
                        "timestamp": "2018-02-01",
                        "token": "Y2hlbmppZTEjMjAxOC0wMi0wMiAxMTo0NTozOA==",
                        "type": ""
                        }
        self.token = "Y2hlbmppZTEjMjAxOC0wMi0wMiAxMTo0NTozOA=="
        # MD5加密拿到skybusAuth
        self.ttestdMD5 = API_skybusauth()
        self.md5dd = self.ttestdMD5.skybus_md5(self.token, self.payload)
        self.headers = {"Content-Type": "application/json;charset=utf-8",
                        "skybusAuth": self.md5dd
                        }
        self.r = requests.post(self.url, json=self.payload, headers=self.headers, allow_redirects=False, verify=False)

        # 判断返回是否正确,正则表达式去提取"pnrcode":"HT4DKY"

        print self.r.content
        self.t = re.findall(r'"errorDescription":"(.+?)"', self.r.content)
        self.ACTresults = self.t[0]
        print self.t[0]
        # 期望值
        self.hope = u"令牌无效1"

        try:
            self.aa = self.assertEqual(self.t[0], self.hope, msg="预期结果和实际结果不符")

        except(AssertionError) as e:
            self.log.error(self.intdiscrp + str(e))
            #try...except...后使用raise 将断言结果再次抛出,使得测试用例抛出faile
            raise

        self.log.info(self.intdiscrp + "------------end--------------------")
Exemplo n.º 4
0
 def test_RT(self):
     u'测试用力'
     self.intdiscrp = u'测试RT接口令牌无效1'
     self.log.info(self.intdiscrp + "---------start---------")
     self.url = "http://172.29.50.67:7060/sbe"
     self.data = "C:\\apiTestForintfc\\testTodispose\\config\\testcase_tickservic"
     self.caseName="SBE_DETR_TKTNO_1.txt"
     self.excelPath = os.path.join(self.data, self.caseName)
     self.f = open(self.excelPath)
     self.data = self.f.read()
     print data
     self.f.close()
     # self.payload =json.loads(self.data)
     self.payload=json.loads(self.data,encoding='GB2312')
     self.payload["token"] = token
     print "tihuan%s"%self.payload
     # MD5加密拿到skybusAuth
     self.ttestdMD5 = API_skybusauth()
     self.md5dd = self.ttestdMD5.skybus_md5(token, self.payload)
     self.headers = {"Content-Type": "application/json;charset=utf-8",
                     "skybusAuth": self.md5dd
                     }
     self.r = requests.post(self.url, json=self.payload, headers=self.headers, allow_redirects=False, verify=False)
     # 判断返回是否正确,正则表达式去提取"pnrcode":"HT4DKY"
     print type(self.r.content)
     self.log.info(self.intdiscrp + "-接口的返回--" + self.r.content)
     self.hope = "卢敬铭"
     # self.hope =hope
     if self.hope in self.r.content:
         a = True
         self.log.info(self.intdiscrp + "测试结果----" + "pass" + "-----")
     else:
         a = False
         self.log.info(self.intdiscrp + "测试结果-----" + "false" + "-----")
     # print a
     self.log.info(self.intdiscrp + "---期待值--" + self.hope)
     try:
         self.aa = self.assertTrue(a, msg="预期结果和实际结果不符")
     except() as e:
         self.log.info(self.intdiscrp + str(e))
         raise
     time.sleep(2)
     self.log.info(self.intdiscrp + "------------end--------------------")
Exemplo n.º 5
0
class Ts_ibeforagent(unittest.TestCase):
    log = Log()

    def setUp(self):
        self.log.info("---------开始测试---------")
        # 测试环境地址
        # self.url = "http://172.29.50.67:7060/sbe"
        # 生存环境地址
        self.url = "http://113.108.131.149:8060/sbe"

    @ddt.data(*testDate)
    def tearDown(self, values):

        self.log.info(values['testcaseID'] + "---------结束测试---------")

    # @unittest.skip(u'我很喜欢你,不想执行你')
    @ddt.data(*testDate)
    # @ddt.unpack
    # def test_RT(self,testcaseid,expath,testname,hope):
    def test_ibeforagent_inf(self, values):
        u'API接口上线验证'
        self.intdiscrp = values['testcaseID']
        self.log.info(self.intdiscrp + "---------start---------" +
                      values['testcaseID'])
        # self.url = "http://172.29.50.67:7060/sbe"
        # self.data = expath
        # self.caseName=testname
        self.data = values['except_path']
        self.caseName = values['tscase_name']
        self.excelPath = os.path.join(self.data, self.caseName)
        self.f = open(self.excelPath)
        self.data = self.f.read()
        # print data
        self.f.close()
        # self.payload =json.loads(self.data)
        self.payload = json.loads(self.data, encoding='GB2312')
        self.payload["token"] = token
        # print "tihuan%s"%self.payload
        # MD5加密拿到skybusAuth
        self.ttestdMD5 = API_skybusauth()
        self.md5dd = self.ttestdMD5.skybus_md5(token, self.payload)
        print "skybusAuth:%s" % self.md5dd
        self.headers = {
            "Content-Type": "application/json;charset=utf-8",
            "skybusAuth": self.md5dd
        }
        self.r = requests.post(self.url,
                               json=self.payload,
                               headers=self.headers,
                               allow_redirects=False,
                               verify=False)
        # 判断返回是否正确,正则表达式去提取"pnrcode":"HT4DKY"
        # print type(self.r.content)
        # self.t = re.findall(r'"class":"(.+?)",', self.r.content)
        # # print "t=%s"%self.t
        # self.ACTresults = self.t[0]
        # # print self.t[0]
        # 期望值
        self.log.info(self.intdiscrp + "-接口的返回--" + self.r.content)
        self.hope = values['hope']
        # self.hope =hope
        if self.hope in self.r.content:
            a = True
            self.log.info(self.intdiscrp + "测试结果----" + "pass" + "-----")
        else:
            a = False
            self.log.info(self.intdiscrp + "测试结果-----" + "false" + "-----")
        # print a
        self.log.info(self.intdiscrp + "---期待值--" + self.hope)
        try:
            self.aa = self.assertTrue(a, msg="预期结果和实际结果不符")
        except () as e:
            self.log.info(self.intdiscrp + str(e))
            raise
        self.log.info(self.intdiscrp + "------------end--------------------")
Exemplo n.º 6
0
import requests
import re
import sys, time
from common.my_MD5andBase64 import API_skybusauth
from common.logger import Log
# from common.excel_pub import ExcelUtil

reload(sys)
sys.setdefaultencoding('utf-8')

accountname = "chenjie1"
psw = "chenjie1"
biosSN = "d41d8cd98f00b204e9800998ecf8427e"
url = "http://172.29.50.67:7060/sbe"
basetoken = accountname + "#" + API_skybusauth().my_md5(psw) + "#" + biosSN
# print basetoken
clientInfo = API_skybusauth().my_base64(basetoken)
# print clientInfo
now = time.strftime("%Y-%m-%d %H:%M:%S")


class applyToken():
    log = Log()

    #挂起帐号
    def ACCOUNT_DEACTIVE(self):
        self.param1 = {
            "clientInfo": clientInfo,
            "serviceName": "ACCOUNT_DEACTIVE",
            "timestamp": now,