Currently administration permissions are required to
run tests in order to change nginx configuration.
With this patch, tests requests are handled directly by
cherrypy, without being proxied by nginx. This allows
tests to be run without administration permissions.
Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com>
---
src/wok/server.py | 5 +++--
tests/utils.py | 14 +++-----------
2 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/src/wok/server.py b/src/wok/server.py
index d99b91f..901940c 100644
--- a/src/wok/server.py
+++ b/src/wok/server.py
@@ -68,8 +68,9 @@ class Server(object):
if hasattr(options, item):
config.config.set(sec, item, str(getattr(options, item)))
- # Check proxy configuration
- check_proxy_config()
+ # Check proxy configuration when not in test mode
+ if not hasattr(options, 'test') or not options.test:
+ check_proxy_config()
make_dirs = [
os.path.abspath(config.get_log_download_path()),
diff --git a/tests/utils.py b/tests/utils.py
index 9c18637..ef8ae21 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -24,9 +24,7 @@ import base64
import cherrypy
import grp
import httplib
-import inspect
import os
-import ssl
import sys
import threading
import time
@@ -40,7 +38,7 @@ from wok.exception import NotFoundError, OperationFailed
from wok.utils import wok_log
HOST = '0.0.0.0'
-PROXY_PORT = 8001
+PORT = 8010
fake_user = {'root': 'letmein!'}
@@ -91,7 +89,7 @@ if sys.version_info[:2] == (2, 6):
def run_server(test_mode, environment='dev', server_root=''):
args = type('_', (object,),
- {'cherrypy_port': 8010, 'max_body_size': '4*1024',
+ {'cherrypy_port': PORT, 'max_body_size': '4*1024',
'test': test_mode, 'access_log': '/dev/null',
'error_log': '/dev/null', 'environment': environment,
'log_level': 'debug', 'session_timeout': 10,
@@ -122,13 +120,7 @@ def _request(conn, path, data, method, headers):
def request(path, data=None, method='GET', headers=None):
- # verify if HTTPSConnection has context parameter
- if "context" in inspect.getargspec(httplib.HTTPSConnection.__init__).args:
- context = ssl._create_unverified_context()
- conn = httplib.HTTPSConnection(HOST, PROXY_PORT, context=context)
- else:
- conn = httplib.HTTPSConnection(HOST, PROXY_PORT)
-
+ conn = httplib.HTTPConnection(HOST, PORT)
return _request(conn, path, data, method, headers)
--
2.7.4
_______________________________________________
Kimchi-devel mailing list
Kimchi-devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel
Reviewed-by: Aline Manera <alinefm@linux.vnet.ibm.com> On 02/09/2017 03:08 PM, Lucio Correia wrote: > Currently administration permissions are required to > run tests in order to change nginx configuration. > > With this patch, tests requests are handled directly by > cherrypy, without being proxied by nginx. This allows > tests to be run without administration permissions. > > Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com> > --- > src/wok/server.py | 5 +++-- > tests/utils.py | 14 +++----------- > 2 files changed, 6 insertions(+), 13 deletions(-) > > diff --git a/src/wok/server.py b/src/wok/server.py > index d99b91f..901940c 100644 > --- a/src/wok/server.py > +++ b/src/wok/server.py > @@ -68,8 +68,9 @@ class Server(object): > if hasattr(options, item): > config.config.set(sec, item, str(getattr(options, item))) > > - # Check proxy configuration > - check_proxy_config() > + # Check proxy configuration when not in test mode > + if not hasattr(options, 'test') or not options.test: > + check_proxy_config() > > make_dirs = [ > os.path.abspath(config.get_log_download_path()), > diff --git a/tests/utils.py b/tests/utils.py > index 9c18637..ef8ae21 100644 > --- a/tests/utils.py > +++ b/tests/utils.py > @@ -24,9 +24,7 @@ import base64 > import cherrypy > import grp > import httplib > -import inspect > import os > -import ssl > import sys > import threading > import time > @@ -40,7 +38,7 @@ from wok.exception import NotFoundError, OperationFailed > from wok.utils import wok_log > > HOST = '0.0.0.0' > -PROXY_PORT = 8001 > +PORT = 8010 > > fake_user = {'root': 'letmein!'} > > @@ -91,7 +89,7 @@ if sys.version_info[:2] == (2, 6): > def run_server(test_mode, environment='dev', server_root=''): > > args = type('_', (object,), > - {'cherrypy_port': 8010, 'max_body_size': '4*1024', > + {'cherrypy_port': PORT, 'max_body_size': '4*1024', > 'test': test_mode, 'access_log': '/dev/null', > 'error_log': '/dev/null', 'environment': environment, > 'log_level': 'debug', 'session_timeout': 10, > @@ -122,13 +120,7 @@ def _request(conn, path, data, method, headers): > > > def request(path, data=None, method='GET', headers=None): > - # verify if HTTPSConnection has context parameter > - if "context" in inspect.getargspec(httplib.HTTPSConnection.__init__).args: > - context = ssl._create_unverified_context() > - conn = httplib.HTTPSConnection(HOST, PROXY_PORT, context=context) > - else: > - conn = httplib.HTTPSConnection(HOST, PROXY_PORT) > - > + conn = httplib.HTTPConnection(HOST, PORT) > return _request(conn, path, data, method, headers) > > _______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel
© 2016 - 2025 Red Hat, Inc.