# HG changeset patch # User Marcin Kuzminski # Date 2017-07-13 08:46:56 # Node ID edd50f390049328db5eb742254cfc550d929c4ff # Parent f0e0aac6440c5e84b2d6bbaefa723a2a2bfe8a1a ops: added redirect and exception ops view for testing. diff --git a/rhodecode/apps/ops/__init__.py b/rhodecode/apps/ops/__init__.py --- a/rhodecode/apps/ops/__init__.py +++ b/rhodecode/apps/ops/__init__.py @@ -25,6 +25,12 @@ def admin_routes(config): config.add_route( name='ops_ping', pattern='/ping') + config.add_route( + name='ops_error_test', + pattern='/error') + config.add_route( + name='ops_redirect_test', + pattern='/redirect') def includeme(config): diff --git a/rhodecode/apps/ops/views.py b/rhodecode/apps/ops/views.py --- a/rhodecode/apps/ops/views.py +++ b/rhodecode/apps/ops/views.py @@ -18,12 +18,14 @@ # RhodeCode Enterprise Edition, including its added features, Support services, # and proprietary license terms, please see https://rhodecode.com/licenses/ +import time import logging from pyramid.view import view_config +from pyramid.httpexceptions import HTTPFound from rhodecode.apps._base import BaseAppView - +from rhodecode.lib import helpers as h log = logging.getLogger(__name__) @@ -50,5 +52,26 @@ class OpsView(BaseAppView): }) return {'ok': data} + @view_config( + route_name='ops_error_test', request_method='GET', + renderer='json_ext') + def ops_error_test(self): + """ + Test exception handling and emails on errors + """ + class TestException(Exception): + pass + msg = ('RhodeCode Enterprise test exception. ' + 'Generation time: {}'.format(time.time())) + raise TestException(msg) + @view_config( + route_name='ops_redirect_test', request_method='GET', + renderer='json_ext') + def ops_redirect_test(self): + """ + Test redirect handling + """ + redirect_to = self.request.GET.get('to') or h.route_path('home') + raise HTTPFound(redirect_to) diff --git a/rhodecode/public/js/rhodecode/routes.js b/rhodecode/public/js/rhodecode/routes.js --- a/rhodecode/public/js/rhodecode/routes.js +++ b/rhodecode/public/js/rhodecode/routes.js @@ -60,6 +60,8 @@ function registerRCRoutes() { pyroutes.register('repo_integrations_create', '/%(repo_name)s/settings/integrations/%(integration)s/new', ['repo_name', 'integration']); pyroutes.register('repo_integrations_edit', '/%(repo_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_name', 'integration', 'integration_id']); pyroutes.register('ops_ping', '/_admin/ops/ping', []); + pyroutes.register('ops_error_test', '/_admin/ops/error', []); + pyroutes.register('ops_redirect_test', '/_admin/ops/redirect', []); pyroutes.register('admin_home', '/_admin', []); pyroutes.register('admin_audit_logs', '/_admin/audit_logs', []); pyroutes.register('pull_requests_global_0', '/_admin/pull_requests/%(pull_request_id)s', ['pull_request_id']);