Changeset - 644b7a16d29c
[Not reviewed]
default
0 2 0
Mads Kiilerich (mads) - 5 years ago 2021-01-11 00:06:52
mads@kiilerich.com
hooks: reserve .kallithea_ hooks namespace for internal use
2 files changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/admin/settings.py
Show inline comments
 
@@ -329,14 +329,14 @@ class SettingsController(base.BaseContro
 
                hook_id = request.POST.get('hook_id')
 

	
 
                try:
 
                    ui_key = ui_key and ui_key.strip()
 
                    if ui_key in (x.ui_key for x in db.Ui.get_custom_hooks()):
 
                        webutils.flash(_('Hook already exists'), category='error')
 
                    elif ui_key in (x.ui_key for x in db.Ui.get_builtin_hooks()):
 
                        webutils.flash(_('Builtin hooks are read-only. Please use another hook name.'), category='error')
 
                    elif ui_key and '.kallithea_' in ui_key:
 
                        webutils.flash(_('Hook names with ".kallithea_" are reserved for internal use. Please use another hook name.'), category='error')
 
                    elif ui_value and ui_key:
 
                        db.Ui.create_or_update_hook(ui_key, ui_value)
 
                        webutils.flash(_('Added new hook'), category='success')
 
                    elif hook_id:
 
                        db.Ui.delete(hook_id)
 
                        meta.Session().commit()
kallithea/tests/functional/test_admin_settings.py
Show inline comments
 
@@ -92,13 +92,13 @@ class TestAdminSettingsController(base.T
 
        self.log_user()
 
        response = self.app.post(base.url('admin_settings_hooks'),
 
                                params=dict(new_hook_ui_key='changegroup.kallithea_update',
 
                                            new_hook_ui_value='attempted_new_value',
 
                                            _session_csrf_secret_token=self.session_csrf_secret_token()))
 

	
 
        self.checkSessionFlash(response, 'Builtin hooks are read-only')
 
        self.checkSessionFlash(response, 'reserved for internal use')
 
        response = response.follow()
 
        response.mustcontain('changegroup.kallithea_update')
 

	
 
    def test_index_search(self):
 
        self.log_user()
 
        response = self.app.get(base.url('admin_settings_search'))
0 comments (0 inline, 0 general)