'Test that the internal store location is NOT revealed
through the API server'

def test_store_location_not_revealed(self):

    for url in ('/images', '/images/detail'):
        req = webob.Request.blank(url)
        res = req.get_response(self.api)
        self.assertEqual(http_client.OK, res.status_int)
        res_dict = jsonutils.loads(res.body)
        images = res_dict['images']
        num_locations = sum([1 for record in images if ('location' in record.keys())])
        self.assertEqual(0, num_locations, images)
    req = webob.Request.blank(('/images/%s' % UUID2))
    res = req.get_response(self.api)
    self.assertEqual(http_client.OK, res.status_int)
    self.assertNotIn('X-Image-Meta-Location', res.headers)
    req = webob.Request.blank(('/images/%s' % UUID2))
    req.method = 'HEAD'
    res = req.get_response(self.api)
    self.assertEqual(http_client.OK, res.status_int)
    self.assertNotIn('X-Image-Meta-Location', res.headers)
    req = webob.Request.blank(('/images/%s' % UUID2))
    req.body = res.body
    req.method = 'PUT'
    res = req.get_response(self.api)
    self.assertEqual(http_client.OK, res.status_int)
    res_body = jsonutils.loads(res.body)
    self.assertNotIn('location', res_body['image'])
    req = webob.Request.blank('/images')
    headers = {'x-image-meta-location': 'http://localhost', 'x-image-meta-disk-format': 'vhd', 'x-image-meta-container-format': 'ovf', 'x-image-meta-name': 'fake    image    #3'}
    for (k, v) in six.iteritems(headers):
        req.headers[k] = v
    req.method = 'POST'
    http = store.get_store_from_scheme('http')
    with mock.patch.object(http, 'get_size') as size:
        size.return_value = 0
        res = req.get_response(self.api)
        self.assertEqual(http_client.CREATED, res.status_int)
        res_body = jsonutils.loads(res.body)
        self.assertNotIn('location', res_body['image'])
