[PATCH] [Wok 0/2] Do not require admin permissions to run Wok tests

DEPENDS ON: [Kimchi 0/2] Run wok tests without administration permissions [Gingerbase] Remove unused temporary directory Lucio Correia (2): Fix value of max_body_size example in config Do not use proxy when running tests src/wok.conf.in | 4 ++-- src/wok/server.py | 5 +++-- tests/utils.py | 14 +++----------- 3 files changed, 8 insertions(+), 15 deletions(-) -- 2.7.4

The correct default value is 4 MB, not 4 GB. Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com> --- src/wok.conf.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wok.conf.in b/src/wok.conf.in index 3806609..0e9b993 100644 --- a/src/wok.conf.in +++ b/src/wok.conf.in @@ -19,8 +19,8 @@ # Running environment of the server #environment = production -# Max request body size in KB, default value is 4GB -#max_body_size = 4 * 1024 * 1024 +# Max request body size in KB, default value is 4MB +#max_body_size = 4 * 1024 # Wok server root. Set the following variable to configure any relative path to # the server. For example, to have Wok pointing to https://localhost:8001/wok/ -- 2.7.4

On 02/09/2017 03:08 PM, Lucio Correia wrote:
The correct default value is 4 MB, not 4 GB.
Why? Where have you gotten that info?
Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com> --- src/wok.conf.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/wok.conf.in b/src/wok.conf.in index 3806609..0e9b993 100644 --- a/src/wok.conf.in +++ b/src/wok.conf.in @@ -19,8 +19,8 @@ # Running environment of the server #environment = production
-# Max request body size in KB, default value is 4GB -#max_body_size = 4 * 1024 * 1024 +# Max request body size in KB, default value is 4MB +#max_body_size = 4 * 1024
# Wok server root. Set the following variable to configure any relative path to # the server. For example, to have Wok pointing to https://localhost:8001/wok/

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

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)
participants (2)
-
Aline Manera
-
Lucio Correia