1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Copyright 2012 OpenStack LLC.
4
# Administrator of the National Aeronautics and Space Administration.
7
# Licensed under the Apache License, Version 2.0 (the "License"); you may
8
# not use this file except in compliance with the License. You may obtain
9
# a copy of the License at
11
# http://www.apache.org/licenses/LICENSE-2.0
13
# Unless required by applicable law or agreed to in writing, software
14
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
# License for the specific language governing permissions and limitations
19
Tests for Consoleauth Code.
25
from nova import context
27
from nova import flags
28
from nova import log as logging
30
from nova import utils
31
from nova.consoleauth import manager
35
LOG = logging.getLogger(__name__)
38
class ConsoleauthTestCase(test.TestCase):
39
"""Test Case for consoleauth."""
42
super(ConsoleauthTestCase, self).setUp()
43
self.manager = utils.import_object(FLAGS.consoleauth_manager)
44
self.context = context.get_admin_context()
46
def test_tokens_expire(self):
47
"""Test that tokens expire correctly."""
49
self.flags(console_token_ttl=1)
50
self.manager.authorize_console(self.context, token, 'novnc',
51
'127.0.0.1', 'host', '')
52
self.assertTrue(self.manager.check_token(self.context, token))
54
self.assertFalse(self.manager.check_token(self.context, token))