RedHatInsights/insights-host-inventory

No filtering by account when finding by hostname or ID

Glutexo opened this issue · 0 comments

When hosts are filtered by the hostname_or_id parameter, they are not filtered by account number. The condition simply isn’t there. An account_number argument is passed, but it’s not used.

Steps to reproduce:

  1. Create a host with one account number. (Here: abc123)
    POST http://localhost:8080/r/insights/platform/inventory/api/v1/hosts
    Content-Type: application/json
    x-rh-identity: eyJpZGVudGl0eSI6eyJhY2NvdW50X251bWJlciI6ImFiYzEyMyIsIm9yZ19pZCI6ImJjZDIzNCJ9fQ==
    
    [
      {
        "account": "abc123",
        "fqdn": "some.thing.cz"
      }
    ]
  2. Query for this hosts using a different account number. (Here: 0000001)
    GET http://localhost:8080/r/insights/platform/inventory/api/v1/hosts?hostname_or_id=some.thing.cz
    x-rh-identity: eyJpZGVudGl0eSI6eyJhY2NvdW50X251bWJlciI6IjAwMDAwMDEifX0=
    
  3. See that the host is retrieved.
    {
      "count": 1,
       "page": 1,
      "per_page": 50,
      "results": [
        {
          "account": "abc123",
          "bios_uuid": null,
          "created": "2019-03-18T12:47:28.151448Z",
          "display_name": "some.thing.cz",
          "external_id": null,
          "facts": [],
          "fqdn": "some.thing.cz",
          "id": "e6e717fb-eba2-47c7-ac00-a37532e33ce2",
          "insights_id": null,
          "ip_addresses": null,
          "mac_addresses": null,
          "rhel_machine_id": null,
          "satellite_id": null,
          "subscription_manager_id": null,
          "updated": "2019-03-18T12:47:28.151468Z"
        }
      ],
      "total": 1
    }