From cb65cc8e44523cd04ecace02296061a6ddc3982d Mon Sep 17 00:00:00 2001 From: Durga Malleswari Varanasi Date: Tue, 22 Mar 2022 15:13:25 +0000 Subject: [PATCH] Internal server error if shared member tries to stage data to image Glance API throws an Internal Server Exception when a non active image is shared with another project and any member from that project tries to stage data for the same. This patch will cover the Functional Test Case for the same Closes-Bug: #1939922 Change-Id: I065036cff6e107b3438007db40981459400ccb6b --- glance/tests/functional/v2/test_images.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/glance/tests/functional/v2/test_images.py b/glance/tests/functional/v2/test_images.py index 8b117c8f04..b1de8c029f 100644 --- a/glance/tests/functional/v2/test_images.py +++ b/glance/tests/functional/v2/test_images.py @@ -4240,6 +4240,24 @@ class TestImageMembers(functional.FunctionalTest): data=body) self.assertEqual(http.BAD_REQUEST, response.status_code) + # Owner can Upload data to staging image + image_id = image_fixture[3]['id'] + path = self._url('/v2/images/%s/stage' % image_id) + headers = get_auth_header('tenant1') + headers.update({'Content-Type': 'application/octet-stream'}) + image_data = b'YYYYY' + response = requests.put(path, headers=headers, + data=image_data) + self.assertEqual(http.NO_CONTENT, response.status_code) + + # Tenant3: can't upload data to tenant1-shared staging image + path = self._url('/v2/images/%s/stage' % image_id) + image_data = b'YYYYY' + headers.update(get_auth_header(TENANT3)) + response = requests.put(path, headers=headers, + data=image_data) + self.assertEqual(http.FORBIDDEN, response.status_code) + # Owner cannot change status of image path = self._url('/v2/images/%s/members/%s' % (image_fixture[3]['id'], TENANT3))