2012-02-06 21:21:46 -05:00
|
|
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
|
|
|
2012-03-02 13:38:39 -06:00
|
|
|
# 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.
|
|
|
|
|
2012-03-28 10:37:16 -07:00
|
|
|
import uuid
|
|
|
|
|
2012-07-03 00:11:57 +08:00
|
|
|
from keystone.common.ldap import fakeldap
|
2012-02-06 21:21:46 -05:00
|
|
|
from keystone import config
|
2012-03-28 10:37:16 -07:00
|
|
|
from keystone import exception
|
2012-02-06 21:21:46 -05:00
|
|
|
from keystone.identity.backends import ldap as identity_ldap
|
2012-07-03 00:11:57 +08:00
|
|
|
from keystone import test
|
2012-02-06 21:21:46 -05:00
|
|
|
|
|
|
|
import default_fixtures
|
|
|
|
import test_backend
|
|
|
|
|
|
|
|
|
|
|
|
CONF = config.CONF
|
|
|
|
|
|
|
|
|
|
|
|
def clear_database():
|
|
|
|
db = fakeldap.FakeShelve().get_instance()
|
|
|
|
db.clear()
|
|
|
|
|
|
|
|
|
|
|
|
class LDAPIdentity(test.TestCase, test_backend.IdentityTests):
|
|
|
|
def setUp(self):
|
|
|
|
super(LDAPIdentity, self).setUp()
|
2012-05-29 08:59:47 +01:00
|
|
|
self.config([test.etcdir('keystone.conf.sample'),
|
|
|
|
test.testsdir('test_overrides.conf'),
|
|
|
|
test.testsdir('backend_ldap.conf')])
|
2012-02-06 21:21:46 -05:00
|
|
|
clear_database()
|
|
|
|
self.identity_api = identity_ldap.Identity()
|
|
|
|
self.load_fixtures(default_fixtures)
|
|
|
|
|
2012-03-28 10:37:16 -07:00
|
|
|
def test_role_crud(self):
|
|
|
|
role = {'id': uuid.uuid4().hex, 'name': uuid.uuid4().hex}
|
|
|
|
self.identity_api.create_role(role['id'], role)
|
|
|
|
role_ref = self.identity_api.get_role(role['id'])
|
|
|
|
role_ref_dict = dict((x, role_ref[x]) for x in role_ref)
|
|
|
|
self.assertDictEqual(role_ref_dict, role)
|
|
|
|
self.identity_api.delete_role(role['id'])
|
|
|
|
self.assertRaises(exception.RoleNotFound,
|
|
|
|
self.identity_api.get_role,
|
|
|
|
role['id'])
|
|
|
|
|
2012-06-27 18:20:16 -04:00
|
|
|
def test_build_tree(self):
|
|
|
|
"""Regression test for building the tree names
|
|
|
|
"""
|
|
|
|
self.config([test.etcdir('keystone.conf.sample'),
|
|
|
|
test.testsdir('test_overrides.conf'),
|
|
|
|
test.testsdir('backend_ldap.conf')])
|
|
|
|
|
|
|
|
user_api = identity_ldap.UserApi(CONF)
|
|
|
|
self.assertTrue(user_api)
|
|
|
|
self.assertEquals(user_api.tree_dn, "ou=Users,%s" % CONF.ldap.suffix)
|