def logout(self): self.req_method = 'GET' self.req_url = '/core/user/logout' self.req_body = {"t": common_util.get_timestamp()} self.req_cookies = { 'JSESSIONID': auth_util.get_cookie('web'), } result = self.x_request() assert_util.result_check(result) auth_util.set_cookie('web', result.rsp.cookies["JSESSIONID"]) return result
def add_new_goods(self, **kwargs): self.req_method = 'POST' self.req_url = '/core/goods/addNewGoods' self.req_body = kwargs result = self.request( method=self.req_method, url=self.req_url, data=self.req_body, cookies=self.req_cookies ) assert_util.result_check(result) core_jsessionid = result.rsp.cookies["JSESSIONID"] auth_util.set_cookie('crm', core_jsessionid) logger.debug(core_jsessionid) return result
def get_current_user(self): self.req_method = 'GET' self.req_url = '/core/user/getCurrentUser' result = self.x_request() # asserter.result_check(result) # code=000002, success=false message=当前用户校验不通过 if result.rsp.status_code == 200: # print(result.rsp.text) jsession_id = result.rsp.cookies['JSESSIONID'] print(jsession_id) auth_util.set_cookie('web', jsession_id) return result
def get_current_user_nocookie(self): self.req_method = 'GET' self.req_url = '/core/user/getCurrentUser' result = self.request(method='GET', url=self.req_url, headers=self.req_headers, params=self.req_body) # asserter.result_check(result) # 响应码=200,code=000002, success=false message=当前用户校验不通过 print(result.sdata) if result.rsp.status_code == 200: jsession_id = result.rsp.cookies['JSESSIONID'] print(jsession_id) auth_util.set_cookie('web', jsession_id) return result
def gz_login(self, param1): self.req_method = 'GET' self.req_url = '/gzuser/user/login' self.req_body = { "phone": param1, 'userPassword': '******' # common.calc_pwd(param1) } # result = self.x_request() result = self.request(method=self.req_method, url=self.req_url, params=self.req_body) token = result.rsp.cookies['token'] auth_util.set_cookie('gz', token) assert_util.result_check(result) return result
def crm_login(self): self.req_method = 'get' self.req_url = '/core/account/login' self.req_body = { "accountName": "*****@*****.**", "accountPassword": "******", # 对应的明文是'Qwe123!@#' 589678262728104112 "captcha": 'qwe123EWQ#@!' # '262728293031' } result = self.x_request() assert_util.result_check(result) # 保存jsessionid,在core项目中用到 core_jsessionid = result.rsp.cookies["JSESSIONID"] auth_util.set_cookie('crm', core_jsessionid) # 保存api_account_token,在蓝桥杯项目中用到 api_account_token = result.rsp.cookies["api_account_token"] auth_util.set_gz_token('crm', api_account_token) logger.info(api_account_token) return result