Bug 54690 - [Kelvin API] ucsschool.lib drops one OU when adding and removing a school to/from a user at the same time
[Kelvin API] ucsschool.lib drops one OU when adding and removing a school to/...
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: Ucsschool-lib
UCS@school 4.4
Other Linux
: P5 normal (vote)
: ---
Assigned To: Johannes Keiser
Daniel Tröder
:
Depends on:
Blocks: 54694 54695 54411 54481
  Show dependency treegraph
 
Reported: 2022-04-25 18:02 CEST by Daniel Tröder
Modified: 2022-04-27 16:41 CEST (History)
0 users

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 5: Major Usability: Impairs usability in key scenarios
Who will be affected by this bug?: 1: Will affect a very 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.057
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

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2022-04-25 18:02:55 CEST
When a user has 2 OUs and in a modify operation one is removed and another is added, the additional OU is later missing in the "schools" attribute:

--------------------------------------------------------------------------------
user = Student(name="stud9", school="DEMOSCHOOL", schools=["DEMOSCHOOL", "school1"], firstname='James9', lastname='Bond9', school_classes={'DEMOSCHOOL': ['ds'], 'school1': ['s1']})
user.create(lo)

user.schools = ["DEMOSCHOOL", "school2"]
user.school_classes={'DEMOSCHOOL': ['ds'], 'school2': ['s2']}
user.modify(lo)

print("school={!r} schools={!r} school_classes={!r}".format(user.school, user.schools, user.school_classes))

→ school=u'DEMOSCHOOL' schools=[u'DEMOSCHOOL'] school_classes={'school2': ['s2'], 'DEMOSCHOOL': ['ds']}

--------------------------- validation -----------------------------------------
... UCS@school Object ... with options {...} has validation errors:
	- is not part of schools: ['school2'].
--------------------------------------------------------------------------------

Fix the ucsschool.lib in to contain all OUs in the "schools" attribute.

This bug is for UCS@school 4.4.
Split this bug into additional bugs for 5.0 and Kelvin.
Comment 1 Daniel Tröder univentionstaff 2022-04-27 13:04:23 CEST
The "schools" attribute is now correctly set, after removing a user from a school.

[feature/kelvin] c44563569 Bug #54690: fix removing and adding school in one go
[feature/kelvin] 0761cc43f Bug #54690: changelog
Comment 2 Daniel Tröder univentionstaff 2022-04-27 13:31:18 CEST
OK: code review

A few tests for adding and removing OUs from/to a user have been added:

[feature/kelvin] 4bcf677cb Bug #54690: add tests for adding and removing schools

OK: Both the tests for the ucsschool.lib and Kelvin now succeed.

A new Docker image for version 1.5.4 was built: ff6213b99e5d

Waiting for results from the Jenkins job.
Comment 3 Daniel Tröder univentionstaff 2022-04-27 15:14:25 CEST
OK The tests in the Jenkins job succeeded. Especially interesting:

94_ucsschool-api-kelvin/10_in_container_tests_kelvin_api → tests/test_route_user.py::test_change_school_

94_ucsschool-api-kelvin/10_in_container_tests_ucsschool_lib → ucsschool/lib/tests/test_user.py::test_modify_{add,remove}*_school

One _unrelated_ test failed. It was fixed:

[feature/kelvin] 90cc12212 Bug #54690: fix test: email domain must exist in ucs domain
A new Docker image for version 1.5.4 was built: f3ef9be32dfb
Comment 4 Daniel Tröder univentionstaff 2022-04-27 16:41:48 CEST
The Kelvin REST API version 1.5.4 has been released.

https://appcenter.software-univention.de/univention-repository/4.4/maintained/component/ucsschool-kelvin-rest-api_20220322152801/README_UPDATE_DE

If this error occurs again, please clone this bug.