self.assertEqual(set(ids), set(['v1.0']))
def test_volumes(self):
- req = fakes.HTTPRequest.blank('/fake/volumes')
+ req = fakes.HTTPRequest.blank('/fakeproject/volumes')
req.method = 'GET'
req.content_type = 'application/json'
response = req.get_response(self.app)
self.assertEqual(200, response.status_int)
def test_volumes_detail(self):
- req = fakes.HTTPRequest.blank('/fake/volumes/detail')
+ req = fakes.HTTPRequest.blank('/fakeproject/volumes/detail')
req.method = 'GET'
req.content_type = 'application/json'
response = req.get_response(self.app)
self.assertEqual(200, response.status_int)
def test_types(self):
- req = fakes.HTTPRequest.blank('/fake/types')
+ req = fakes.HTTPRequest.blank('/fakeproject/types')
req.method = 'GET'
req.content_type = 'application/json'
response = req.get_response(self.app)
self.assertEqual(200, response.status_int)
def test_snapshots(self):
- req = fakes.HTTPRequest.blank('/fake/snapshots')
+ req = fakes.HTTPRequest.blank('/fakeproject/snapshots')
req.method = 'GET'
req.content_type = 'application/json'
response = req.get_response(self.app)
self.assertEqual(200, response.status_int)
def test_snapshots_detail(self):
- req = fakes.HTTPRequest.blank('/fake/snapshots/detail')
+ req = fakes.HTTPRequest.blank('/fakeproject/snapshots/detail')
req.method = 'GET'
req.content_type = 'application/json'
response = req.get_response(self.app)
'description': 'Volume Test Desc',
'id': '1',
'links':
- [{'href': 'http://localhost/v2/fake/volumes/1',
+ [{'href': 'http://localhost/v2/fakeproject/volumes/1',
'rel': 'self'},
- {'href': 'http://localhost/fake/volumes/1',
+ {'href': 'http://localhost/fakeproject/volumes/1',
'rel': 'bookmark'}],
'metadata': {},
'name': 'Volume Test Name',
'encrypted': False,
'id': '1',
'links':
- [{'href': 'http://localhost/v2/fake/volumes/1',
+ [{'href': 'http://localhost/v2/fakeproject/volumes/1',
'rel': 'self'},
- {'href': 'http://localhost/fake/volumes/1',
+ {'href': 'http://localhost/fakeproject/volumes/1',
'rel': 'bookmark'}],
'metadata': {},
'name': 'Volume Test Name',
'size': 1,
'links': [
{
- 'href': 'http://localhost/v2/fake/volumes/1',
+ 'href': 'http://localhost/v2/fakeproject/volumes/1',
'rel': 'self'
},
{
- 'href': 'http://localhost/fake/volumes/1',
+ 'href': 'http://localhost/fakeproject/volumes/1',
'rel': 'bookmark'
}
],
'size': 1,
'links': [
{
- 'href': 'http://localhost/v2/fake/volumes/1',
+ 'href': 'http://localhost/v2/fakeproject/volumes/1',
'rel': 'self'
},
{
- 'href': 'http://localhost/fake/volumes/1',
+ 'href': 'http://localhost/fakeproject/volumes/1',
'rel': 'bookmark'
}
],
'size': 1,
'links': [
{
- 'href': 'http://localhost/v2/fake/volumes/1',
+ 'href': 'http://localhost/v2/fakeproject/volumes/1',
'rel': 'self'
},
{
- 'href': 'http://localhost/fake/volumes/1',
+ 'href': 'http://localhost/fakeproject/volumes/1',
'rel': 'bookmark'
}
],
'size': 1,
'links': [
{
- 'href': 'http://localhost/v2/fake/volumes/1',
+ 'href': 'http://localhost/v2/fakeproject/volumes/1',
'rel': 'self'
},
{
- 'href': 'http://localhost/fake/volumes/1',
+ 'href': 'http://localhost/fakeproject/volumes/1',
'rel': 'bookmark'
}
],
'id': '1',
'links': [
{
- 'href': 'http://localhost/v2/fake/volumes/1',
+ 'href': 'http://localhost/v2/fakeproject/volumes/'
+ '1',
'rel': 'self'
},
{
- 'href': 'http://localhost/fake/volumes/1',
+ 'href': 'http://localhost/fakeproject/volumes/1',
'rel': 'bookmark'
}
],
'size': 1,
'links': [
{
- 'href': 'http://localhost/v2/fake/volumes/1',
+ 'href': 'http://localhost/v2/fakeproject/volumes/'
+ '1',
'rel': 'self'
},
{
- 'href': 'http://localhost/fake/volumes/1',
+ 'href': 'http://localhost/fakeproject/volumes/1',
'rel': 'bookmark'
}
],
links = res_dict['volumes_links']
self.assertEqual(links[0]['rel'], 'next')
href_parts = urlparse.urlparse(links[0]['href'])
- self.assertEqual('/v2/fake/volumes', href_parts.path)
+ self.assertEqual('/v2/fakeproject/volumes', href_parts.path)
params = urlparse.parse_qs(href_parts.query)
self.assertTrue('marker' in params)
self.assertEqual('1', params['limit'][0])
links = res_dict['volumes_links']
self.assertEqual(links[0]['rel'], 'next')
href_parts = urlparse.urlparse(links[0]['href'])
- self.assertEqual('/v2/fake/volumes/detail', href_parts.path)
+ self.assertEqual('/v2/fakeproject/volumes/detail', href_parts.path)
params = urlparse.parse_qs(href_parts.query)
self.assertTrue('marker' in params)
self.assertEqual('1', params['limit'][0])
'''Verify next link and url.'''
self.assertEqual(links[0]['rel'], 'next')
href_parts = urlparse.urlparse(links[0]['href'])
- self.assertEqual('/v2/fake/%s' % key, href_parts.path)
+ self.assertEqual('/v2/fakeproject/%s' % key, href_parts.path)
# Verify both the index and detail queries
api_keys = ['volumes', 'volumes/detail']
'size': 1,
'links': [
{
- 'href': 'http://localhost/v2/fake/volumes/1',
+ 'href': 'http://localhost/v2/fakeproject/volumes/1',
'rel': 'self'
},
{
- 'href': 'http://localhost/fake/volumes/1',
+ 'href': 'http://localhost/fakeproject/volumes/1',
'rel': 'bookmark'
}
],
'size': 1,
'links': [
{
- 'href': 'http://localhost/v2/fake/volumes/1',
+ 'href': 'http://localhost/v2/fakeproject/volumes/1',
'rel': 'self'
},
{
- 'href': 'http://localhost/fake/volumes/1',
+ 'href': 'http://localhost/fakeproject/volumes/1',
'rel': 'bookmark'
}
],
self.mox.UnsetStubs()
self.volume.delete_volume(self.context, volume_id)
+ def test_get_volume_different_tenant(self):
+ """Test can't get volume of another tenant when viewable_admin_meta."""
+ volume = tests_utils.create_volume(self.context,
+ **self.volume_params)
+ volume_id = volume['id']
+ self.volume.create_volume(self.context, volume_id)
+
+ another_context = context.RequestContext('another_user_id',
+ 'another_project_id',
+ is_admin=False)
+ self.assertNotEqual(another_context.project_id,
+ self.context.project_id)
+
+ volume_api = cinder.volume.api.API()
+
+ self.assertRaises(exception.VolumeNotFound, volume_api.get,
+ another_context, volume_id, viewable_admin_meta=True)
+ self.assertEqual(volume_id,
+ volume_api.get(self.context, volume_id)['id'])
+
+ self.volume.delete_volume(self.context, volume_id)
+
def test_delete_volume_in_error_extending(self):
"""Test volume can be deleted in error_extending stats."""
# create a volume