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
This commit is contained in:
Durga Malleswari Varanasi 2022-03-22 15:13:25 +00:00
parent 14bd3eb1bb
commit cb65cc8e44

View File

@ -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))