Univention Bugzilla – Bug 55446
Support translations for password already used message
Last modified: 2022-12-21 20:23:38 CET
For some reason the UDM ModifyError message for already used passwords is not translated (other password errors are). Example (run twice to get the error, the user demo_student should exist and the IP and LDAP base should be adapted): ``` import asyncio from udm_rest_client import UDM async def test_password_save(mod_name, dn, new_password): async with UDM( "Administrator", "univention", "http://10.207.218.171/univention/udm", ssl_ca_cert='/usr/local/share/ca-certificates/ucs.crt', language="en" ) as udm: mod = udm.get("users/user") udm_obj = await mod.get(dn) udm_obj.props.password = new_password udm_obj.props.overridePWHistory = False udm_obj.props.overridePWLength = False await udm_obj.save() return udm_obj obj = asyncio.run(test_password_save("users/user", "uid=demo_student,cn=schueler,cn=users,ou=DEMOSCHOOL,dc=school,dc=test", "univentionunivention")) assert obj.props.password == "univentionunivention" ``` Result: ``` udm_rest_client.exceptions.ModifyError: 1 Fehler aufgetreten:Request-Argument "password" Password has been used before. Please choose a different one. ```
management/univention-directory-manager-modules/modules/univention/admin/uexceptions.py > 329 class pwalreadyused(base): > 330 » message = _('Password has been used before. Please choose a different one.') The translation is translated during import-time. The problem here is, that univention.admin is importing univention.admin.uexceptions and univention.admin.rest.__main__ imports univention.admin before it is able to set the process locale.
Reproducer: udm users/user create --set username=foo12345 --set lastname=univention --set password=univention --position="cn=users,$(ucr get ldap/base)" curl -s -H 'Accept: application/json' "https://Administrator:univention@localhost/univention/udm/users/user/uid=foo12345,cn=users,$(ucr get ldap/base)" -X PATCH -H 'Content-Type: application/json' -H 'Accept-Language: de_DE' -d '{"properties": {"password": "univention"}}' | python -m json.tool MR: https://git.knut.univention.de/univention/ucs/-/merge_requests/590
The uexceptions exceptions now translate the string again during str() evaluation, so that if the translation happened during import time the correct language is used when the locale is set after the import. univention-management-console-module-udm.yaml 3e7f6654317c | fix(udm): translate error messages again during exception evaluation univention-management-console-module-udm (10.0.2-5) 3e7f6654317c | fix(udm): translate error messages again during exception evaluation univention-directory-manager-rest.yaml 3e7f6654317c | fix(udm): translate error messages again during exception evaluation univention-directory-manager-rest (10.0.4-11) 3e7f6654317c | fix(udm): translate error messages again during exception evaluation univention-directory-manager-modules.yaml 64a70cc26c11 | chore(univention-directory-manager-modules): update advisory 3e7f6654317c | fix(udm): translate error messages again during exception evaluation univention-directory-manager-modules (15.0.13-27) 3e8d0bb300a7 | refactor: enhance use of exceptions 3e7f6654317c | fix(udm): translate error messages again during exception evaluation ucs-test-tools (9.0.0-2) 3e8d0bb300a7 | refactor: enhance use of exceptions ucs-test (10.0.7-30) f86d176769f2 | test(udm-rest): allow faster re-execution of test 3e8d0bb300a7 | refactor: enhance use of exceptions 3e7f6654317c | fix(udm): translate error messages again during exception evaluation
Checked: * Code review * Package build * Tested password already used message to appear in German. * Changelog and YAML advisory
<https://errata.software-univention.de/#/?erratum=5.0x521> <https://errata.software-univention.de/#/?erratum=5.0x522> <https://errata.software-univention.de/#/?erratum=5.0x523>