Skip to content

Commit

Permalink
Fixes Bug 992215-Some new tests to be added to test_images.py and tes…
Browse files Browse the repository at this point in the history
…t_authorization.py

Change-Id: Ib290bcbc338c68ce3063d17791293378defa7eeb
  • Loading branch information
RajalakshmiGanesan committed May 23, 2012
1 parent 4a64d23 commit 32f8db6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tempest/tests/test_authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,17 @@ def test_get_keypair_of_other_account_fails(self):
def test_delete_keypair_of_other_account_fails(self):
"""A DELETE request for another user's keypair should fail"""
self.other_keypairs_client.delete_keypair(self.keypairname)

@raises(exceptions.NotFound)
@attr(type='negative')
@utils.skip_unless_attr('multi_user', 'Second user not configured')
def test_get_image_for_other_account_fails(self):
"""A GET request for an image on another user's account should fail"""
self.other_images_client.get_image(self.image['id'])

@raises(exceptions.NotFound)
@attr(type='negative')
@utils.skip_unless_attr('multi_user', 'Second user not configured')
def test_delete_image_for_other_account_fails(self):
"""A DELETE request for another user's image should fail"""
self.other_images_client.delete_image(self.image['id'])
36 changes: 36 additions & 0 deletions tempest/tests/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import tempest.config
from tempest import openstack
from tempest.common.utils import data_utils
from tempest import exceptions


class ImagesTest(BaseComputeTest):
Expand Down Expand Up @@ -79,3 +80,38 @@ def test_create_image_from_deleted_server(self):
self.client.wait_for_image_status(image_id, 'ACTIVE')
self.client.delete_image(image_id)
self.fail("Should not create snapshot from deleted instance!")

@attr(type='negative')
def test_create_image_from_invalid_server(self):
"""An image should not be created with invalid server id"""
try:
# Create a new image with invalid server id
name = rand_name('image')
meta = {'image_type': 'test'}
resp = {}
resp['status'] = None
resp, body = self.client.create_image('!@#$%^&*()', name, meta)

except exceptions.NotFound:
pass

finally:
if (resp['status'] != None):
image_id = data_utils.parse_image_id(resp['location'])
resp, _ = self.client.delete_image(image_id)
self.fail("An image should not be created"
" with invalid server id")

@attr(type='negative')
def test_delete_image_with_invalid_image_id(self):
"""An image should not be deleted with invalid image id"""
try:
# Delete an image with invalid image id
resp, _ = self.client.delete_image('!@$%^&*()')

except exceptions.NotFound:
pass

else:
self.fail("DELETE image request should rasie NotFound exception"
"when requested with invalid image")

0 comments on commit 32f8db6

Please sign in to comment.