mkumatag / openbmc-automation

Test OpenBMC Distribution, moved to - https://github.com/openbmc/openbmc-test-automation
Apache License 2.0
5 stars 11 forks source link

PreTag InsecureRequestWarning: Unverified HTTPS request is being made #62

Closed gkeishin closed 8 years ago

gkeishin commented 8 years ago

While executing the test , we are seeing logs throwing up on console and log output

.tox/palmetto/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py:821: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html InsecureRequestWarning)

This is a debatable topic.. they are really genuine warning coming from urllib library packaged which comes with the python however for the test case output this seems redundant and flooding the log is not desirable...

This warning as per the discussion over the forums seems to fix post 2.7.xx Python version, however there are dependencies with robot framework which creates more configuration and setting issues..

There is a work around hack for this.. but will wait for Chris to discuss and close on this one if this really needed to be fixed..

mkumatag commented 8 years ago

I've already added PYTHONWARNINGS="ignore:Unverified HTTPS request" as env var to .tox file so that you will not a problem if Python 2.7 used with tox.

You will hit this issue if 2.6 version of python used or if you are not having PYTHONWARNINGS set to ignore warning.

gkeishin commented 8 years ago

We are aware of that tox.ini having that parameter.. It doesn't work now... I have a version 2.7.11 installed as well Python 2.7.11 (default, Dec 15 2015, 16:48:05)

This is seen with other folks as well...

gkeishin commented 8 years ago

I have a simplified fix working solution for this.. but will talk to Chris Austen on it to see if he is ok with the fix.. Will keep posted

gkeishin commented 8 years ago

The fix will look like this.. This would to suppress almost or stop it from propagating on the console those COnnections, URLLIB warnings..

lib/disable_warning_urlib.py

!/usr/bin/python

import logging import warnings import httplib

warnings.filterwarnings("ignore")

Hijack the HTTP lib message and Log only once

httplib.HTTPConnection.debuglevel = 0

requests_log = logging.getLogger("requests.packages.urllib3") requests_log.setLevel(logging.CRITICAL) requests_log.propagate = False

class disable_warning_urlib(): def do_nothing(): return

* Setting *

Library ../lib/disable_warning_urlib.py

in the lib/rest_client.robot

That's it..

mkumatag commented 8 years ago

Can you please make sure whether this works for python 2.6 as well? if yes - send the PR with proposed changes.

gkeishin commented 8 years ago

Python 2.6.9 (default, Oct 22 2014, 19:58:14) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information.

I have to tweak the tox.ini to pick up the 2.6.9

rango@ubuntu:~/FTC_OPENBMC_TEST/openbmc-automation$ ls .tox/barreleye/bin/ activate activate.fish easy_install pip pip2.6 python python2.6 robot activate.csh activate_this.py easy_install-2.6 pip2 pybot python2 rebot

rango@ubuntu:~/FTC_OPENBMC_TEST/openbmc-automation$ .tox/barreleye/bin/python Python 2.6.9 (default, Oct 22 2014, 19:58:14) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information.

and it runs good like it ran on 2.7.11

We will still see some Warning but not recurring in a test case any more..

gkeishin commented 8 years ago

SAMPLE TEST CASE 1 : o/p


BEFORE :

Test Generic Conf :: This suite will verifiy the Generic Configuration Rest...

Get the boot_flags :: _GOOD PATH_ URI:https://9.3.23.24/org/openbmc/settings/host0//attr/boot_flags, method:Get, args:{} /home/rango/FTC_OPENBMCTEST/openbmc-automation/.tox/barreleye/lib/python2.6/site-packages/requests/packages/urllib3/util/ssl.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning. SNIMissingWarning /home/rango/FTC_OPENBMCTEST/openbmc-automation/.tox/barreleye/lib/python2.6/site-packages/requests/packages/urllib3/util/ssl.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning /home/rango/FTC_OPENBMC_TEST/openbmc-automation/.tox/barreleye/lib/python2.6/site-packages/requests/packages/urllib3/connectionpool.py:821: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html InsecureRequestWarning) /home/rango/FTC_OPENBMC_TEST/openbmc-automation/.tox/barreleye/lib/python2.6/site-packages/requests/packages/urllib3/connectionpool.py:821: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html InsecureRequestWarning) Response code:200, Content:{ "data": "Default", "message": "200 OK", "status": "ok" }

Get the boot_flags :: _GOOD PATH_ | PASS |

Test Generic Conf :: This suite will verifiy the Generic Configura... | PASS | 1 critical test, 1 passed, 0 failed

1 test total, 1 passed, 0 failed

AFTER ::

Test Generic Conf :: This suite will verifiy the Generic Configuration Rest...

Get the boot_flags :: _GOOD PATH_ URI:https://9.3.23.24/org/openbmc/settings/host0//attr/boot_flags, method:Get, args:{} Response code:200, Content:{ "data": "Default", "message": "200 OK", "status": "ok" }

Get the boot_flags :: _GOOD PATH_ | PASS |

Test Generic Conf :: This suite will verifiy the Generic Configura... | PASS | 1 critical test, 1 passed, 0 failed

1 test total, 1 passed, 0 failed


SAMPLE TEST CASE 2 : o/p


BEFORE :**

Test Ssl :: This testsuite is for testing SSL connection to OpenBMC

[ WARN ] Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0xa535e6c>: Failed to establish a new connection: [Errno 111] Connection refused',)': //list [ WARN ] Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0xa544aec>: Failed to establish a new connection: [Errno 111] Connection refused',)': //list [ WARN ] Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0xa544c2c>: Failed to establish a new connection: [Errno 111] Connection refused',)': //list Test non-SSL Connection to port 80 :: This testcase is for test to... | FAIL |

ConnectionError: HTTPConnectionPool(host='9.3.23.24', port=80): Max retries exceeded with url: //list (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0xa544d4c>: Failed to establish a new connection: [Errno 111] Connection refused',))

Test Ssl :: This testsuite is for testing SSL connection to OpenBMC | FAIL | 1 critical test, 0 passed, 1 failed

1 test total, 0 passed, 1 failed

AFTER:

Test Ssl :: This testsuite is for testing SSL connection to OpenBMC

Test non-SSL Connection to port 80 :: This testcase is for test to... | FAIL |

ConnectionError: HTTPConnectionPool(host='9.3.23.24', port=80): Max retries exceeded with url: //list (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x9cdd08c>: Failed to establish a new connection: [Errno 111] Connection refused',))

Test Ssl :: This testsuite is for testing SSL connection to OpenBMC | FAIL | 1 critical test, 0 passed, 1 failed

1 test total, 0 passed, 1 failed

gkeishin commented 8 years ago

The code is merged and available on the main repo.. Closing this task..