The environment module will be configured once, during code initialization. Subsequently all other possibly-evented modules will retrieve from environment and transparently obtain either the eventlet or standard library modules. If eventlet, httplib, subprocess or other environment dependant module is referenced outside of the environment module it should be considered a bug. The changes to tests are required to ensure that test is imported first to setup the environment. Hopefully these can all be replaced with an __init__.py in a post-nose keystone. Implements: blueprint extract-eventlet Change-Id: Icacd6f2ee0906ac5d303777c1f87a184f38283bf
67 lines
2.5 KiB
Python
67 lines
2.5 KiB
Python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
|
|
# Copyright 2012 OpenStack LLC
|
|
#
|
|
# 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.
|
|
|
|
# Copyright 2012 Justin Santa Barbara
|
|
# 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 keystone import test
|
|
|
|
from keystone.common import utils
|
|
|
|
|
|
class UtilsTestCase(test.TestCase):
|
|
def test_hash(self):
|
|
password = 'right'
|
|
wrong = 'wrongwrong' # Two wrongs don't make a right
|
|
hashed = utils.hash_password(password)
|
|
self.assertTrue(utils.check_password(password, hashed))
|
|
self.assertFalse(utils.check_password(wrong, hashed))
|
|
|
|
def test_hash_long_password(self):
|
|
bigboy = '0' * 9999999
|
|
hashed = utils.hash_password(bigboy)
|
|
self.assertTrue(utils.check_password(bigboy, hashed))
|
|
|
|
def test_hash_edge_cases(self):
|
|
hashed = utils.hash_password('secret')
|
|
self.assertFalse(utils.check_password('', hashed))
|
|
self.assertFalse(utils.check_password(None, hashed))
|
|
|
|
def test_hash_unicode(self):
|
|
password = u'Comment \xe7a va'
|
|
wrong = 'Comment ?a va'
|
|
hashed = utils.hash_password(password)
|
|
self.assertTrue(utils.check_password(password, hashed))
|
|
self.assertFalse(utils.check_password(wrong, hashed))
|
|
|
|
def test_auth_str_equal(self):
|
|
self.assertTrue(utils.auth_str_equal('abc123', 'abc123'))
|
|
self.assertFalse(utils.auth_str_equal('a', 'aaaaa'))
|
|
self.assertFalse(utils.auth_str_equal('aaaaa', 'a'))
|
|
self.assertFalse(utils.auth_str_equal('ABC123', 'abc123'))
|