Imported Upstream version 4.7.2
This commit is contained in:
@@ -21,10 +21,11 @@
|
||||
Base class for all cmdline tests
|
||||
"""
|
||||
|
||||
import nose
|
||||
import krbV
|
||||
from __future__ import absolute_import
|
||||
|
||||
import distutils.spawn
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from ipalib import api
|
||||
from ipalib import errors
|
||||
@@ -33,16 +34,14 @@ from ipatests.test_xmlrpc.xmlrpc_test import XMLRPC_test
|
||||
from ipaserver.plugins.ldap2 import ldap2
|
||||
|
||||
# See if our LDAP server is up and we can talk to it over GSSAPI
|
||||
ccache = krbV.default_context().default_ccache()
|
||||
|
||||
try:
|
||||
conn = ldap2(shared_instance=False, ldap_uri=api.env.ldap_uri, base_dn=api.env.basedn)
|
||||
conn.connect(ccache=ccache)
|
||||
conn = ldap2(api)
|
||||
conn.connect()
|
||||
conn.disconnect()
|
||||
server_available = True
|
||||
except errors.DatabaseError:
|
||||
server_available = False
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
server_available = False
|
||||
|
||||
class cmdline_test(XMLRPC_test):
|
||||
@@ -52,27 +51,22 @@ class cmdline_test(XMLRPC_test):
|
||||
# some reasonable default command
|
||||
command = paths.LS
|
||||
|
||||
def setUp(self):
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
# Find the executable in $PATH
|
||||
# This is neded because ipautil.run resets the PATH to
|
||||
# a system default.
|
||||
original_command = self.command
|
||||
if not os.path.isabs(self.command):
|
||||
self.command = distutils.spawn.find_executable(self.command)
|
||||
original_command = cls.command
|
||||
if not os.path.isabs(cls.command):
|
||||
cls.command = distutils.spawn.find_executable(cls.command)
|
||||
# raise an error if the command is missing even if the remote
|
||||
# server is not available.
|
||||
if not self.command:
|
||||
if not cls.command:
|
||||
raise AssertionError(
|
||||
'Command %r not available' % original_command
|
||||
)
|
||||
super(cmdline_test, self).setUp()
|
||||
super(cmdline_test, cls).setup_class()
|
||||
if not server_available:
|
||||
raise nose.SkipTest(
|
||||
raise unittest.SkipTest(
|
||||
'Server not available: %r' % api.env.xmlrpc_uri
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
nose tear-down fixture.
|
||||
"""
|
||||
super(cmdline_test, self).tearDown()
|
||||
|
||||
Reference in New Issue
Block a user