Bug 1328940 - Creating rate - should verify chargeback argument
Summary: Creating rate - should verify chargeback argument
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: API
Version: 5.6.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: GA
: 5.6.0
Assignee: Gregg Tanzillo
QA Contact: Martin Kourim
URL:
Whiteboard: c&u:chargeback:rest
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-04-20 16:23 UTC by Taras Lehinevych
Modified: 2019-01-24 14:28 UTC (History)
6 users (show)

Fixed In Version: 5.6.0.5
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-01-24 14:28:34 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:


Attachments (Terms of Use)

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"
    }
  ]
}


Note You need to log in before you can comment on or make changes to this bug.