diff options
| author | Avinash Prasad <avinash.prasad@nttdata.com> | 2013-05-16 07:50:03 -0700 |
|---|---|---|
| committer | Avinash Prasad <avinash.prasad@nttdata.com> | 2013-05-28 23:36:36 -0700 |
| commit | 83dec85cd9ec8217aaaa9764266cdf584d064cdc (patch) | |
| tree | 9b3aabc16edd72d2e39ac906c550a935dcd861c0 /nova/tests | |
| parent | 64b234d5cb69fbfd183d74f20d7b243569f6c6f6 (diff) | |
| download | nova-83dec85cd9ec8217aaaa9764266cdf584d064cdc.tar.gz nova-83dec85cd9ec8217aaaa9764266cdf584d064cdc.tar.xz nova-83dec85cd9ec8217aaaa9764266cdf584d064cdc.zip | |
Fix EC2 RegisterImage ImageLocation starts with /
* Allows image location that begins with '/' during EC2 image register
* Adds relevant unit test
Fixes LP bug #1074908
Change-Id: I488b126c2079de4370823b347e80c7ec1ecc2c9f
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/image/test_s3.py | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/nova/tests/image/test_s3.py b/nova/tests/image/test_s3.py index 8cdde1dc6..e02ac4c6b 100644 --- a/nova/tests/image/test_s3.py +++ b/nova/tests/image/test_s3.py @@ -198,12 +198,8 @@ class TestS3ImageService(test.TestCase): 'no_device': True}] self.assertEqual(block_device_mapping, expected_bdm) - def test_s3_create_is_public(self): - metadata = {'properties': { - 'image_location': 'mybucket/my.img.manifest.xml'}, - 'name': 'mybucket/my.img'} + def _initialize_mocks(self): handle, tempf = tempfile.mkstemp(dir='/tmp') - ignore = mox.IgnoreArg() mockobj = self.mox.CreateMockAnything() self.stubs.Set(self.image_service, '_conn', mockobj) @@ -225,6 +221,33 @@ class TestS3ImageService(test.TestCase): mockobj(ignore, ignore).AndReturn(tempf) self.mox.ReplayAll() + def test_s3_create_image_locations(self): + image_location_1 = 'testbucket_1/test.img.manifest.xml' + # Use another location that starts with a '/' + image_location_2 = '/testbucket_2/test.img.manifest.xml' + + metadata = [{'properties': {'image_location': image_location_1}}, + {'properties': {'image_location': image_location_2}}] + + for mdata in metadata: + self._initialize_mocks() + image = self.image_service._s3_create(self.context, mdata) + eventlet.sleep() + translated = self.image_service._translate_id_to_uuid(self.context, + image) + uuid = translated['id'] + image_service = fake.FakeImageService() + updated_image = image_service.update(self.context, uuid, + {'properties': {'image_state': 'available'}}, + purge_props=False) + self.assertEqual(updated_image['properties']['image_state'], + 'available') + + def test_s3_create_is_public(self): + self._initialize_mocks() + metadata = {'properties': { + 'image_location': 'mybucket/my.img.manifest.xml'}, + 'name': 'mybucket/my.img'} img = self.image_service._s3_create(self.context, metadata) eventlet.sleep() translated = self.image_service._translate_id_to_uuid(self.context, |
