~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/tests/cert/test_rpcapi.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-05-24 13:12:53 UTC
  • mfrom: (1.1.55)
  • Revision ID: package-import@ubuntu.com-20120524131253-ommql08fg1en06ut
Tags: 2012.2~f1-0ubuntu1
* New upstream release.
* Prepare for quantal:
  - Dropped debian/patches/upstream/0006-Use-project_id-in-ec2.cloud._format_image.patch
  - Dropped debian/patches/upstream/0005-Populate-image-properties-with-project_id-again.patch
  - Dropped debian/patches/upstream/0004-Fixed-bug-962840-added-a-test-case.patch
  - Dropped debian/patches/upstream/0003-Allow-unprivileged-RADOS-users-to-access-rbd-volumes.patch
  - Dropped debian/patches/upstream/0002-Stop-libvirt-test-from-deleting-instances-dir.patch
  - Dropped debian/patches/upstream/0001-fix-bug-where-nova-ignores-glance-host-in-imageref.patch 
  - Dropped debian/patches/0001-fix-useexisting-deprecation-warnings.patch
* debian/control: Add python-keystone as a dependency. (LP: #907197)
* debian/patches/kombu_tests_timeout.patch: Refreshed.
* debian/nova.conf, debian/nova-common.postinst: Convert to new ini
  file configuration
* debian/patches/nova-manage_flagfile_location.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
# Copyright 2012, Red Hat, Inc.
 
4
#
 
5
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
6
#    not use this file except in compliance with the License. You may obtain
 
7
#    a copy of the License at
 
8
#
 
9
#         http://www.apache.org/licenses/LICENSE-2.0
 
10
#
 
11
#    Unless required by applicable law or agreed to in writing, software
 
12
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
13
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
14
#    License for the specific language governing permissions and limitations
 
15
#    under the License.
 
16
 
 
17
"""
 
18
Unit Tests for nova.cert.rpcapi
 
19
"""
 
20
 
 
21
from nova.cert import rpcapi as cert_rpcapi
 
22
from nova import context
 
23
from nova import flags
 
24
from nova import rpc
 
25
from nova import test
 
26
 
 
27
 
 
28
FLAGS = flags.FLAGS
 
29
 
 
30
 
 
31
class CertRpcAPITestCase(test.TestCase):
 
32
 
 
33
    def setUp(self):
 
34
        super(CertRpcAPITestCase, self).setUp()
 
35
 
 
36
    def tearDown(self):
 
37
        super(CertRpcAPITestCase, self).tearDown()
 
38
 
 
39
    def _test_cert_api(self, method, **kwargs):
 
40
        ctxt = context.RequestContext('fake_user', 'fake_project')
 
41
        rpcapi = cert_rpcapi.CertAPI()
 
42
        expected_retval = 'foo'
 
43
        expected_msg = rpcapi.make_msg(method, **kwargs)
 
44
        expected_msg['version'] = rpcapi.RPC_API_VERSION
 
45
 
 
46
        self.call_ctxt = None
 
47
        self.call_topic = None
 
48
        self.call_msg = None
 
49
        self.call_timeout = None
 
50
 
 
51
        def _fake_call(_ctxt, _topic, _msg, _timeout):
 
52
            self.call_ctxt = _ctxt
 
53
            self.call_topic = _topic
 
54
            self.call_msg = _msg
 
55
            self.call_timeout = _timeout
 
56
            return expected_retval
 
57
 
 
58
        self.stubs.Set(rpc, 'call', _fake_call)
 
59
 
 
60
        retval = getattr(rpcapi, method)(ctxt, **kwargs)
 
61
 
 
62
        self.assertEqual(retval, expected_retval)
 
63
        self.assertEqual(self.call_ctxt, ctxt)
 
64
        self.assertEqual(self.call_topic, FLAGS.cert_topic)
 
65
        self.assertEqual(self.call_msg, expected_msg)
 
66
        self.assertEqual(self.call_timeout, None)
 
67
 
 
68
    def test_revoke_certs_by_user(self):
 
69
        self._test_cert_api('revoke_certs_by_user', user_id='fake_user_id')
 
70
 
 
71
    def test_revoke_certs_by_project(self):
 
72
        self._test_cert_api('revoke_certs_by_project',
 
73
                            project_id='fake_project_id')
 
74
 
 
75
    def test_revoke_certs_by_user_and_project(self):
 
76
        self._test_cert_api('revoke_certs_by_user_and_project',
 
77
                            user_id='fake_user_id',
 
78
                            project_id='fake_project_id')
 
79
 
 
80
    def test_generate_x509_cert(self):
 
81
        self._test_cert_api('generate_x509_cert',
 
82
                            user_id='fake_user_id',
 
83
                            project_id='fake_project_id')
 
84
 
 
85
    def test_fetch_ca(self):
 
86
        self._test_cert_api('fetch_ca', project_id='fake_project_id')
 
87
 
 
88
    def test_fetch_crl(self):
 
89
        self._test_cert_api('fetch_crl', project_id='fake_project_id')
 
90
 
 
91
    def test_decrypt_text(self):
 
92
        self._test_cert_api('decrypt_text',
 
93
                            project_id='fake_project_id', text='blah')