Bug 57208 - Hook `ext_config_dep_on_role.py` does not support role `teacher_and_staff`.
Summary: Hook `ext_config_dep_on_role.py` does not support role `teacher_and_staff`.
Status: CLOSED FIXED
Alias: None
Product: UCS@school
Classification: Unclassified
Component: Import scripts
Version: UCS@school 5.0
Hardware: Other Linux
: P5 normal
Target Milestone: UCS@school 5.0 v5-errata
Assignee: Alexander Steffen
QA Contact: Ole Schwiegert
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-03 16:36 CEST by Johannes Königer
Modified: 2024-09-13 15:42 CEST (History)
3 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 3: Simply Wrong: The implementation doesn't match the docu
Who will be affected by this bug?: 2: Will only affect a few installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.069
Enterprise Customer affected?:
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2024040321000153, 2024080121000211
Bug group (optional):
Customer ID:
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Königer univentionstaff 2024-04-03 16:36:58 CEST
The hook `ext_config_dep_on_role.py` does not support the role `teacher_and_staff`. As we support importing that role generally, this hook should also work with this role.

The test `90_ucsschool/246_import_user_config_pyhook.py` fails while loading the configuration, but passes anyway:

```
2024-04-03 15:33:19 INFO  import_pyhook.call_hooks:165  Running ImportPyHookLoader post_config_files_read hook <bound method ExtendConfigByRole.post_config_files_read of <test246_config_modification.ExtendConfigByRole object at 0x7f598426a780>> ...
2024-04-03 15:33:19 ERROR test246_config_modification.preconditions_met:127  Exiting hook: unknown role 'teacher_and_staff'.
```

We need to add `teacher_and_staff` to the supported roles of the hook and review/rework the test.
Comment 1 Mirac Erdemiroglu univentionstaff 2024-08-02 12:50:35 CEST
Informations from another ticket and rocketchat to solve this issue:

This is the diff for the file in the pyhooks-available folder:
diff --git a/ucs-school-import/usr/share/ucs-school-import/pyhooks-available/ext_config_dep_on_role.py b/ucs-school-import/usr/share/ucs-school-import/pyhooks-available/ext_config_dep_on_role.py
index 43ecf14e4..aa58d7378 100644
--- a/ucs-school-import/usr/share/ucs-school-import/pyhooks-available/ext_config_dep_on_role.py
+++ b/ucs-school-import/usr/share/ucs-school-import/pyhooks-available/ext_config_dep_on_role.py
@@ -123,7 +123,7 @@ class ExtendConfigByRole(ConfigPyHook):
         if config.get("user_role") is None:
             self.logger.error('Exiting hook: hook requires a fixed role but "user_role" is None.')
             return False
-        if config["user_role"] not in list(supported_roles) + ["student"]:
+        if config["user_role"] not in list(supported_roles) + ["student", "teacher_and_staff"]:
             self.logger.error("Exiting hook: unknown role %r.", config["user_role"])
             return False
         if config["user_role"] not in config["include"]["by_role"]:

But apply this to the file in /usr/share/ucs-school-import/pyhooks/, not in /usr/share/ucs-school-import/pyhooks-available/.


or


udm users/user modify \
--dn uid='testlehrer,cn=lehrer,cn=users,ou=GrundschuleUnivention,dc=school,dc=intranet' \
--append-option=ucsschoolStaff \
--append ucsschoolRole=staff:school:GrundschuleUnivention \
--append groups='cn=mitarbeiter-GrundschuleUnivention,cn=groups,ou=GrundschuleUnivention,dc=school,dc=intranet'

udm users/user move \
--dn uid='testlehrer,cn=lehrer,cn=users,ou=GrundschuleUnivention,dc=school,dc=intranet' \
--position 'cn=lehrer und mitarbeiter,cn=users,ou=GrundschuleUnivention,dc=school,dc=intranet'
Comment 3 Alexander Steffen univentionstaff 2024-08-19 08:40:36 CEST
Fixed with

Package: ucs-school-import
Version: 18.0.48
Branch: 5.0-0
Scope: ucs-school-5.0
Comment 4 Jürn Brodersen univentionstaff 2024-09-13 15:42:44 CEST
Errata updates for UCS@school 5.0 v5 have been released.

https://docs.software-univention.de/ucsschool-changelog/5.0v5/en/changelog.html
https://docs.software-univention.de/ucsschool-changelog/5.0v5/de/changelog.html

If this error occurs again, please clone this bug.