Bug 1388148 - API host PUT uses fields not in host hash as filter
Summary: API host PUT uses fields not in host hash as filter
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hosts
Version: 6.2.2
Hardware: Unspecified
OS: Unspecified
medium
medium vote
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 1122832
TreeView+ depends on / blocked
 
Reported: 2016-10-24 15:18 UTC by Peter Vreman
Modified: 2019-08-12 16:22 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-08 15:51:44 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Peter Vreman 2016-10-24 15:18:55 UTC
Description of problem:
I got the following undocumented feature that setting the environment_id not inside the require host hash then it will be used for filtering.

See the commands below, when i specify the current environment_id in the PUT i get a result.
When i specify a different environment_id then it returns a resource not found

[prod] root@li-lp-1800:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999,\"environment_id\":\"71\"}" -XPUT https://localhost:443/api/v2/hosts/107 | jq .environment_id
71
[prod] root@li-lp-1800:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999,\"environment_id\":\"70\"}" -XPUT https://localhost:443/api/v2/hosts/107
{
  "error": {"message":"Resource host not found by id '107'"}
}



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


How reproducible:


Steps to Reproduce:
1. PUT a hosts with a value of environment_id that is different from the current one, but not inside the host:{} hash
2. 
3.

Actual results:
Error resource not found.


Expected results:
Value of environment_id is ignore or an error is given that an unsupported field is passed.

Additional info:

Comment 3 Peter Vreman 2017-08-08 15:51:44 UTC
Closing, with 6.2.10 the filtering works reliable and consistent. It first uses the environment_id for filtering and then will search for the host. If the provided environment does not exists then it gives an error that does not exists

Correct environment_id and host_id

[crash/LI] root@li-lc-1578:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999,\"environment_id\":\"503\"}" -XPUT https://localhost:443/api/v2/hosts/3 | jq .id
3

Hosts is not in environment_id 503

[crash/LI] root@li-lc-1578:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999,\"environment_id\":\"503\"}" -XPUT https://localhost:443/api/v2/hosts/7
{
  "error": {"message":"Resource host not found by id '7'"}
}

Environment does not exists

[crash/LI] root@li-lc-1578:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999,\"environment_id\":\"99503\"}" -XPUT https://localhost:443/api/v2/hosts/7
{"message":"Environment not found by id '99503'"}


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