~ubuntu-cloud-archive/ubuntu/precise/nova/trunk

« back to all changes in this revision

Viewing changes to nova/tests/consoleauth/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.consoleauth.rpcapi
 
19
"""
 
20
 
 
21
from nova.consoleauth import rpcapi as consoleauth_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 ConsoleAuthRpcAPITestCase(test.TestCase):
 
32
 
 
33
    def setUp(self):
 
34
        super(ConsoleAuthRpcAPITestCase, self).setUp()
 
35
 
 
36
    def tearDown(self):
 
37
        super(ConsoleAuthRpcAPITestCase, self).tearDown()
 
38
 
 
39
    def _test_consoleauth_api(self, method, **kwargs):
 
40
        ctxt = context.RequestContext('fake_user', 'fake_project')
 
41
        rpcapi = consoleauth_rpcapi.ConsoleAuthAPI()
 
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.consoleauth_topic)
 
65
        self.assertEqual(self.call_msg, expected_msg)
 
66
        self.assertEqual(self.call_timeout, None)
 
67
 
 
68
    def test_authorize_console(self):
 
69
        self._test_consoleauth_api('authorize_console', token='token',
 
70
                console_type='ctype', host='h', port='p',
 
71
                internal_access_path='iap')
 
72
 
 
73
    def test_check_token(self):
 
74
        self._test_consoleauth_api('check_token', token='t')