Merge "Fix 500 status code when we add in "depend_on" yourself"

This commit is contained in:
Jenkins 2016-02-23 14:30:34 +00:00 committed by Gerrit Code Review
commit f4d202b8b5
2 changed files with 13 additions and 1 deletions

View File

@ -202,7 +202,8 @@ class ArtifactsController(object):
return self._get_artifact_with_dependencies(artifact_repo, id)
except (exception.InvalidArtifactPropertyValue,
exception.ArtifactInvalidProperty,
exception.InvalidJsonPatchPath) as e:
exception.InvalidJsonPatchPath,
exception.ArtifactCircularDependency) as e:
raise webob.exc.HTTPBadRequest(explanation=e.msg)
except exception.NotFound as e:
raise webob.exc.HTTPNotFound(explanation=e.msg)

View File

@ -1918,3 +1918,14 @@ paste.filter_factory = glance.tests.utils:FakeAuthMiddleware.factory
url = '/withprops/v1.0/drafts?version=gt:%s' % bad_version
result = self._check_artifact_get(url=url, status=400)
self.assertIn(response_string % bad_version, result)
def test_circular_dependency(self):
data = {'name': 'artifact',
'version': '12'}
art = self._create_artifact('withprops', data=data)
upd = self._check_artifact_post(
'/withprops/v1.0/%s/depends_on' % art['id'],
data={'data': art['id']}, status=400)
self.assertIn(
'Artifact with a circular dependency can not be created', upd)