From 39c2854f6e0cc41d65a256b177b9a7892287d295 Mon Sep 17 00:00:00 2001 From: Amit Upadhye Date: Wed, 13 Sep 2023 19:23:58 +0530 Subject: [PATCH] Load all systems if there are no groups --- ros/api/common/add_group_filter.py | 2 -- tests/test_api_endpoints.py | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ros/api/common/add_group_filter.py b/ros/api/common/add_group_filter.py index 441772d2..57cd8e69 100644 --- a/ros/api/common/add_group_filter.py +++ b/ros/api/common/add_group_filter.py @@ -10,8 +10,6 @@ def group_filtered_query(query): if get_flag_value(FLAG_INVENTORY_GROUPS): if len(get_host_groups()) >= 1: query = query.filter(System.groups[0]['id'].astext.in_(get_host_groups()) | (System.groups == '[]')) - else: - query = query.filter((System.groups == '[]')) return query diff --git a/tests/test_api_endpoints.py b/tests/test_api_endpoints.py index c4cb3de1..5c9f885a 100644 --- a/tests/test_api_endpoints.py +++ b/tests/test_api_endpoints.py @@ -485,7 +485,7 @@ def test_systems_rbac_returns_emtpy_group( mock_rbac(get_rbac_mock_file("mock_rbac_returns_emtpy_group.json"), mocker) response = client.get('/api/ros/v1/systems', headers={"x-rh-identity": auth_token}) assert response.status_code == 200 - assert response.json["meta"]["count"] == 1 + assert response.json["meta"]["count"] == 4 assert response.json["data"][0]["groups"] == [] @@ -509,7 +509,7 @@ def test_systems_mock_rbac_returns_no_groups( mock_rbac(get_rbac_mock_file("mock_rbac_returns_no_groups.json"), mocker) response = client.get('/api/ros/v1/systems', headers={"x-rh-identity": auth_token}) assert response.status_code == 200 - assert response.json["meta"]["count"] == 1 + assert response.json["meta"]["count"] == 4 def test_systems_mock_rbac_returns_multiple_inventory_hosts_read(