Bug 51545 - make schema-checking code more robust
make schema-checking code more robust
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: Import scripts
UCS@school 4.4
Other Linux
: P5 normal (vote)
: UCS@school 4.4 v5-errata
Assigned To: Daniel Tröder
Tobias Wenzel
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-06-22 11:41 CEST by Daniel Tröder
Modified: 2020-07-30 13:14 CEST (History)
2 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 2: Improvement: Would be a product improvement
Who will be affected by this bug?: 1: Will affect a very few installed domains
How will those affected feel about the bug?: 5: Blocking further progress on the daily work
User Pain: 0.057
Enterprise Customer affected?:
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2020072021000202, 2020072121000264
Bug group (optional):
Max CVSS v3 score:
troeder: Patch_Available+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2020-06-22 11:41:24 CEST
A traceback occurred because of an unexpected entry:

[..]
  File "/usr/share/ucs-school-import/checks/defaults.py", line 132, in iterate_config
    if scheme_field.count("<") != scheme_field.count(">"):
AttributeError: 'bool' object has no attribute 'count'

The problem was the unexpected key "scheme:username:allow_rename".

Make the "check_scheme" test function in the "defaults" check hook more robust.
Comment 1 Daniel Tröder univentionstaff 2020-06-22 11:43:09 CEST
More robust code was added - untested!
Tests should be written to verify it.

[dtroeder/51545_schema_check a0cda8d51] Bug #51545: make schema-checking code more robust (WIP)
Comment 2 Tobias Wenzel univentionstaff 2020-07-02 13:40:37 CEST
QA

- Code -> looks good, few changes required (+)

Functionality
*****

I ran some manual tests and implemented a new ucs-test (see below) in

[dtroeder/51545_schema_check] ed39da0ec Bug #51545: Add test

defaults.py is missing username:scheme:default (+):

  File "/usr/share/ucs-school-import/checks/defaults.py", line 199, in test_scheme_valid_format
    "Unknown configuration key 'scheme:username:{}'.".format(k)
InitialisationError: Unknown configuration key 'scheme:username:default'.


I got the following expected errors:

adding scheme:username:allow_rename
-> InitialisationError: Deprecated configuration key 'scheme:username:allow_rename'.

setting scheme:username to "<:umlauts><firstname>.<lastname><:lower>[COUNTER2]"
-> InitialisationError: Value of 'scheme:username' must be a dict/object.

setting scheme.firstname to {"default" :...}
InitialisationError: Value of 'scheme:firstname' must be a string.

setting scheme:username:username to an int
InitialisationError: Value of 'scheme:username:username' must be a string.

-> mini-mistake: use k instead of name (+)

setting scheme:record_uid to an int
InitialisationError: Value of 'scheme:record_uid' must be a string.


ucs-test
*****

Check if no import error is raised for:

- scheme:username:   "default"** |  "staff" |  "student" | "teacher",           "teacher_and_staff" 
-scheme: "email" | "firstname" | "lastname" | "description" | "displayName" |    "employeeNumber"


Check if import error is raised for
- scheme:username:allow_rename (depr.)
- scheme:username is not allowed
- scheme: "email" | "firstname" | "lastname" | "description" | "displayName" |    "employeeNumber" and ":default"
- scheme:record_uid
- scheme:username:defaut: 123 | tuple, list

** This test fails because defaults.py is missing username:scheme:default
Comment 3 Daniel Tröder univentionstaff 2020-07-06 11:42:22 CEST
Thanks for hints, errors were fixed.
I modified the test to not hide exceptions.

[4.4] f2b866a70 Bug #51545: make schema-checking code more robust (WIP)
[4.4] 632e36694 Bug #51545: Add test
[4.4] 7a846a081 Bug #51545: Merge branch 'dtroeder/51545_schema_check' into 4.4
[4.4] 0b58d27ce Bug #51545: changelogs, advisory
[4.4] 0d2dd5143 Bug #51545: advisory update

ucs-school-import (17.0.37)
ucs-test-ucsschool (6.0.119)
Comment 5 Tobias Wenzel univentionstaff 2020-07-06 13:38:31 CEST
QA -> all ok -> VERIFY

Code -> ok
Changelog -> ok
Yaml -> ok
No merge conflicts -> ok
test are still passing -> ok
Comment 6 Christina Scheinig univentionstaff 2020-07-20 10:39:37 CEST
Is there a workaround, so the customer can import his teachers?
Comment 7 Christina Scheinig univentionstaff 2020-07-21 12:04:22 CEST
Happened again.
Comment 8 Christina Scheinig univentionstaff 2020-07-21 12:06:58 CEST
I now set the blocking affect. Everytime this traceback occurs the customer cannot import anymore. And this causes a support ticket.
Comment 9 Tobias Wenzel univentionstaff 2020-07-30 13:14:48 CEST
UCS@school 4.4 v5 has been released (errata update to the release).

http://docs.software-univention.de/changelog-ucsschool-4.4v5-de.html#changelog:ucsschool:2020-07-30

If this error occurs again, please clone this bug.