[PATCH V2] [Wok 0/6] Log failed user requests

Important: * This patchset depends on [PATCH V2] [Wok 0/3] User Request Log improvements. * This patch requires "[Kimchi] Do not break the logging of failed requests". Otherwise, some tests will be broken. Changes in V2: * Applied review suggestions Lucio Correia (6): Revert "Use past verbs" Parse request before authorization check Use status code 200 for PUT requests on resource Log failed login/logout attempts Log failed user requests Add status code to request log message docs/API/logs.md | 1 + src/wok/control/base.py | 130 ++++++++++++++++++++++-------------------------- src/wok/exception.py | 28 ++++++++--- src/wok/i18n.py | 4 +- src/wok/reqlogger.py | 10 ++-- src/wok/root.py | 44 +++++++++++----- tests/test_api.py | 2 +- 7 files changed, 122 insertions(+), 97 deletions(-) -- 1.9.1

This reverts commit 04358829a34f246efa7198191b4ca7a851c02bbb. --- src/wok/i18n.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wok/i18n.py b/src/wok/i18n.py index 4fc21f1..d6cb17c 100644 --- a/src/wok/i18n.py +++ b/src/wok/i18n.py @@ -58,6 +58,6 @@ messages = { # These messages (ending with L) are for user log purposes "WOKCOL0001L": _("Request made on collection"), "WOKRES0001L": _("Request made on resource"), - "WOKROOT0001L": _("User '%(username)s' logged in"), - "WOKROOT0002L": _("User '%(username)s' logged out"), + "WOKROOT0001L": _("User '%(username)s' login"), + "WOKROOT0002L": _("User '%(username)s' logout"), } -- 1.9.1

The variable request is used to log request, but if authorization fails, it will not be initialize and break logging. Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com> --- src/wok/control/base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wok/control/base.py b/src/wok/control/base.py index 419179a..b861b9c 100644 --- a/src/wok/control/base.py +++ b/src/wok/control/base.py @@ -122,13 +122,14 @@ class Resource(object): method = 'POST' validate_method((method), self.role_key, self.admin_methods) try: + request = parse_request() + validate_params(request, self, action_name) + self.lookup() if not self.is_authorized(): raise UnauthorizedError('WOKAPI0009E') model_args = list(self.model_args) - request = parse_request() - validate_params(request, self, action_name) if action_args is not None: model_args.extend( request[key] if key in request.keys() else None -- 1.9.1

Some PUT requests on resource have no status code defined. Other were returning 202, which is not the best option for PUT requests. Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com> --- src/wok/control/base.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wok/control/base.py b/src/wok/control/base.py index b861b9c..9b34c55 100644 --- a/src/wok/control/base.py +++ b/src/wok/control/base.py @@ -263,6 +263,7 @@ class Resource(object): args = list(self.model_args) + [params] ident = update(*args) self._redirect(ident) + cherrypy.response.status = 200 self.lookup() return self.get() -- 1.9.1

Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com> --- src/wok/root.py | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/src/wok/root.py b/src/wok/root.py index 902e203..e2b9216 100644 --- a/src/wok/root.py +++ b/src/wok/root.py @@ -31,10 +31,9 @@ from wok.config import paths as wok_paths from wok.control import sub_nodes from wok.control.base import Resource from wok.control.utils import parse_request -from wok.exception import MissingParameter, OperationFailed +from wok.exception import MissingParameter from wok.message import WokMessage from wok.reqlogger import RequestRecord -from wok.utils import get_plugin_from_request ROOT_REQUESTS = { @@ -152,28 +151,43 @@ class WokRoot(Root): @cherrypy.expose def login(self, *args): + method = 'POST' + code = self.getRequestMessage(method, 'login') + app = 'wok' + ip = cherrypy.request.remote.ip + try: params = parse_request() + msg = WokMessage(code, params).get_text(prepend_code=False) username = params['username'] password = params['password'] except KeyError, item: + RequestRecord( + msg, + app=app, + req=method, + status=400, + user='N/A', + ip=ip + ).log() + e = MissingParameter('WOKAUTH0003E', {'item': str(item)}) raise cherrypy.HTTPError(400, e.message) try: + status = 200 user_info = auth.login(username, password) - except OperationFailed: - raise cherrypy.HTTPError(401) + except cherrypy.HTTPError, e: + status = e.status + raise finally: - method = 'POST' - code = self.getRequestMessage(method, 'login') - msg = WokMessage(code, params).get_text(prepend_code=False) RequestRecord( msg, - app=get_plugin_from_request(), + app=app, req=method, - user=cherrypy.session.get(auth.USER_NAME, 'N/A'), - ip=cherrypy.request.remote.ip + status=status, + user='N/A', + ip=ip ).log() return json.dumps(user_info) @@ -184,13 +198,17 @@ class WokRoot(Root): code = self.getRequestMessage(method, 'logout') params = {'username': cherrypy.session.get(auth.USER_NAME, 'N/A')} msg = WokMessage(code, params).get_text(prepend_code=False) + ip = cherrypy.request.remote.ip + + auth.logout() + RequestRecord( msg, - app=get_plugin_from_request(), + app='wok', req=method, + status=200, user=params['username'], - ip=cherrypy.request.remote.ip + ip=ip ).log() - auth.logout() return '{}' -- 1.9.1

Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com> --- src/wok/control/base.py | 124 ++++++++++++++++++++++-------------------------- src/wok/exception.py | 28 ++++++++--- 2 files changed, 78 insertions(+), 74 deletions(-) diff --git a/src/wok/control/base.py b/src/wok/control/base.py index 9b34c55..69541b1 100644 --- a/src/wok/control/base.py +++ b/src/wok/control/base.py @@ -30,9 +30,7 @@ from wok.auth import USER_GROUPS, USER_NAME, USER_ROLES from wok.control.utils import get_class_name, internal_redirect, model_fn from wok.control.utils import parse_request, validate_method from wok.control.utils import validate_params -from wok.exception import InvalidOperation, InvalidParameter -from wok.exception import MissingParameter, NotFoundError -from wok.exception import OperationFailed, UnauthorizedError, WokException +from wok.exception import InvalidOperation, UnauthorizedError, WokException from wok.message import WokMessage from wok.reqlogger import RequestRecord from wok.utils import get_plugin_from_request, utf8_dict, wok_log, encode_value @@ -119,6 +117,10 @@ class Resource(object): def _generate_action_handler_base(self, action_name, render_fn, destructive=False, action_args=None): def wrapper(*args, **kwargs): + # status must be always set in order to request be logged. + # use 500 as fallback for "exception not handled" cases. + status = 500 + method = 'POST' validate_method((method), self.role_key, self.admin_methods) try: @@ -138,7 +140,18 @@ class Resource(object): action_fn = getattr(self.model, model_fn(self, action_name)) action_result = action_fn(*model_args) + status = 200 + if destructive is False or \ + ('persistent' in self.info.keys() and + self.info['persistent'] is True): + result = render_fn(self, action_result) + status = cherrypy.response.status + return result + except WokException, e: + status = e.getHttpStatusCode() + raise cherrypy.HTTPError(status, e.message) + finally: # log request code = self.getRequestMessage(method, action_name) reqParams = utf8_dict(self.log_args, request) @@ -147,29 +160,11 @@ class Resource(object): msg, app=get_plugin_from_request(), req=method, + status=status, user=cherrypy.session.get(USER_NAME, 'N/A'), ip=cherrypy.request.remote.ip ).log() - if destructive is False or \ - ('persistent' in self.info.keys() and - self.info['persistent'] is True): - return render_fn(self, action_result) - except MissingParameter, e: - raise cherrypy.HTTPError(400, e.message) - except InvalidParameter, e: - raise cherrypy.HTTPError(400, e.message) - except InvalidOperation, e: - raise cherrypy.HTTPError(400, e.message) - except UnauthorizedError, e: - raise cherrypy.HTTPError(403, e.message) - except NotFoundError, e: - raise cherrypy.HTTPError(404, e.message) - except OperationFailed, e: - raise cherrypy.HTTPError(500, e.message) - except WokException, e: - raise cherrypy.HTTPError(500, e.message) - wrapper.__name__ = action_name wrapper.exposed = True return wrapper @@ -190,13 +185,13 @@ class Resource(object): e = InvalidOperation('WOKAPI0002E', {'resource': get_class_name(self)}) raise cherrypy.HTTPError(405, e.message) - except OperationFailed, e: - raise cherrypy.HTTPError(500, e.message) - except InvalidOperation, e: - raise cherrypy.HTTPError(400, e.message) @cherrypy.expose def index(self, *args, **kargs): + # status must be always set in order to request be logged. + # use 500 as fallback for "exception not handled" cases. + status = 500 + method = validate_method(('GET', 'DELETE', 'PUT'), self.role_key, self.admin_methods) @@ -208,30 +203,27 @@ class Resource(object): result = {'GET': self.get, 'DELETE': self.delete, 'PUT': self.update}[method](*args, **kargs) - except InvalidOperation, e: - raise cherrypy.HTTPError(400, e.message) - except InvalidParameter, e: - raise cherrypy.HTTPError(400, e.message) - except UnauthorizedError, e: - raise cherrypy.HTTPError(403, e.message) - except NotFoundError, e: - raise cherrypy.HTTPError(404, e.message) - except OperationFailed, e: - raise cherrypy.HTTPError(500, e.message) + + status = cherrypy.response.status except WokException, e: - raise cherrypy.HTTPError(500, e.message) - - # log request - if method not in LOG_DISABLED_METHODS: - code = self.getRequestMessage(method) - msg = WokMessage(code, self.log_args).get_text(prepend_code=False) - RequestRecord( - msg, - app=get_plugin_from_request(), - req=method, - user=cherrypy.session.get(USER_NAME, 'N/A'), - ip=cherrypy.request.remote.ip - ).log() + status = e.getHttpStatusCode() + raise cherrypy.HTTPError(status, e.message) + except cherrypy.HTTPError, e: + status = e.status + raise + finally: + # log request + if method not in LOG_DISABLED_METHODS: + code = self.getRequestMessage(method) + msg = WokMessage(code, self.log_args) + RequestRecord( + msg.get_text(prepend_code=False), + app=get_plugin_from_request(), + req=method, + status=status, + user=cherrypy.session.get(USER_NAME, 'N/A'), + ip=cherrypy.request.remote.ip + ).log() return result @@ -311,10 +303,6 @@ class AsyncResource(Resource): e = InvalidOperation('WOKAPI0002E', {'resource': get_class_name(self)}) raise cherrypy.HTTPError(405, e.message) - except OperationFailed, e: - raise cherrypy.HTTPError(500, e.message) - except InvalidOperation, e: - raise cherrypy.HTTPError(400, e.message) cherrypy.response.status = 202 return wok.template.render("Task", task) @@ -437,6 +425,10 @@ class Collection(object): @cherrypy.expose def index(self, *args, **kwargs): + # status must be always set in order to request be logged. + # use 500 as fallback for "exception not handled" cases. + status = 500 + params = {} method = validate_method(('GET', 'POST'), self.role_key, self.admin_methods) @@ -449,7 +441,16 @@ class Collection(object): elif method == 'POST': params = parse_request() result = self.create(params, *args) - + status = cherrypy.response.status + return result + except WokException, e: + status = e.getHttpStatusCode() + raise cherrypy.HTTPError(status, e.message) + except cherrypy.HTTPError, e: + status = e.status + raise + finally: + if method not in LOG_DISABLED_METHODS: # log request code = self.getRequestMessage(method) reqParams = utf8_dict(self.log_args, params) @@ -458,24 +459,11 @@ class Collection(object): msg, app=get_plugin_from_request(), req=method, + status=status, user=cherrypy.session.get(USER_NAME, 'N/A'), ip=cherrypy.request.remote.ip ).log() - return result - except InvalidOperation, e: - raise cherrypy.HTTPError(400, e.message) - except InvalidParameter, e: - raise cherrypy.HTTPError(400, e.message) - except MissingParameter, e: - raise cherrypy.HTTPError(400, e.message) - except NotFoundError, e: - raise cherrypy.HTTPError(404, e.message) - except OperationFailed, e: - raise cherrypy.HTTPError(500, e.message) - except WokException, e: - raise cherrypy.HTTPError(500, e.message) - class AsyncCollection(Collection): """ diff --git a/src/wok/exception.py b/src/wok/exception.py index 90b6410..f8f4bd4 100644 --- a/src/wok/exception.py +++ b/src/wok/exception.py @@ -28,30 +28,44 @@ class WokException(Exception): def __init__(self, code='', args=None): if args is None: args = {} + self.httpStatusCode = 500 self.code = code msg = WokMessage(code, args).get_text() cherrypy.log.error_log.error(msg) Exception.__init__(self, msg) + def getHttpStatusCode(self): + return self.httpStatusCode + class NotFoundError(WokException): - pass + def __init__(self, code='', args=None): + super(NotFoundError, self).__init__(code, args) + self.httpStatusCode = 404 class OperationFailed(WokException): - pass + def __init__(self, code='', args=None): + super(OperationFailed, self).__init__(code, args) + self.httpStatusCode = 500 class MissingParameter(WokException): - pass + def __init__(self, code='', args=None): + super(MissingParameter, self).__init__(code, args) + self.httpStatusCode = 400 class InvalidParameter(WokException): - pass + def __init__(self, code='', args=None): + super(InvalidParameter, self).__init__(code, args) + self.httpStatusCode = 400 class InvalidOperation(WokException): - pass + def __init__(self, code='', args=None): + super(InvalidOperation, self).__init__(code, args) + self.httpStatusCode = 400 class IsoFormatError(WokException): @@ -67,4 +81,6 @@ class TimeoutExpired(WokException): class UnauthorizedError(WokException): - pass + def __init__(self, code='', args=None): + super(UnauthorizedError, self).__init__(code, args) + self.httpStatusCode = 403 -- 1.9.1

* Also, remove download field from filtering options. * Update test case Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com> --- docs/API/logs.md | 1 + src/wok/reqlogger.py | 10 +++++----- tests/test_api.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/API/logs.md b/docs/API/logs.md index fcfb3b2..0cbabff 100644 --- a/docs/API/logs.md +++ b/docs/API/logs.md @@ -12,6 +12,7 @@ Use "wok" or any plugin installed, like "kimchi". * req: Filter entries by type of request: "DELETE", "POST", "PUT". "GET" requests are not logged. + * status: Filter entries by HTTP response status: 200, 404, 500, etc. * user: Filter entries by user that performed the request. * ip: Filter entries by user IP address, i.e. 127.0.0.1 * date: Filter entries by date of record in the format "YYYY-MM-DD" diff --git a/src/wok/reqlogger.py b/src/wok/reqlogger.py index 6f32c44..8fadbcf 100644 --- a/src/wok/reqlogger.py +++ b/src/wok/reqlogger.py @@ -34,16 +34,17 @@ from wok.utils import ascii_dict, remove_old_files # Log search setup -FILTER_FIELDS = ['app', 'date', 'download', 'ip', 'req', 'user', 'time'] +FILTER_FIELDS = ['app', 'date', 'ip', 'req', 'status' 'user', 'time'] LOG_DOWNLOAD_URI = "/data/logs/%s" LOG_DOWNLOAD_TIMEOUT = 6 -LOG_FORMAT = "[%(date)s %(time)s %(zone)s] %(req)-6s %(app)-11s %(ip)-15s " \ - "%(user)s: %(message)s\n" +LOG_FORMAT = "[%(date)s %(time)s %(zone)s] %(req)-6s %(status)s %(app)-11s " \ + "%(ip)-15s %(user)s: %(message)s\n" RECORD_TEMPLATE_DICT = { 'date': '', 'time': '', 'zone': '', 'req': '', + 'status': '', 'app': '', 'ip': '', 'user': '', @@ -157,6 +158,7 @@ class RequestParser(object): uri = None results = [] records = self.getRecords() + download = filter_params.pop('download', False) # fail for unrecognized filter options for key in filter_params.keys(): @@ -164,8 +166,6 @@ class RequestParser(object): filters = ", ".join(FILTER_FIELDS) raise InvalidParameter("WOKLOG0001E", {"filters": filters}) - download = filter_params.pop('download', False) - # filter records according to parameters for record in records: if all(key in record and record[key] == val diff --git a/tests/test_api.py b/tests/test_api.py index 79f9af5..bcf34cb 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -84,7 +84,7 @@ class APITests(unittest.TestCase): self.assertGreaterEqual(records, 1) for record in records: keys = [u'zone', u'ip', u'app', u'req', u'user', u'time', u'date', - u'message'] + u'message', u'status'] self.assertEquals(sorted(keys), sorted(record.keys())) # Test search by app -- 1.9.1

Hi Lucio, IMO we should add the original exception raised to fail a request to a 'details' parameter in the JSON. So the user can check the reason the requested failed. The exception will be raised right after you record the log entry. That exception would be translate to the time of it was raised. So we will need to add a logic to record only its code and when requesting the user logs entries, it may be translated again to avoid showing a exception in Portuguese to other user requesting the log entries in Chinese, for example. Do you know what I mean? I have talked to you offline about the message, if there is need to have separated messages for success and failed action. For this first attempt, I recommend to use the same message (as you are doing in this patch set). There is no need to add a "FAILED" warning in the begging of the message as it can be easily added by the UI according to the status code. For example, on UI, if status code different than 20X it will prefix the message with "FAILED". What do you think about it? Also other point we need to think about is related to those actions that will generated a Task. For example, when creating/cloning a guest, the POST action will, on most of time, succeed but it will start a Task on background. But that Task may fail, ie, the guest creation/cloning failed by some reason but the POST action succeeded. How can we track that? Maybe we need to differentiate the actions which rely on Task to only record its success or failure when the Task has completed. Any ideas on how to do that? Regards, Aline Manera On 06/09/2016 05:59 PM, Lucio Correia wrote:
Important: * This patchset depends on [PATCH V2] [Wok 0/3] User Request Log improvements. * This patch requires "[Kimchi] Do not break the logging of failed requests". Otherwise, some tests will be broken.
Changes in V2: * Applied review suggestions
Lucio Correia (6): Revert "Use past verbs" Parse request before authorization check Use status code 200 for PUT requests on resource Log failed login/logout attempts Log failed user requests Add status code to request log message
docs/API/logs.md | 1 + src/wok/control/base.py | 130 ++++++++++++++++++++++-------------------------- src/wok/exception.py | 28 ++++++++--- src/wok/i18n.py | 4 +- src/wok/reqlogger.py | 10 ++-- src/wok/root.py | 44 +++++++++++----- tests/test_api.py | 2 +- 7 files changed, 122 insertions(+), 97 deletions(-)

Hi Aline, thanks for the feedback. See my comments below. On 16-06-2016 10:18, Aline Manera wrote:
Hi Lucio,
IMO we should add the original exception raised to fail a request to a 'details' parameter in the JSON. So the user can check the reason the requested failed.
The exception will be raised right after you record the log entry. That exception would be translate to the time of it was raised. So we will need to add a logic to record only its code and when requesting the user logs entries, it may be translated again to avoid showing a exception in Portuguese to other user requesting the log entries in Chinese, for example. Do you know what I mean?
Today we save only text in wok-req.log file, in json-friendly format. That file is the source for any request to /logs API. Today the translation is done at the moment of logging. So the above is a design change for the functionality because, in order to translate the message when /logs API is called, we need to save and recover the data differently.
I have talked to you offline about the message, if there is need to have separated messages for success and failed action. For this first attempt, I recommend to use the same message (as you are doing in this patch set). There is no need to add a "FAILED" warning in the begging of the message as it can be easily added by the UI according to the status code. For example, on UI, if status code different than 20X it will prefix the message with "FAILED". What do you think about it?
I'm OK with it.
Also other point we need to think about is related to those actions that will generated a Task. For example, when creating/cloning a guest, the POST action will, on most of time, succeed but it will start a Task on background. But that Task may fail, ie, the guest creation/cloning failed by some reason but the POST action succeeded. How can we track that? Maybe we need to differentiate the actions which rely on Task to only record its success or failure when the Task has completed. Any ideas on how to do that?
It will need further investigation, but one idea is to log the result of the task as well, and change the logging of requests that originate tasks to something like "task created for...". Considering all the above, I think this patch can be commited as is and then we work on the redesign, since they are not conflicting to each other.
Regards, Aline Manera
On 06/09/2016 05:59 PM, Lucio Correia wrote:
Important: * This patchset depends on [PATCH V2] [Wok 0/3] User Request Log improvements. * This patch requires "[Kimchi] Do not break the logging of failed requests". Otherwise, some tests will be broken.
Changes in V2: * Applied review suggestions
Lucio Correia (6): Revert "Use past verbs" Parse request before authorization check Use status code 200 for PUT requests on resource Log failed login/logout attempts Log failed user requests Add status code to request log message
docs/API/logs.md | 1 + src/wok/control/base.py | 130 ++++++++++++++++++++++-------------------------- src/wok/exception.py | 28 ++++++++--- src/wok/i18n.py | 4 +- src/wok/reqlogger.py | 10 ++-- src/wok/root.py | 44 +++++++++++----- tests/test_api.py | 2 +- 7 files changed, 122 insertions(+), 97 deletions(-)
-- Lucio Correia Software Engineer IBM LTC Brazil

On 06/16/2016 02:01 PM, Lucio Correia wrote:
Hi Aline, thanks for the feedback. See my comments below.
On 16-06-2016 10:18, Aline Manera wrote:
Hi Lucio,
IMO we should add the original exception raised to fail a request to a 'details' parameter in the JSON. So the user can check the reason the requested failed.
The exception will be raised right after you record the log entry. That exception would be translate to the time of it was raised. So we will need to add a logic to record only its code and when requesting the user logs entries, it may be translated again to avoid showing a exception in Portuguese to other user requesting the log entries in Chinese, for example. Do you know what I mean?
Today we save only text in wok-req.log file, in json-friendly format. That file is the source for any request to /logs API.
Today the translation is done at the moment of logging. So the above is a design change for the functionality because, in order to translate the message when /logs API is called, we need to save and recover the data differently.
I have talked to you offline about the message, if there is need to have separated messages for success and failed action. For this first attempt, I recommend to use the same message (as you are doing in this patch set). There is no need to add a "FAILED" warning in the begging of the message as it can be easily added by the UI according to the status code. For example, on UI, if status code different than 20X it will prefix the message with "FAILED". What do you think about it?
I'm OK with it.
Also other point we need to think about is related to those actions that will generated a Task. For example, when creating/cloning a guest, the POST action will, on most of time, succeed but it will start a Task on background. But that Task may fail, ie, the guest creation/cloning failed by some reason but the POST action succeeded. How can we track that? Maybe we need to differentiate the actions which rely on Task to only record its success or failure when the Task has completed. Any ideas on how to do that?
It will need further investigation, but one idea is to log the result of the task as well, and change the logging of requests that originate tasks to something like "task created for...".
Considering all the above, I think this patch can be commited as is and then we work on the redesign, since they are not conflicting to each other.
OK. I have open 3 new issues to cover what I have proposed above: https://github.com/kimchi-project/wok/issues/140 https://github.com/kimchi-project/wok/issues/141 https://github.com/kimchi-project/wok/issues/142 Please, take a look when you have a chance. Thanks, Aline Manera
Regards, Aline Manera
On 06/09/2016 05:59 PM, Lucio Correia wrote:
Important: * This patchset depends on [PATCH V2] [Wok 0/3] User Request Log improvements. * This patch requires "[Kimchi] Do not break the logging of failed requests". Otherwise, some tests will be broken.
Changes in V2: * Applied review suggestions
Lucio Correia (6): Revert "Use past verbs" Parse request before authorization check Use status code 200 for PUT requests on resource Log failed login/logout attempts Log failed user requests Add status code to request log message
docs/API/logs.md | 1 + src/wok/control/base.py | 130 ++++++++++++++++++++++-------------------------- src/wok/exception.py | 28 ++++++++--- src/wok/i18n.py | 4 +- src/wok/reqlogger.py | 10 ++-- src/wok/root.py | 44 +++++++++++----- tests/test_api.py | 2 +- 7 files changed, 122 insertions(+), 97 deletions(-)

Some tests cases are failing: ...... ====================================================================== FAIL: test_user_log (test_api.APITests) ---------------------------------------------------------------------- Traceback (most recent call last): File "test_api.py", line 88, in test_user_log self.assertEquals(sorted(keys), sorted(record.keys())) AssertionError: Lists differ: [u'app', u'date', u'ip', u'mes... != [u'app', u'date', u'ip', u'mes... First differing element 5: status time First list contains 1 additional elements. First extra element 8: zone + [u'app', u'date', u'ip', u'message', u'req', u'time', u'user', u'zone'] - [u'app', - u'date', - u'ip', - u'message', - u'req', - u'status', - u'time', - u'user', - u'zone'] ---------------------------------------------------------------------- Ran 28 tests in 10.319s FAILED (failures=1, skipped=2) On 06/09/2016 05:59 PM, Lucio Correia wrote:
Important: * This patchset depends on [PATCH V2] [Wok 0/3] User Request Log improvements. * This patch requires "[Kimchi] Do not break the logging of failed requests". Otherwise, some tests will be broken.
Changes in V2: * Applied review suggestions
Lucio Correia (6): Revert "Use past verbs" Parse request before authorization check Use status code 200 for PUT requests on resource Log failed login/logout attempts Log failed user requests Add status code to request log message
docs/API/logs.md | 1 + src/wok/control/base.py | 130 ++++++++++++++++++++++-------------------------- src/wok/exception.py | 28 ++++++++--- src/wok/i18n.py | 4 +- src/wok/reqlogger.py | 10 ++-- src/wok/root.py | 44 +++++++++++----- tests/test_api.py | 2 +- 7 files changed, 122 insertions(+), 97 deletions(-)

Hi Lucio, I cleaned up wok-req.log and the tests passed! =) Sorry about the noise. Regards, Aline Manera On 06/21/2016 05:05 PM, Aline Manera wrote:
Some tests cases are failing:
...... ====================================================================== FAIL: test_user_log (test_api.APITests) ---------------------------------------------------------------------- Traceback (most recent call last): File "test_api.py", line 88, in test_user_log self.assertEquals(sorted(keys), sorted(record.keys())) AssertionError: Lists differ: [u'app', u'date', u'ip', u'mes... != [u'app', u'date', u'ip', u'mes...
First differing element 5: status time
First list contains 1 additional elements. First extra element 8: zone
+ [u'app', u'date', u'ip', u'message', u'req', u'time', u'user', u'zone'] - [u'app', - u'date', - u'ip', - u'message', - u'req', - u'status', - u'time', - u'user', - u'zone']
---------------------------------------------------------------------- Ran 28 tests in 10.319s
FAILED (failures=1, skipped=2)
On 06/09/2016 05:59 PM, Lucio Correia wrote:
Important: * This patchset depends on [PATCH V2] [Wok 0/3] User Request Log improvements. * This patch requires "[Kimchi] Do not break the logging of failed requests". Otherwise, some tests will be broken.
Changes in V2: * Applied review suggestions
Lucio Correia (6): Revert "Use past verbs" Parse request before authorization check Use status code 200 for PUT requests on resource Log failed login/logout attempts Log failed user requests Add status code to request log message
docs/API/logs.md | 1 + src/wok/control/base.py | 130 ++++++++++++++++++++++-------------------------- src/wok/exception.py | 28 ++++++++--- src/wok/i18n.py | 4 +- src/wok/reqlogger.py | 10 ++-- src/wok/root.py | 44 +++++++++++----- tests/test_api.py | 2 +- 7 files changed, 122 insertions(+), 97 deletions(-)
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel
participants (2)
-
Aline Manera
-
Lucio Correia