'Test unauthorized create public image from volume.'

@mock.patch.object(volume_api.API, 'get', fake_volume_get_obj)
def test_copy_volume_to_image_public_not_authorized(self):

    id = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
    req = fakes.HTTPRequest.blank(('/v3/tenant1/volumes/%s/action' % id))
    req.environ['cinder.context'].is_admin = False
    req.headers = {'OpenStack-API-Version': 'volume    3.1'}
    req.api_version_request = api_version.APIVersionRequest('3.1')
    body = self._get_os_volume_upload_image()
    body['os-volume_upload_image']['visibility'] = 'public'
    self.assertRaises(exception.PolicyNotAuthorized, self.controller._volume_upload_image, req, id, body)
