summaryrefslogtreecommitdiff
path: root/nova/tests/console/test_type.py
blob: d9a82d76581e317aa66835a71f2b5eda328e863e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.


from nova.console import type as ctype
from nova import test


class TypeTestCase(test.TestCase):
    def test_console(self):
        c = ctype.Console(host='127.0.0.1', port=8945)

        self.assertTrue(hasattr(c, 'host'))
        self.assertTrue(hasattr(c, 'port'))
        self.assertTrue(hasattr(c, 'internal_access_path'))

        self.assertEqual('127.0.0.1', c.host)
        self.assertEqual(8945, c.port)
        self.assertIsNone(c.internal_access_path)

        self.assertEqual({
            'host': '127.0.0.1',
            'port': 8945,
            'internal_access_path': None,
            'token': 'a-token',
            'access_url': 'an-url'},
            c.get_connection_info('a-token', 'an-url'))

    def test_console_vnc(self):
        c = ctype.ConsoleVNC(host='127.0.0.1', port=8945)

        self.assertIsInstance(c, ctype.Console)

    def test_console_rdp(self):
        c = ctype.ConsoleRDP(host='127.0.0.1', port=8945)

        self.assertIsInstance(c, ctype.Console)

    def test_console_spice(self):
        c = ctype.ConsoleSpice(host='127.0.0.1', port=8945, tlsPort=6547)

        self.assertIsInstance(c, ctype.Console)
        self.assertEqual(6547, c.tlsPort)
        self.assertEqual(
            6547, c.get_connection_info('a-token', 'an-url')['tlsPort'])

    def test_console_serial(self):
        c = ctype.ConsoleSerial(host='127.0.0.1', port=8945)

        self.assertIsInstance(c, ctype.Console)