Univention Bugzilla – Bug 54535
make validation of ucsschool roles more robust
Last modified: 2022-07-15 08:31:10 CEST
ucsschool-roles with a format other than role:school:context will raise errors, e.g. in the umc Interner Server-Fehler in "schoolwizards/users/query (schoolwizards/users)". Request: schoolwizards/users/query (schoolwizards/users) ucsschool/lib/models/validator.py errors.append(cls.validate_part_of_school(roles, schools)) File "/usr/lib/python2.7/dist-packages/ucsschool/lib/models/validator.py", line 228, in validate_part_of_school missing_schools = set([s for r, c, s in roles if c == "school" and s.lower() not in schools]) ValueError: need more than 2 values to unpack These errors come from an incorrect of the school role, but we should log an error with a better description of whats wrong. ... e.g. the function split_roles could be refactored into one of the validation classes, log and a) return only values as tuples (r,c,s) or b) return an empty list.
split_roles is a more simple implementation of get_role_info in roles.py. I would like to see the validation module use the common function to split the roles, instead of using its own implementation. The common get_role_info also already throws exceptions for wrong and malformed roles. This could be catched and transformed into an error message. -> I propose replacing split_role with get_role_info
The validate method now logs in /var/log/univention/management-console-web-server.log if non-canonical ucsschool-role strings are encountered (instead of throwing exceptions), and passes spitted strings to part_of_school and student_roles validatores otherwise.
Package was built! Package: ucs-school-lib Version: 13.0.13A~5.0.0.202204051400 Branch: ucs_5.0-0 Scope: ucs-school-5.0
Manual & Automatic tests look fine, change works, - VERIFIED
The fix for Kelvin will be implemented in Bug #54653
flake8...................................................................Failed - hook id: flake8 - exit code: 1 ucs-school-lib/unittests/test_roles_valid.py:4:1: E402 module level import not at top of file ucs-school-lib/unittests/test_roles_valid.py:5:1: E402 module level import not at top of file ucs-school-lib/unittests/test_roles_valid.py:6:1: E402 module level import not at top of file ucs-school-lib/unittests/test_roles_valid.py:6:1: F401 'ucsschool.lib.roles.all_roles' imported but unused ucs-school-lib/unittests/test_roles_valid.py:36:106: E501 line too long (140 > 105 characters) ucs-school-lib/unittests/test_roles_valid.py:146:106: E501 line too long (126 > 105 characters) ucs-school-lib/unittests/test_roles_valid.py:158:106: E501 line too long (137 > 105 characters)
This test failure looks like it is related to this bug: https://univention-dist-jenkins.k8s.knut.univention.de/job/UCSschool-5.0/job/Install%20Singleserver/lastCompletedBuild/Config=s4,TestGroup=import1,UCSRelease=testing/testReport/(root)/90_ucsschool/407_ucsschool_lib_validation_users/ Could you take a look? Thanks :)
Package: ucs-test-ucsschool Version: 7.3.37A~5.0.0.202204131244 Branch: ucs_5.0-0 Scope: ucs-school-5.0 Package: ucs-school-lib Version: 13.0.15A~5.0.0.202204131253 Branch: ucs_5.0-0 Scope: ucs-school-5.0 fixed in: 1da048dcc8c10c5e516898cfc9879c8e5c1417c1 13105648be47448d593ccbc02ca072bd58bb896e
QA: All OK - changelog OK - advisory OK - jenkins looks good OK -> verify
UCS@school 5.0 v2 has been released. https://docs.software-univention.de/changelog-ucsschool-5.0v2-de.html If this error occurs again, please clone this bug.