Bug 1328940

Summary: Creating rate - should verify chargeback argument
Product: Red Hat CloudForms Management Engine Reporter: Taras Lehinevych <tlehinev>
Component: APIAssignee: Gregg Tanzillo <gtanzill>
Status: CLOSED CURRENTRELEASE QA Contact: Martin Kourim <mkourim>
Severity: high Docs Contact:
Priority: high    
Version: 5.6.0CC: dajohnso, gtanzill, jhardy, nachandr, obarenbo, simaishi
Target Milestone: GA   
Target Release: 5.6.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: c&u:chargeback:rest
Fixed In Version: 5.6.0.5 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-01-24 14:28:34 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 Taras Lehinevych 2016-04-20 16:23:29 UTC
Description of problem:
You are able to add rate to any chargeback (non-existent) via REST API what could cause the unexpected error in UI.

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

How reproducible:
100%

Steps to Reproduce:
1. Add rate via REST API with argument chargeback_rate_id = 25658956
   chargeback_rate_id corresponds to non-existent id

Actual results:
The Rate is added successfully.

Expected results:
Error message about incorrect chargeback should be returned

Comment 2 Tim Wade 2016-05-02 18:13:45 UTC
PR: https://github.com/ManageIQ/manageiq/pull/8262

Comment 4 Satoe Imaishi 2016-10-07 15:25:05 UTC
This was fixed in 5.6.0.5. Please move to CLOSED CURRENTRELEASE if verification passes.

Comment 5 Martin Kourim 2016-10-18 12:33:30 UTC
Verified that it is no longer possible to create rate with non-existent chargeback_rate_id.



Request with non-existent chargeback_rate_id:

POST /api/rates
{"per_time": "daily", "chargeback_rate_id": 22222, "description": "test_rate_0_GWzpMP5qsYZ", "group": "cpu", "per_unit": "megahertz", "source": "allocated"}

Response:
{
  "error": {
    "kind": "bad_request",
    "message": "Chargeback rate can't be blank",
    "klass": "ApiController::BadRequestError"
  }
}



Request with existing chargeback_rate_id:

POST /api/rates
{"per_time": "daily", "chargeback_rate_id": 1, "description": "test_rate_0_GWzpMP5qsYZ", "group": "cpu", "per_unit": "megahertz", "source": "allocated"}

Response:
{
  "results": [
    {
      "id": 15,
      "enabled": true,
      "description": "test_rate_0_GWzpMP5qsYZ",
      "group": "cpu",
      "source": "allocated",
      "per_time": "daily",
      "per_unit": "megahertz",
      "friendly_rate": "",
      "chargeback_rate_id": 2,
      "created_on": "2016-10-18T12:30:31Z",
      "updated_on": "2016-10-18T12:30:31Z"
    }
  ]
}