From 0d2523f029b291817551e33fe15cd7ab33fe2102 Mon Sep 17 00:00:00 2001 From: Chris Yeoh Date: Sat, 25 Aug 2012 15:51:37 +0930 Subject: Stop fetch_ca from throwing IOError exceptions Fixes bug #883300 Fixes problem where fetch_ca could throw an IOError exception rather than a Nova specific exception. Adds FileError exception. Fixes other functions in crypto.py that had very similar problems. Change-Id: Ic2e43c35ad58c67d33156c53d2a41910dfdf8678 --- nova/tests/test_crypto.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/test_crypto.py b/nova/tests/test_crypto.py index c9ee6ca02..c725079d2 100644 --- a/nova/tests/test_crypto.py +++ b/nova/tests/test_crypto.py @@ -22,6 +22,7 @@ import mox from nova import crypto from nova import db +from nova import exception from nova import flags from nova import test from nova import utils @@ -133,3 +134,21 @@ class RevokeCertsTest(test.TestCase): self.mox.ReplayAll() crypto.revoke_certs_by_project(project_id) + + +class CertExceptionTests(test.TestCase): + def test_fetch_ca_file_not_found(self): + with utils.tempdir() as tmpdir: + self.flags(ca_path=tmpdir) + self.flags(use_project_ca=True) + + self.assertRaises(exception.CryptoCAFileNotFound, crypto.fetch_ca, + project_id='fake') + + def test_fetch_crl_file_not_found(self): + with utils.tempdir() as tmpdir: + self.flags(ca_path=tmpdir) + self.flags(use_project_ca=True) + + self.assertRaises(exception.CryptoCRLFileNotFound, + crypto.fetch_crl, project_id='fake') -- cgit