mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 00:14:44 +01:00
Merge test-translations: include "ignore" in exec prompts + make debugging hotkey conflicts easier
This is a follow-up of adding the "ignore" option to exec prompts in https://gitlab.com/apparmor/apparmor/-/merge_requests/1543 To make future handling of hotkey conflicts easier, - display all hotkey conflicts at once instead of erroring out at the first conflict. - display all options involved in a hotkey conflict to make fixing it easier. Since 1543 was picked into 4.1, I propose the same for this MR. MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1557 Approved-by: John Johansen <john@jjmx.net> Merged-by: John Johansen <john@jjmx.net>
This commit is contained in:
commit
0e8377cde9
1 changed files with 15 additions and 3 deletions
|
@ -29,8 +29,8 @@ class TestHotkeyConflicts(AATest):
|
|||
(('CMD_ALLOW', 'CMD_DENY', 'CMD_IGNORE_ENTRY', 'CMD_GLOB', 'CMD_GLOBEXT', 'CMD_NEW', 'CMD_AUDIT_NEW', 'CMD_USER_OFF', 'CMD_ABORT', 'CMD_FINISHED'), True), # aa.py available_buttons() with CMD_AUDIT_NEW and CMD_USER_OFF
|
||||
(('CMD_SAVE_CHANGES', 'CMD_SAVE_SELECTED', 'CMD_VIEW_CHANGES', 'CMD_VIEW_CHANGES_CLEAN', 'CMD_ABORT'), True), # aa.py save_profiles()
|
||||
(('CMD_VIEW_PROFILE', 'CMD_USE_PROFILE', 'CMD_CREATE_PROFILE', 'CMD_ABORT'), True), # aa.py get_profile()
|
||||
(('CMD_ix', 'CMD_pix', 'CMD_cix', 'CMD_nix', 'CMD_EXEC_IX_OFF', 'CMD_ux', 'CMD_DENY', 'CMD_ABORT', 'CMD_FINISHED'), True), # aa.py build_x_functions() with exec_toggle
|
||||
(('CMD_ix', 'CMD_cx', 'CMD_px', 'CMD_nx', 'CMD_ux', 'CMD_EXEC_IX_ON', 'CMD_DENY', 'CMD_ABORT', 'CMD_FINISHED'), True), # aa.py build_x_functions() without exec_toggle
|
||||
(('CMD_ix', 'CMD_pix', 'CMD_cix', 'CMD_nix', 'CMD_EXEC_IX_OFF', 'CMD_ux', 'CMD_DENY', 'CMD_ABORT', 'CMD_FINISHED', 'CMD_IGNORE_ENTRY'), True), # aa.py build_x_functions() with exec_toggle
|
||||
(('CMD_ix', 'CMD_cx', 'CMD_px', 'CMD_nx', 'CMD_ux', 'CMD_EXEC_IX_ON', 'CMD_DENY', 'CMD_ABORT', 'CMD_FINISHED', 'CMD_IGNORE_ENTRY'), True), # aa.py build_x_functions() without exec_toggle
|
||||
(('CMD_ADDHAT', 'CMD_USEDEFAULT', 'CMD_DENY', 'CMD_ABORT', 'CMD_FINISHED'), True), # aa.py ask_addhat()
|
||||
(('CMD_YES', 'CMD_NO', 'CMD_CANCEL'), True), # ui.py UI_YesNo() and UI_YesNoCancel
|
||||
(('CMD_SAVE_CHANGES', 'CMD_VIEW_CHANGES', 'CMD_ABORT', 'CMD_IGNORE_ENTRY'), True), # aa-mergeprof act()
|
||||
|
@ -59,6 +59,8 @@ class TestHotkeyConflicts(AATest):
|
|||
# we also want to detect hotkey conflicts in the untranslated english strings
|
||||
self.languages.append('C')
|
||||
|
||||
conflicts = []
|
||||
|
||||
for language in self.languages:
|
||||
with self.subTest(language=language):
|
||||
t = gettext.translation(
|
||||
|
@ -67,15 +69,25 @@ class TestHotkeyConflicts(AATest):
|
|||
)
|
||||
|
||||
keys = {}
|
||||
all_keys = []
|
||||
found_conflict = ''
|
||||
|
||||
for key in params:
|
||||
text = t.gettext(CMDS[key])
|
||||
all_keys.append(text)
|
||||
hotkey = get_translated_hotkey(text)
|
||||
|
||||
if keys.get(hotkey):
|
||||
raise Exception("Hotkey conflict: '{}' and '{}'".format(keys[hotkey], text))
|
||||
found_conflict = "Hotkey conflict for {}: '{}' and '{}'".format(language, keys[hotkey], text)
|
||||
else:
|
||||
keys[hotkey] = text
|
||||
|
||||
if found_conflict:
|
||||
conflicts.append("{}\n {}'".format(found_conflict, ' '.join(all_keys)))
|
||||
|
||||
if conflicts:
|
||||
raise Exception('\n'.join(conflicts))
|
||||
|
||||
|
||||
setup_all_loops(__name__)
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Reference in a new issue