Bug 42928 - Trying to create an existing group does not raise udm_errors.objectExists
Trying to create an existing group does not raise udm_errors.objectExists
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: App Center
UCS 4.1
Other Linux
: P5 normal (vote)
: UCS 4.1-4-errata
Assigned To: Dirk Wiesenthal
Florian Best
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-11-11 00:29 CET by Dirk Wiesenthal
Modified: 2016-12-14 12:36 CET (History)
1 user (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?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.023
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 (830 bytes, patch)
2016-11-11 11:15 CET, Florian Best
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Wiesenthal univentionstaff 2016-11-11 00:29:25 CET
When trying to create an already existing group, I get an exception (which is good). This exception is univention.admin.uexceptions.groupNameAlreadyUsed (which I think is bad).

When writing generic functions, I expect this to work:

def create_if_not_exists(object):
  try:
    obj.create()
  except udm_errors.objectExists:
    pass

It does not for groups. Did not test users. A function like this exists in the App Center. In the App Center itself, it is currently not called with 'groups/group', though.
Comment 1 Florian Best univentionstaff 2016-11-11 10:40:40 CET
See management/univention-directory-manager-modules/modules/univention/admincli/admin.py +745.

This bug - if it is correct usage of UDM - will probably also affect ucs-test.
Comment 2 Florian Best univentionstaff 2016-11-11 11:15:37 CET
Created attachment 8219 [details]
patch

If you want to get the objectExists exception you need to pass a DN.
This is not done in the current code, so you will never get objectExists!

I attached a patch which does what you want, it's not very nice but with the current function signature only this is possible.

The patch also fixes another misusage:
The code operates on obj.info directly. This must not be done. It causes that no syntax validations are done and even more validations like:
* property may not change
* property is required but not set
* property is not allowed to change on AD-objects
* it's not detected that a default value is overwritten, leading to followup-errors if the object is further used
* singlevalue properties might contain multiple entries
* property value has an invalid syntax
* property value with wrong encoding might be written into LDAP
Comment 3 Florian Best univentionstaff 2016-11-11 12:03:26 CET
management/univention-appcenter/umc/python/appcenter/app_center.py:»   »   »   »   container_obj.info['name'] = container
→ Also has to be fixed.
Comment 4 Dirk Wiesenthal univentionstaff 2016-11-25 12:20:23 CET
For now, it somehow does not matter. Needs to be fixed eventually, because more UDM objects will be created by univention-appcenter (like settings/extended_attribute)
Comment 5 Dirk Wiesenthal univentionstaff 2016-12-08 18:51:59 CET
univention-appcenter 5.0.23-18.246.201612081850
Comment 6 Florian Best univentionstaff 2016-12-13 10:17:13 CET
OK: fix
~OK: YAML (very technical but it is technical)
OK: workaround for Bug #43148
Comment 7 Janek Walkenhorst univentionstaff 2016-12-14 12:36:46 CET
<http://errata.software-univention.de/ucs/4.1/357.html>