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
|
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:
|
|
|
|
conn = ldap2(shared_instance=False, ldap_uri=api.env.ldap_uri, base_dn=api.env.basedn)
|
|
|
|
conn.connect(ccache=ccache)
|
|
|
|
conn.disconnect()
|
|
|
|
server_available = True
|
|
|
|
except errors.DatabaseError:
|
|
|
|
server_available = False
|
|
|
|
except Exception, e:
|
|
|
|
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
|
|
|
|
command = '/bin/ls'
|
2010-07-12 16:48:58 -05:00
|
|
|
|
|
|
|
def setUp(self):
|
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.
|
|
|
|
original_command = self.command
|
|
|
|
if not os.path.isabs(self.command):
|
|
|
|
self.command = distutils.spawn.find_executable(self.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.
|
2013-06-03 08:04:58 -05:00
|
|
|
if not self.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
|
|
|
)
|
2010-07-12 16:48:58 -05:00
|
|
|
super(cmdline_test, self).setUp()
|
|
|
|
if not server_available:
|
|
|
|
raise nose.SkipTest(
|
|
|
|
'Server not available: %r' % api.env.xmlrpc_uri
|
|
|
|
)
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
"""
|
|
|
|
nose tear-down fixture.
|
|
|
|
"""
|
|
|
|
super(cmdline_test, self).tearDown()
|