Bug 50972 - allow setting properties that only exist after enabling an option
allow setting properties that only exist after enabling an option
Status: RESOLVED FIXED
Product: Components
Classification: Unclassified
Component: udm-rest-api-client
unspecified
Other Linux
: P5 normal (vote)
: ---
Assigned To: Daniel Tröder
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-03-18 11:41 CET by Daniel Tröder
Modified: 2020-03-24 12:03 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

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2020-03-18 11:41:59 CET
The udm-rest-api-client currently does not support adding a property to an object, if the object didn't have it when retrieved:

---------------------------------------------------------------------------
import asyncio
from udm_rest_client import UDM

async def test(): 
    async with UDM("Administrator", "s3cr3t", "https://<IP>/univention/udm", verify_ssl=False) as udm:
        obj = await udm.get("users/user").get("uid=test3,cn=users,<basedn>") 
        setattr(obj.props, "school", ["DEMOSCHOOL"])  
        await obj.save() 

asyncio.run(test())                                                                                                                        
---------------------------------------------------------------------------
in test()
      3         obj = await udm.get("users/user").get("uid=test3,cn=users,<basedn>")
      4         setattr(obj.props, "school", ["DEMOSCHOOL"])
----> 5         await obj.save()

base_http.py in save(self)
    630                     if isinstance(value, list):
    631                         new_value = set(value)
--> 632                         old_value = set(old_obj["properties"][prop])
    633                     else:
    634                         new_value = value

KeyError: 'school'
Comment 1 Daniel Tröder univentionstaff 2020-03-18 11:46:18 CET
Scenario for this is a deactivated option (maybe added by an app) of an existing object. When off, certain properties would not exist for the object. It should be possible to enable the option and at the same time set the value of the attribute.
Comment 2 Daniel Tröder univentionstaff 2020-03-18 14:00:30 CET
It is now possible to set previously not existent properties.

0033c56 Bug #50972: allow setting properties that only exist after enabling an option
ce7928b Bug #50972: add test for setting unknown properties
0a2fdd8 Bug #50972: version 0.3.0

A new version (0.3.0) was released on PyPI:
* https://test.pypi.org/project/udm-rest-client/0.3.0/#description
* https://pypi.org/project/udm-rest-client/0.3.0/

Coverage: https://codecov.io/gh/univention/python-udm-rest-api-client/commit/0a2fdd801cf82c4aedfc7be3a41c3397e95c76ab

Documentation: https://udm-rest-client.readthedocs.io/en/stable/

Tests for 3.6, 3.7 and 3.8: https://travis-ci.com/github/univention/python-udm-rest-api-client/builds/153908671