Bug 1660237

Summary: Default dialog values not populated when API auth type is auth token
Product: Red Hat CloudForms Management Engine Reporter: Satoe Imaishi <simaishi>
Component: APIAssignee: Gregg Tanzillo <gtanzill>
Status: CLOSED ERRATA QA Contact: Parthvi Vala <pvala>
Severity: urgent Docs Contact: Red Hat CloudForms Documentation <cloudforms-docs>
Priority: urgent    
Version: 5.9.5CC: cpelland, obarenbo
Target Milestone: GAKeywords: ZStream
Target Release: 5.9.7   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.9.7.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1659602 Environment:
Last Closed: 2019-01-23 14:35:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: CFME Core Target Upstream Version:
Embargoed:
Bug Depends On: 1659602    
Bug Blocks:    

Comment 2 Satoe Imaishi 2018-12-18 17:17:48 UTC
https://github.com/ManageIQ/manageiq-api/pull/530

Comment 4 Parthvi Vala 2019-01-10 13:09:36 UTC
FIXED. Verified on 5.9.7.2.

Steps taken to verify:
1. Set `run_automate_methods_on_service_api_submit` to `true`.
2. Get the authentication token by sending a request to GET /api/auth.
3. Create a new domain, `domain_1`.
4. Create a Method, let's say `method_1`.
5. Create an instance, let's say `instance_1`.
6. Create a Dialog with one static element(name="static", value_type="Integer", read_only=True, required=True) with some default value, and one dynamic element(name="dynamic", value_type="Integer", read_only=True, required=True) with the endpoint pointing to `method_1` which returns default value.
7. Create a Catalog, say `catalog_1`.
8. Create a Generic Catalog item under the newly create Catalog, say `catalog_item_1`.
9. Get the `service_catalog` id and `service_template` id.
10. Send the request.

Method used: https://bugzilla.redhat.com/attachment.cgi?id=1498504

This method sets value 2 for static element and 7 for the dynamic element, both of which are reflected in the response.

Request:
curl "https://<ip_address>/api/service_catalogs/1/service_templates/1" -k -X POST -H "Content-Type" -d '{"action" : "order"}' -H "X-Auth-Token: 99e4c7176dabff26ca859a04b9c1e5dd" -H "X-MIQ-Group: EvmGroup-super_administrator"

Response:
{
    "href": "https://<ip_address>/api/service_requests/1",
    "id": "1",
    "description": "Provisioning Service [catalog_item_1] from [catalog_item_1]",
    "approval_state": "pending_approval",
    "type": "ServiceTemplateProvisionRequest",
    "created_on": "2019-01-10T12:59:13Z",
    "updated_on": "2019-01-10T12:59:13Z",
    "requester_id": "1",
    "requester_name": "Administrator",
    "request_type": "clone_to_service",
    "request_state": "pending",
    "message": "Service_Template_Provisioning - Request Created",
    "status": "Ok",
    "options": {
        "dialog": {
            "dialog_static": 2,
            "dialog_dynamic": 7
        },
        "workflow_settings": {
            "resource_action_id": "23",
            "dialog_id": "2"
        },
        "src_id": "1",
        "request_options": {
            "submit_workflow": true,
            "init_defaults": true
        },
        "cart_state": "ordered",
        "requester_group": "EvmGroup-super_administrator"
    },
    "userid": "admin",
    "source_id": "1",
    "source_type": "ServiceTemplate",
    "tenant_id": "1",
    "service_order_id": "1",
    "process": true,
    "service_templates": {
        "count": 1,
        "resources": [{
            "href": "https://<ip_address>/api/service_catalogs/1/service_templates/1"
        }],
        "actions": [{
            "name": "edit",
            "method": "post",
            "href": "https://<ip_address>/api/service_catalogs/1/service_templates"
        }, {
            "name": "delete",
            "method": "post",
            "href": "https://<ip_address>/api/service_catalogs/1/service_templates"
        }, {
            "name": "order",
            "method": "post",
            "href": "https://<ip_address>/api/service_catalogs/1/service_templates"
        }, {
            "name": "refresh_dialog_fields",
            "method": "post",
            "href": "https://<ip_address>/api/service_catalogs/1/service_templates"
        }, {
            "name": "assign",
            "method": "post",
            "href": "https://<ip_address>/api/service_catalogs/1/service_templates"
        }, {
            "name": "unassign",
            "method": "post",
            "href": "https://<ip_address>/api/service_catalogs/1/service_templates"
        }]
    }
}

Comment 6 errata-xmlrpc 2019-01-23 14:35:55 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:0110