Disable InsecureRequestWarning from requests library
Globally disable InsecureRequestWarning coming
from requests library for both pre 2.16.0 and
for >= 2.16.0 versions.
Change-Id: Ibf4e749086265e8726e90a2f8b4c1c9df3b2c55d
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Issue-ID: TEST-227
diff --git a/test/vcpe/vcpe.py b/test/vcpe/vcpe.py
index c768aa8..bf6fcaf 100755
--- a/test/vcpe/vcpe.py
+++ b/test/vcpe/vcpe.py
@@ -13,7 +13,13 @@
import csar_parser
import config_sdnc_so
import json
+import urllib3
+# disable InsecureRequestWarning warning in requests < 2.16.0
+urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
+# disable InsecureRequestWarning warning in requests >= 2.16.0
+from requests.packages.urllib3.exceptions import InsecureRequestWarning
+requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
def config_sniro(vcpecommon, vgmux_svc_instance_uuid, vbrg_svc_instance_uuid):
logger = logging.getLogger(__name__)
diff --git a/test/vcpe/vcpecommon.py b/test/vcpe/vcpecommon.py
index 371029e..7ce223a 100755
--- a/test/vcpe/vcpecommon.py
+++ b/test/vcpe/vcpecommon.py
@@ -369,7 +369,6 @@
sys.exit(1)
# Check policy already applied
- requests.packages.urllib3.disable_warnings()
policy_exists_req = requests.get(self.policy_pap_get_url.format(
p_pap_cluster_ip), auth=self.policy_userpass,
verify=False, headers=self.policy_headers)
@@ -440,7 +439,6 @@
self.hosts['aai-inst1'], self.aai_query_port, search_node_type, key, node_uuid)
headers = {'Content-Type': 'application/json', 'Accept': 'application/json', 'X-FromAppID': 'vCPE-Robot', 'X-TransactionId': 'get_aai_subscr'}
- requests.packages.urllib3.disable_warnings()
r = requests.get(url, headers=headers, auth=self.aai_userpass, verify=False)
response = r.json()
self.logger.debug('aai query: ' + url)