From 5ed6a5b1ebcc2148047dc2ae42465366d047ee4c Mon Sep 17 00:00:00 2001 From: fumingwei Date: Thu, 14 Oct 2021 10:15:15 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:TSG-8020:=E4=BF=AE=E6=94=B9firewallblock?= =?UTF-8?q?=E5=8A=A8=E4=BD=9C=E6=97=B6=E7=94=B1=E5=8F=91=E9=80=81FIN?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E8=BF=9E=E6=8E=A5=E5=8F=98=E4=B8=BA=E5=8F=91?= =?UTF-8?q?=E9=80=81RST=E7=BB=93=E6=9D=9F=E8=BF=9E=E6=8E=A5=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E8=87=AA=E6=A3=80=E5=A4=B1=E8=B4=A5bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- images_build/client/dign_client/bin/client.py | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/images_build/client/dign_client/bin/client.py b/images_build/client/dign_client/bin/client.py index f2c9373..6b8b444 100644 --- a/images_build/client/dign_client/bin/client.py +++ b/images_build/client/dign_client/bin/client.py @@ -859,16 +859,31 @@ class HttpFirewallActionBuild: 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 self._set_conn_opt(test_suite_name,URLHttpFirewallDenyBlock) - self.conn.perform() - rescode = self.conn.getinfo(self.conn.RESPONSE_CODE) - self.conn.close() - if rescode == 403: - raise Exception(http_firewall_deny_block_re) - else: - raise Exception("Error: The stream may be not block, http code %s " % rescode) + 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\'") + raise Exception(http_firewall_deny_block_re) + else: + raise Exception("Error:The connection is not close by send rst,error info : %s" % errorinfo) class SslFirewallActionBuild: def __init__(self):