non-admin user only able to download Active image
Test case updated
This is to check that non-admin user should not able to download
deactivated image and after reactivation it should able to download
the reactive image.
Change-Id: I0a1d0f4fcb72d9d0252a86f6ee136519dac2f677
diff --git a/tempest/api/image/admin/v2/test_images.py b/tempest/api/image/admin/v2/test_images.py
index 1608b76..09877ba 100644
--- a/tempest/api/image/admin/v2/test_images.py
+++ b/tempest/api/image/admin/v2/test_images.py
@@ -20,7 +20,7 @@
from tempest.api.image import base
from tempest import config
from tempest import test
-
+from tempest_lib import exceptions as lib_exc
CONF = config.CONF
@@ -43,13 +43,20 @@
image_id = body['id']
self.addCleanup(self.client.delete_image, image_id)
# upload an image file
- image_file = moves.cStringIO(data_utils.random_bytes())
+ content = data_utils.random_bytes()
+ image_file = moves.cStringIO(content)
self.client.store_image_file(image_id, image_file)
# deactivate image
self.admin_client.deactivate_image(image_id)
body = self.client.show_image(image_id)
self.assertEqual("deactivated", body['status'])
+ # non-admin user unable to download deactivated image
+ self.assertRaises(lib_exc.Forbidden, self.client.load_image_file,
+ image_id)
# reactivate image
self.admin_client.reactivate_image(image_id)
body = self.client.show_image(image_id)
self.assertEqual("active", body['status'])
+ # non-admin user able to download image after reactivation by admin
+ body = self.client.load_image_file(image_id)
+ self.assertEqual(content, body.data)