From c84887206144e70b41774d3252f828e4fcdcc78e Mon Sep 17 00:00:00 2001 From: fumingwei Date: Fri, 15 Oct 2021 14:42:25 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:TSG-8020:=E4=BF=AE=E5=A4=8D=E5=9B=A0fire?= =?UTF-8?q?wall=E5=AE=9E=E7=8E=B0block=E6=96=B9=E5=BC=8F=E5=8F=98=E4=B8=BA?= =?UTF-8?q?=E5=85=88=E5=8F=91fin=E5=86=8D=E5=8F=91=E9=80=81rst=E5=8C=85?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E8=87=AA=E6=A3=80=E5=A4=B1=E8=B4=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- images_build/client/dign_client/bin/client.py | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/images_build/client/dign_client/bin/client.py b/images_build/client/dign_client/bin/client.py index 6b8b444..031ad77 100644 --- a/images_build/client/dign_client/bin/client.py +++ b/images_build/client/dign_client/bin/client.py @@ -858,32 +858,22 @@ class HttpFirewallActionBuild: raise Exception(http_firewall_deny_rst_re) else: raise Exception("Error: The stream may be not rst %s" % errorinfo) - - def verify_debug_msg(self,debug_type,debug_msg): - if re.search(r'403 Forbidden', debug_msg.decode('utf8'), 0): - self.blockinfo_rsp_code_verify_ok=True - if re.search(r'dign-testing-deny-block', debug_msg.decode('utf8'), 0): - self.blockinfo_rsp_content_verify_ok=True def action_deny_subaction_block(self,test_suite_name): - self.blockinfo_rsp_code_verify_ok=False - self.blockinfo_rsp_content_verify_ok=False + bodyBuf = BytesIO() self._set_conn_opt(test_suite_name,URLHttpFirewallDenyBlock) - self.conn.setopt(self.conn.VERBOSE,1) - self.conn.setopt(self.conn.DEBUGFUNCTION, self.verify_debug_msg) - try: - self.conn.perform() - self.conn.close() - except pycurl.error as errorinfo: - errcode = errorinfo.args[0] - if(errcode == 56): - if self.blockinfo_rsp_code_verify_ok == False: - raise Exception("Error:response code is not reqiured,reqiured 403") - if self.blockinfo_rsp_content_verify_ok == False: - raise Exception("Error: response content is not required, required \'dign-testing-deny-block\'") + self.conn.setopt(self.conn.WRITEDATA, bodyBuf) + self.conn.perform() + rescode = self.conn.getinfo(self.conn.RESPONSE_CODE) + self.conn.close() + if rescode == 403: + if re.search(r'dign-testing-deny-block', bodyBuf.getvalue().decode('utf-8'), 0): raise Exception(http_firewall_deny_block_re) else: - raise Exception("Error:The connection is not close by send rst,error info : %s" % errorinfo) + raise Exception("Error: response content is not required, required \'dign-testing-deny-block\'") + + else: + raise Exception("Error: The stream may be not block, http code %s " % rescode) class SslFirewallActionBuild: def __init__(self):