Bug 42495 - Membership of working groups or global groups get removed if user is modified via ucs-school-lib
Membership of working groups or global groups get removed if user is modified...
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: Ucsschool-lib
UCS@school 4.1 R2
Other Linux
: P5 enhancement (vote)
: UCS@school 4.1 R2 vXXX
Assigned To: Florian Best
Daniel Tröder
: interim-3
Depends on: 41907
Blocks: 42251
  Show dependency treegraph
 
Reported: 2016-09-23 18:35 CEST by Florian Best
Modified: 2016-12-12 13:10 CET (History)
4 users (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments
patch (4.25 KB, patch)
2016-09-23 18:35 CEST, Florian Best
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2016-09-23 18:35:02 CEST
Created attachment 8029 [details]
patch

Attached is the correct fix for Bug #41907. It reverts the things of Bug #41907 and Bug #42251.
The test test_modify_with_several_groups() still pass with the patch.

+++ This bug was initially created as a clone of Bug #41907 +++

If a user is modified via ucs-school-lib, the lib removes all group memberships that are not listed in school_classes. Even the memberships of
- working groups
- groups in school OU
- global groups
are removed.
Comment 1 Sönke Schwardt-Krummrich univentionstaff 2016-09-26 11:33:05 CEST
The patch corrects the broken API and makes the workaround therefore obsolete. The patch should be applied in interim-3 round.
Comment 2 Florian Best univentionstaff 2016-11-14 19:20:00 CET
Applied the patch and did some whitespace pep8 E101 cleanup.

ucs-school-lib (9.0.29-1):
r74422 | Bug #42495: optimize internal handling of group modifications

ucs-school-lib.yaml:
r74423 | YAML Bug #42495
Comment 3 Daniel Tröder univentionstaff 2016-11-25 12:37:12 CET
OK: automated tests:
# for TEST in
/usr/share/ucs-test/90_ucsschool/05_ucs-school-workinggroup-module-check /usr/share/ucs-test/90_ucsschool/36_import-groups_via_cli
/usr/share/ucs-test/90_ucsschool/36_import-groups_via_python_api
/usr/share/ucs-test/90_ucsschool/101_exam_mode_group_members
/usr/share/ucs-test/90_ucsschool/105_activate_groupmembers
/usr/share/ucs-test/90_ucsschool/213_import-users_modify_with_several_groups;
do $TEST -f || break; done
OK: advisory

REOPEN: if a User is removed from a secondary school (not a school change), it's not removed from the classes and workgroups of that school:

from ucsschool.lib.models import Student, WorkGroup
stud3 = Student(
    school="SchuleEinz",
    schools=["SchuleEinz", "SchuleZwei"],
    name="stud3",
    email="stud3@uni.dtr",
    firstname="stud3fn",
    lastname="stud3ln",
    school_classes={"SchuleEinz": ["SchuleEinz-1A"], "SchuleZwei": ["SchuleZwei-2B"]})
stud3.create(lo)
WorkGroup(school="SchuleEinz", name="wg1", users=[stud3.dn]).create(lo)
WorkGroup(school="SchuleZwei", name="wg2", users=[stud3.dn]).create(lo)
stud3 = Student.from_dn(stud3.dn, None, lo)
print 'stud3.school:', stud3.school
print 'stud3.schools:', stud3.schools
print 'stud3.school_classes:', stud3.school_classes
print 'stud3.get_udm_object(lo)[groups]:', stud3.get_udm_object(lo)['groups']
===============================================================
stud3.school: SchuleEinz
stud3.schools: ['SchuleZwei', 'SchuleEinz']
stud3.school_classes: {'SchuleZwei': ['SchuleZwei-2B'], 'SchuleEinz': ['SchuleEinz-1A']}
stud3.get_udm_object(lo)[groups]: ['cn=schueler-schuleeinz,cn=groups,ou=SchuleEinz,dc=uni,dc=dtr', 'cn=Domain Users schuleeinz,cn=groups,ou=SchuleEinz,dc=uni,dc=dtr', 'cn=SchuleEinz-1A,cn=klassen,cn=schueler,cn=groups,ou=SchuleEinz,dc=uni,dc=dtr', 'cn=schueler-schulezwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr', 'cn=Domain Users SchuleZwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr', 'cn=SchuleZwei-2B,cn=klassen,cn=schueler,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr', 'cn=wg1,cn=schueler,cn=groups,ou=SchuleEinz,dc=uni,dc=dtr', 'cn=wg2,cn=schueler,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr']
===============================================================
stud3.schools.remove('SchuleZwei')
stud3.modify(lo)
print 'stud3.school:', stud3.school
print 'stud3.schools:', stud3.schools
print 'stud3.school_classes:', stud3.school_classes
print 'stud3.get_udm_object(lo)[groups]:', stud3.get_udm_object(lo)['groups']
===============================================================
stud3.school: SchuleEinz
stud3.schools: ['SchuleEinz']
stud3.school_classes: {'SchuleZwei': ['SchuleZwei-2B'], 'SchuleEinz': ['SchuleEinz-1A']}
stud3.get_udm_object(lo)[groups]: ['cn=schueler-schuleeinz,cn=groups,ou=SchuleEinz,dc=uni,dc=dtr', 'cn=Domain Users schuleeinz,cn=groups,ou=SchuleEinz,dc=uni,dc=dtr', 'cn=SchuleEinz-1A,cn=klassen,cn=schueler,cn=groups,ou=SchuleEinz,dc=uni,dc=dtr', 'cn=schueler-schulezwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr', 'cn=Domain Users SchuleZwei,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr', 'cn=SchuleZwei-2B,cn=klassen,cn=schueler,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr', 'cn=wg1,cn=schueler,cn=groups,ou=SchuleEinz,dc=uni,dc=dtr', 'cn=wg2,cn=schueler,cn=groups,ou=SchuleZwei,dc=uni,dc=dtr']


Removing 'SchuleZwei' from school_classes (stud3.school_classes.pop('SchuleZwei')) doesn't change this.


When fixing, please enhance 213_import-users_modify_with_several_groups to check for this case.
Comment 4 Florian Best univentionstaff 2016-11-25 16:06:43 CET
(In reply to Daniel Tröder from comment #3)
> REOPEN: if a User is removed from a secondary school (not a school change),
> it's not removed from the classes and workgroups of that school:

> stud3.schools.remove('SchuleZwei')
→ Please use the official way to remove the user from that school:
stud3.remove_from_school('SchuleZwei', lo)

If you want the API be changed for supporting schools.remove() then please fill a new bug.
Comment 5 Daniel Tröder univentionstaff 2016-11-25 16:46:36 CET
(In reply to Florian Best from comment #4)
> (In reply to Daniel Tröder from comment #3)
> > REOPEN: if a User is removed from a secondary school (not a school change),
> > it's not removed from the classes and workgroups of that school:
> 
> > stud3.schools.remove('SchuleZwei')
> → Please use the official way to remove the user from that school:
> stud3.remove_from_school('SchuleZwei', lo)
OK - that works as expected.

With this, all is verified.

> If you want the API be changed for supporting schools.remove() then please
> fill a new bug.
I don't want the API changed - I want it documented.
Comment 6 Sönke Schwardt-Krummrich univentionstaff 2016-12-12 13:10:21 CET
UCS@school 4.1 R2 v9 has been released.

http://docs.software-univention.de/changelog-ucsschool-4.1R2v9-de.html