Bug 1394207

Summary: create a group and specifying a role via the identifier 'id' does not work via API (WORKAROUND: use 'href' or 'name' identifiers)
Product: Red Hat CloudForms Management Engine Reporter: Reartes Guillermo <greartes>
Component: APIAssignee: Tim Wade <twade>
Status: CLOSED NOTABUG QA Contact: Martin Kourim <mkourim>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.6.0CC: cpelland, jhardy, obarenbo, twade
Target Milestone: GA   
Target Release: cfme-future   
Hardware: x86_64   
OS: Linux   
Whiteboard: rest:api
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-04-07 19:50:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Reartes Guillermo 2016-11-11 12:00:22 UTC
Description of problem:

Creating a role specifying a role does not work when the role identifier is "id". It does work with "href" and "name".

Version-Release number of selected component (if applicable):
CFME: 5.6.2.2

How reproducible:
Always

Steps to Reproduce:

Example #1: (NOT WORKING):
----------------------


    new_group_json = {
        "action" : "create",
        "resource" : {
            "description" : NEW_GROUP,
            "role" : { "id" : result_role_id }
            }
        }


INFO: Role "1000000000018" exists.
INFO: Group name "ccc4" will be created.

G:     ccc4
R: ID: 1000000000018
R: HR: https://cfme1.example.com/api/roles/1000000000018
R:  N: aaa

ERROR: bad_request [ApiController::BadRequestError]
ERROR: Missing Role identifier href, id or name

{u'error': {u'kind': u'bad_request',
            u'klass': u'ApiController::BadRequestError',
            u'message': u'Missing Role identifier href, id or name'}}

{'action': 'create',
 'resource': {'description': 'ccc4', 'role': {'id': '1000000000018'}}}


Actual results:
One must specify the role via 'href' or 'name' and not by 'id'.

Expected results:
It should work.


Additional info:


Example #2: (WORKING):
----------------------

    new_group_json = {
        "action" : "create",
        "resource" : {
            "description" : NEW_GROUP,
            "role" : { "name" : result_role_name }
            }
        }

INFO: Role "1000000000018" exists.
INFO: Group name "ccc2" will be created.

G:     ccc2
R: ID: 1000000000018
R: HR: https://cfme1.example.com/api/roles/1000000000018
R:  N: aaa

INFO: GROUP was created.



Example #3: (WORKING):
----------------------

    new_group_json = {
        "action" : "create",
        "resource" : {
            "description" : NEW_GROUP,
            "role" : { "href" : result_role_href }
            }
        }

INFO: Role "1000000000018" exists.
INFO: Group name "ccc3" will be created.

G:     ccc3
R: ID: 1000000000018
R: HR: https://cfme1.example.com/api/roles/1000000000018
R:  N: aaa

INFO: GROUP was created.



Logs (evm.log):
---------------

[----] E, [2016-11-11T08:53:42.996605 #3031:e54db8] ERROR -- : <API> MIQ(ApiController.api_error) API Error
[----] E, [2016-11-11T08:53:42.996779 #3031:e54db8] ERROR -- : <API> MIQ(ApiController.api_error) ApiController::BadRequestError: Missing Role identifier href, id or name