2010-07-12 16:48:58 -05:00
|
|
|
# Authors:
|
|
|
|
# Rob Crittenden <rcritten@redhat.com>
|
|
|
|
#
|
|
|
|
# Copyright (C) 2010 Red Hat
|
|
|
|
# see file 'COPYING' for use and warranty information
|
|
|
|
#
|
2010-12-09 06:59:11 -06:00
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
2010-07-12 16:48:58 -05:00
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2010-12-09 06:59:11 -06:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-07-12 16:48:58 -05:00
|
|
|
|
|
|
|
"""
|
|
|
|
Base class for all cmdline tests
|
|
|
|
"""
|
|
|
|
|
|
|
|
import nose
|
|
|
|
import krbV
|
2013-06-03 08:04:58 -05:00
|
|
|
import distutils.spawn
|
|
|
|
import os
|
2013-01-10 05:14:15 -06:00
|
|
|
|
|
|
|
from ipalib import api
|
2010-07-12 16:48:58 -05:00
|
|
|
from ipalib import errors
|
2014-05-29 07:47:17 -05:00
|
|
|
from ipaplatform.paths import paths
|
2013-05-21 06:40:27 -05:00
|
|
|
from ipatests.test_xmlrpc.xmlrpc_test import XMLRPC_test
|
2010-07-12 16:48:58 -05:00
|
|
|
from ipaserver.plugins.ldap2 import ldap2
|
|
|
|
|
|
|
|
# See if our LDAP server is up and we can talk to it over GSSAPI
|
2013-05-22 05:26:55 -05:00
|
|
|
ccache = krbV.default_context().default_ccache()
|
2010-07-12 16:48:58 -05:00
|
|
|
|
|
|
|
try:
|
2015-06-22 05:58:43 -05:00
|
|
|
conn = ldap2(api)
|
2010-07-12 16:48:58 -05:00
|
|
|
conn.connect(ccache=ccache)
|
|
|
|
conn.disconnect()
|
|
|
|
server_available = True
|
|
|
|
except errors.DatabaseError:
|
|
|
|
server_available = False
|
2015-07-30 09:49:29 -05:00
|
|
|
except Exception as e:
|
2010-07-12 16:48:58 -05:00
|
|
|
server_available = False
|
|
|
|
|
|
|
|
class cmdline_test(XMLRPC_test):
|
|
|
|
"""
|
|
|
|
Base class for all command-line tests
|
|
|
|
"""
|
2010-07-29 09:51:47 -05:00
|
|
|
# some reasonable default command
|
2014-05-29 07:47:17 -05:00
|
|
|
command = paths.LS
|
2010-07-12 16:48:58 -05:00
|
|
|
|
2014-10-08 02:42:52 -05:00
|
|
|
@classmethod
|
|
|
|
def setup_class(cls):
|
2013-06-03 08:04:58 -05:00
|
|
|
# Find the executable in $PATH
|
|
|
|
# This is neded because ipautil.run resets the PATH to
|
|
|
|
# a system default.
|
2014-10-08 02:42:52 -05:00
|
|
|
original_command = cls.command
|
|
|
|
if not os.path.isabs(cls.command):
|
|
|
|
cls.command = distutils.spawn.find_executable(cls.command)
|
2010-07-29 09:51:47 -05:00
|
|
|
# raise an error if the command is missing even if the remote
|
|
|
|
# server is not available.
|
2014-10-08 02:42:52 -05:00
|
|
|
if not cls.command:
|
2010-07-29 09:51:47 -05:00
|
|
|
raise AssertionError(
|
2013-06-03 08:04:58 -05:00
|
|
|
'Command %r not available' % original_command
|
2010-07-29 09:51:47 -05:00
|
|
|
)
|
2014-10-08 02:42:52 -05:00
|
|
|
super(cmdline_test, cls).setup_class()
|
2010-07-12 16:48:58 -05:00
|
|
|
if not server_available:
|
|
|
|
raise nose.SkipTest(
|
|
|
|
'Server not available: %r' % api.env.xmlrpc_uri
|
|
|
|
)
|