Move fakeldap.py from auth dir to tests.

Also removes the auth  dir from nova.
fix bug lp:1054848

Change-Id: I9c2710c9789ff8413bc80044eba94f3a851d8544
This commit is contained in:
Yaguang Tang 2012-09-23 12:33:18 +08:00
parent 338fae4f2b
commit 821271113d
5 changed files with 17 additions and 44 deletions

View File

@ -1,28 +0,0 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# 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.
"""
:mod:`nova.auth` -- Authentication and Access Control
=====================================================
.. automodule:: nova.auth
:platform: Unix
:synopsis: User-and-Project based RBAC using LDAP, SAML.
.. moduleauthor:: Jesse Andrews <jesse@ansolabs.com>
.. moduleauthor:: Vishvananda Ishaya <vishvananda@gmail.com>
.. moduleauthor:: Joshua McKenty <joshua@cognition.ca>
"""

View File

@ -15,7 +15,6 @@
import ldap
import time
from nova.auth import fakeldap
from nova import exception
from nova import flags
from nova.openstack.common import cfg
@ -360,14 +359,3 @@ class LdapDNS(object):
def delete_dns_file(self):
LOG.warn("This shouldn't be getting called except during testing.")
pass
class FakeLdapDNS(LdapDNS):
"""For testing purposes, a DNS driver backed with a fake ldap driver."""
def __init__(self):
self.lobj = fakeldap.FakeLDAP()
attrs = {'objectClass': ['domainrelatedobject', 'dnsdomain',
'domain', 'dcobject', 'top'],
'associateddomain': ['root'],
'dc': ['root']}
self.lobj.add_s(flags.FLAGS.ldap_dns_base_dn, create_modlist(attrs))

View File

@ -23,6 +23,7 @@ import tempfile
from nova import context
from nova import db
from nova import exception
from nova.network import ldapdns
from nova.network import linux_net
from nova.network import manager as network_manager
from nova.openstack.common import importutils
@ -30,6 +31,7 @@ from nova.openstack.common import log as logging
from nova.openstack.common import rpc
import nova.policy
from nova import test
from nova.tests import fake_ldap
from nova.tests import fake_network
from nova import utils
@ -1827,17 +1829,27 @@ domain1 = "example.org"
domain2 = "example.com"
class FakeLdapDNS(ldapdns.LdapDNS):
"""For testing purposes, a DNS driver backed with a fake ldap driver."""
def __init__(self):
self.lobj = fake_ldap.FakeLDAP()
attrs = {'objectClass': ['domainrelatedobject', 'dnsdomain',
'domain', 'dcobject', 'top'],
'associateddomain': ['root'],
'dc': ['root']}
self.lobj.add_s("ou=hosts,dc=example,dc=org",
ldapdns.create_modlist(attrs))
class LdapDNSTestCase(test.TestCase):
"""Tests nova.network.ldapdns.LdapDNS"""
def setUp(self):
super(LdapDNSTestCase, self).setUp()
self.saved_ldap = sys.modules.get('ldap')
import nova.auth.fakeldap
sys.modules['ldap'] = nova.auth.fakeldap
sys.modules['ldap'] = fake_ldap
temp = importutils.import_object('nova.network.ldapdns.FakeLdapDNS')
self.driver = temp
self.driver = FakeLdapDNS()
self.driver.create_domain(domain1)
self.driver.create_domain(domain2)

View File

@ -2,6 +2,7 @@
distribute>=0.6.24
coverage
python-ldap
mox==0.5.3
nose
openstack.nose_plugin>=0.7