From 42585a3b2559329f0e563bcd04ff6c8c19115439 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Mon, 26 Mar 2012 14:50:17 -0700 Subject: Handle Forbidden and NotAuthenticated glance exc. * Remove references to deprecated NotAuthorized exception * Handle Forbidden and NotAuthenticated * Fixes bug 965540 Change-Id: Ib5eef3015239e0fafdb01c975a0f5d553f70519e --- nova/tests/image/test_glance.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/image/test_glance.py b/nova/tests/image/test_glance.py index d41e87423..bc5969a45 100644 --- a/nova/tests/image/test_glance.py +++ b/nova/tests/image/test_glance.py @@ -556,6 +556,19 @@ class TestGlanceImageService(test.TestCase): self.flags(glance_num_retries=1) service.get(self.context, image_id, writer) + def test_client_raises_forbidden(self): + class MyGlanceStubClient(glance_stubs.StubGlanceClient): + """A client that fails the first time, then succeeds.""" + def get_image(self, image_id): + raise glance_exception.Forbidden() + + client = MyGlanceStubClient() + service = glance.GlanceImageService(client=client) + image_id = 1 # doesn't matter + writer = NullWriter() + self.assertRaises(exception.ImageNotAuthorized, service.get, + self.context, image_id, writer) + def test_glance_client_image_id(self): fixture = self._make_fixture(name='test image') image_id = self.service.create(self.context, fixture)['id'] -- cgit