Actions
Bug #22747
closedValidation on Puppet Class ID When using API
Description
When posting data to;
/api/v2/hosts/:host/puppetclass_ids
The Puppetclass ID is not validated and a successful response is return. While this doesn't cause any issues (it isn't evaluated against the hosts puppetclasses) it means that errant data can be inserted into the database which can then only be cleaned manually. It also can be misleading - particuarly when interfacing with external systems which get a positive response.
e.g
# curl -X POST http://localhost:5000/api/v2/hosts/testhost/puppetclass_ids -d '{"puppetclass_id":"THISISINVALID"}' -H 'Content-Type: application/json' {"host_id":1,"puppetclass_id":0}
# curl -X POST http://localhost:5000/api/v2/hosts/testhost/puppetclass_ids -d '{"puppetclass_id":"999999999"}' -H 'Content-Type: application/json' {"host_id":1,"puppetclass_id":999999999}
Submitting patch to add validation on create action and adding test.
Actions