Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(RHINENG-10369): fix merge/replace facts returns #2185

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def update_facts_by_namespace(operation, host_id_list, namespace, fact_dict, rba
"not match the org_id associated with one or more the hosts. Rejecting the fact change request."
)
logger.debug(error_msg)
return error_msg, 400
return error_msg, 404

staleness = get_staleness_obj(current_identity)

Expand Down
8 changes: 4 additions & 4 deletions tests/test_api_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def test_replace_facts_to_multiple_hosts_including_nonexistent_host(db_create_mu
url_host_id_list = f"{build_id_list_for_url(created_hosts)},{generate_uuid()},{generate_uuid()}"
facts_url = build_facts_url(host_list_or_id=url_host_id_list, namespace=DB_FACTS_NAMESPACE)

response_status, response_data = api_put(facts_url, DB_NEW_FACTS)
response_status, _ = api_put(facts_url, DB_NEW_FACTS)

assert_response_status(response_status, expected_status=400)
assert_response_status(response_status, expected_status=404)


def test_replace_facts_to_multiple_hosts_with_empty_key_value_pair(
Expand Down Expand Up @@ -137,8 +137,8 @@ def test_replace_facts_on_multiple_culled_hosts(db_create_multiple_hosts, api_pu
facts_url = build_facts_url(host_list_or_id=created_hosts, namespace=DB_FACTS_NAMESPACE)

# Try to replace the facts on a host that has been marked as culled
response_status, response_data = api_put(facts_url, DB_NEW_FACTS)
assert_response_status(response_status, expected_status=400)
response_status, _ = api_put(facts_url, DB_NEW_FACTS)
assert_response_status(response_status, expected_status=404)


def test_put_facts_with_RBAC_allowed(subtests, mocker, api_put, db_create_host, enable_rbac, event_producer_mock):
Expand Down
8 changes: 4 additions & 4 deletions tests/test_api_hosts_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,9 @@ def test_add_facts_to_multiple_hosts_including_nonexistent_host(db_create_multip
url_host_id_list = f"{build_id_list_for_url(created_hosts)},{generate_uuid()},{generate_uuid()}"
facts_url = build_facts_url(host_list_or_id=url_host_id_list, namespace=DB_FACTS_NAMESPACE)

response_status, response_data = api_patch(facts_url, DB_NEW_FACTS)
response_status, _ = api_patch(facts_url, DB_NEW_FACTS)

assert_response_status(response_status, expected_status=400)
assert_response_status(response_status, expected_status=404)


def test_add_facts_to_multiple_hosts_overwrite_empty_key_value_pair(
Expand Down Expand Up @@ -452,8 +452,8 @@ def test_add_facts_to_multiple_culled_hosts(
facts_url = build_facts_url(host_list_or_id=created_hosts, namespace=DB_FACTS_NAMESPACE)

# Try to replace the facts on a host that has been marked as culled
response_status, response_data = api_patch(facts_url, DB_NEW_FACTS)
assert_response_status(response_status, expected_status=400)
response_status, _ = api_patch(facts_url, DB_NEW_FACTS)
assert_response_status(response_status, expected_status=404)


def test_patch_host_with_RBAC_allowed(subtests, mocker, api_patch, db_create_host, event_producer_mock, enable_rbac):
Expand Down
8 changes: 4 additions & 4 deletions tests/test_culling.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def test_patch_works_on_non_culled(mq_create_hosts_in_all_states, api_patch):
def test_patch_facts_ignores_culled(mq_create_deleted_hosts, api_patch):
culled_host = mq_create_deleted_hosts["culled"]
url = build_facts_url(host_list_or_id=[culled_host], namespace="ns1")
response_status, response_data = api_patch(url, {"ARCHITECTURE": "patched"})
response_status, _ = api_patch(url, {"ARCHITECTURE": "patched"})

assert response_status == 400
assert response_status == 404


def test_patch_facts_works_on_non_culled(mq_create_hosts_in_all_states, api_patch):
Expand All @@ -68,9 +68,9 @@ def test_put_facts_ignores_culled(mq_create_deleted_hosts, api_put):

url = build_facts_url(host_list_or_id=[culled_host], namespace="ns1")

response_status, response_data = api_put(url, {"ARCHITECTURE": "patched"})
response_status, _ = api_put(url, {"ARCHITECTURE": "patched"})

assert response_status == 400
assert response_status == 404


def test_put_facts_works_on_non_culled(mq_create_hosts_in_all_states, api_put):
Expand Down