def test_image_get_all_marker_deleted_showing_deleted(self):
     """Specify a deleted image as a marker if showing deleted images."""
     db_api.image_destroy(self.adm_context, UUID1)
     filters = {'deleted': True}
     images = db_api.image_get_all(self.context, marker=UUID1,
                                   filters=filters)
     self.assertEquals(len(images), 0)
Beispiel #2
0
    def delete(self, req, id):
        """
        Deletes an existing image with the registry.

        :param req: wsgi Request object
        :param id:  The opaque internal identifier for the image

        :retval Returns 200 if delete was successful, a fault if not.
        """
        if req.context.read_only:
            raise exc.HTTPForbidden()

        try:
            db_api.image_destroy(req.context, id)

        except exception.ForbiddenPublicImage:
            # If it's private and doesn't belong to them, don't let on
            # that it exists
            msg = _("Access by %(user)s to delete public image %(id)s denied")
            args = {'user': req.context.user, 'id': id}
            logger.info(msg % args)
            raise exc.HTTPForbidden()

        except exception.Forbidden:
            msg = _("Access by %(user)s to delete private image %(id)s denied")
            args = {'user': req.context.user, 'id': id}
            logger.info(msg % args)
            return exc.HTTPNotFound()

        except exception.NotFound:
            return exc.HTTPNotFound()
Beispiel #3
0
    def delete(self, req, id):
        """
        Deletes an existing image with the registry.

        :param req: wsgi Request object
        :param id:  The opaque internal identifier for the image

        :retval Returns 200 if delete was successful, a fault if not.
        """
        if req.context.read_only:
            raise exc.HTTPForbidden()

        try:
            db_api.image_destroy(req.context, id)
        except exception.NotFound:
            return exc.HTTPNotFound()
        except exception.NotAuthorized:
            # If it's private and doesn't belong to them, don't let on
            # that it exists
            msg = _("Access by %(user)s to image %(id)s "
                    "denied") % ({
                        'user': req.context.user,
                        'id': id
                    })
            logger.info(msg)
            raise exc.HTTPNotFound()
Beispiel #4
0
 def test_image_get_all_marker_deleted_showing_deleted(self):
     """Specify a deleted image as a marker if showing deleted images."""
     db_api.image_destroy(self.adm_context, UUID1)
     filters = {'deleted': True}
     images = db_api.image_get_all(self.context, marker=UUID1,
                                   filters=filters)
     self.assertEquals(len(images), 0)
Beispiel #5
0
 def test_image_get_all_marker_deleted(self):
     """Cannot specify a deleted image as a marker."""
     db_api.image_destroy(self.adm_context, UUID1)
     filters = {'deleted': False}
     self.assertRaises(exception.NotFound,
                       db_api.image_get_all,
                       self.context,
                       marker=UUID1,
                       filters=filters)
Beispiel #6
0
    def delete(self, req, id):
        """
        Deletes an existing image with the registry.

        :param req: Request body.  Ignored.
        :param id:  The opaque internal identifier for the image

        :retval Returns 200 if delete was successful, a fault if not.

        """
        context = None
        try:
            db_api.image_destroy(context, id)
        except exception.NotFound:
            return exc.HTTPNotFound()
Beispiel #7
0
    def delete(self, req, id):
        """
        Deletes an existing image with the registry.

        :param req: wsgi Request object
        :param id:  The opaque internal identifier for the image

        :retval Returns 200 if delete was successful, a fault if not.
        """
        if req.context.read_only:
            raise exc.HTTPForbidden()

        try:
            db_api.image_destroy(req.context, id)
        except exception.NotFound:
            return exc.HTTPNotFound()
        except exception.NotAuthorized:
            # If it's private and doesn't belong to them, don't let on
            # that it exists
            logger.info("Access by %s to image %s denied" %
                        (req.context.user, id))
            raise exc.HTTPNotFound()
 def test_image_get_all_marker_deleted_showing_deleted_as_admin(self):
     """Specify a deleted image as a marker if showing deleted images."""
     db_api.image_destroy(self.adm_context, UUID1)
     images = db_api.image_get_all(self.adm_context, marker=UUID1)
     self.assertEquals(len(images), 0)
 def test_image_get_all_marker_deleted(self):
     """Cannot specify a deleted image as a marker."""
     db_api.image_destroy(self.adm_context, UUID1)
     filters = {'deleted': False}
     self.assertRaises(exception.NotFound, db_api.image_get_all,
                       self.context, marker=UUID1, filters=filters)
 def test_image_get_force_allow_deleted(self):
     db_api.image_destroy(self.adm_context, UUID1)
     image = db_api.image_get(self.context, UUID1, force_show_deleted=True)
     self.assertEquals(image['id'], self.fixtures[0]['id'])
 def test_image_get_disallow_deleted(self):
     db_api.image_destroy(self.adm_context, UUID1)
     self.assertRaises(exception.NotFound, db_api.image_get,
                       self.context, UUID1)
Beispiel #12
0
 def test_image_get_disallow_deleted(self):
     db_api.image_destroy(self.adm_context, UUID1)
     self.assertRaises(exception.NotFound, db_api.image_get,
                       self.context, UUID1)
Beispiel #13
0
 def test_image_get_all_marker_deleted_showing_deleted_as_admin(self):
     """Specify a deleted image as a marker if showing deleted images."""
     db_api.image_destroy(self.adm_context, UUID1)
     images = db_api.image_get_all(self.adm_context, marker=UUID1)
     self.assertEquals(len(images), 0)
Beispiel #14
0
 def test_image_get_force_allow_deleted(self):
     db_api.image_destroy(self.adm_context, UUID1)
     image = db_api.image_get(self.context, UUID1, force_show_deleted=True)
     self.assertEquals(image['id'], FIXTURES[0]['id'])
Beispiel #15
0
 def test_image_get_allow_deleted(self):
     db_api.image_destroy(self.adm_context, UUID1)
     image = db_api.image_get(self.adm_context, UUID1)
     self.assertEquals(image['id'], FIXTURES[0]['id'])
 def test_image_get_allow_deleted(self):
     db_api.image_destroy(self.adm_context, UUID1)
     image = db_api.image_get(self.adm_context, UUID1)
     self.assertEquals(image['id'], self.fixtures[0]['id'])