Designate DNS – list shared zones API (using Admin) responds with 200 OK for non-existing zone/project ID

Bug #2009819 reported by Arkady Shtempler
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Designate
Confirmed
Low
Unassigned

Bug Description

### Scenario ###
List shared zones using invalid zone ID, here is it:
@decorators.idempotent_id('871e7e1c-bd9a-11ed-80f5-201e8823901f')
def test_list_zone_shares_invalid_zone_id(self):
    LOG.info(
        'Admin user lists shared zone using not existing zone ID')
    sudo_header = {
        'x-auth-sudo-project-id': self.share_zone_client.project_id}
    self.assertRaises(lib_exc.NotFound,
       lambda: self.adm_shr_client.list_zone_shares(
           dns_data_utils.rand_uuid(), headers=sudo_header))

To reproduce the scenario you can use this test patch:
1) test_list_zone_shares_invalid_zone_id
https://review.opendev.org/c/openstack/designate-tempest-plugin/+/875919/7/designate_tempest_plugin/tests/api/v2/test_shared_zones.py#488

2) test_list_zone_shares_invalid_project_id
https://review.opendev.org/c/openstack/designate-tempest-plugin/+/875919/7/designate_tempest_plugin/tests/api/v2/test_shared_zones.py#499

### Actual Result ###
API responds with 200 OK + empty list for shared_zones, like this:
2023-03-08 10:31:04.536 560986 INFO tempest.lib.common.rest_client [req-a44bcf7f-3112-448c-bccb- 200 GET https://192.168.122.49/dns/v2/ 0.025s
2023-03-08 10:31:04.537 560986 DEBUG tempest.lib.common.rest_client [req-a44bcf7f-3112-448c-bccb-
        Body: None
    Response - Headers: {'date': 'Wed, 08 Mar 2023 10:31:04 GMT', 'server': 'Apache/2.4.41 (Ubuntu)', 'content-length': '119', 'content-type': 'application/json', 'x-openstack-request-id': 'req-a44bcf7f-3112-448c-bccb-https://192.168.122.49/dns/'}
        Body: b'{"shared_zones": [], "links": {"self": "https://127.0.0.1:60053/v2/"}}' _log_request_full /opt/stack/tempest/tempest/

### Expected result ###
If zone ID doesn’t exists in Designate DB, responding with “404 NotFound" (instead of 200 OK and empty list) could have make sense.

### Note ###
Existing zones list API has the same behavior:

REQ: curl -g -i -X GET http://10.21.21.126/dns/v2/ -H "Accept: application/json" -H "Content-Type: application/json" -H "User-Agent: python-designateclient-5.2.0" -H "X-Auth-Token: {SHA256}
Resetting dropped connection: 10.21.21.126
http://10.21.21.126:80 "GET /dns/v2/zones?name=bogus HTTP/1.1" 200 110
RESP: [200] Connection: close Content-Length: 110 Content-Type: application/json Date: Wed, 08 Mar 2023 21:28:41 GMT Server: Apache/2.4.52 (Ubuntu) x-openstack-request-id: req-0be38914-14f8-45da-81a8-
RESP BODY: {"zones": [], "links": {"self": "http://127.0.0.1:60053/v2/"}, "metadata": {"total_count": 0}}

This means that will need to fix Zone API and maybe some other APIs that have a similar behavior.

description: updated
summary: - Designate DNS – list shared zones responds with 200 OK for non-existing
- zone ID
+ Designate DNS – list shared zones API (using Admin) responds with 200 OK
+ for non-existing zone/project ID
description: updated
Revision history for this message
Michael Johnson (johnsom) wrote :

I am not sure this is a bug given the existing zone list API behaves the same way.
The list API is a "search" API and it's saying it found no results, which I think is ok.

Would like to hear any community comments on this. Marking low priority for now.

Changed in designate:
importance: Undecided → Low
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.