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
|
|
|
|
"""
|
|
|
|
|
2018-04-05 02:21:16 -05:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2013-06-03 08:04:58 -05:00
|
|
|
import os
|
2013-01-10 05:14:15 -06:00
|
|
|
|
2019-06-20 09:14:02 -05:00
|
|
|
import pytest
|
2022-11-21 02:03:56 -06:00
|
|
|
import shutil
|
2019-06-20 09:14:02 -05:00
|
|
|
|
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
|
|
|
|
try:
|
2015-06-22 05:58:43 -05:00
|
|
|
conn = ldap2(api)
|
2015-07-20 09:04:07 -05:00
|
|
|
conn.connect()
|
2010-07-12 16:48:58 -05:00
|
|
|
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
|
|
|
|
2019-06-20 09:14:02 -05:00
|
|
|
@pytest.fixture(autouse=True, scope="class")
|
|
|
|
def cmdline_setup(self, request, xmlrpc_setup):
|
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.
|
2019-06-20 09:14:02 -05:00
|
|
|
cls = request.cls
|
2014-10-08 02:42:52 -05:00
|
|
|
original_command = cls.command
|
|
|
|
if not os.path.isabs(cls.command):
|
2022-11-21 02:03:56 -06:00
|
|
|
cls.command = shutil.which(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
|
|
|
)
|
2010-07-12 16:48:58 -05:00
|
|
|
if not server_available:
|
2019-10-15 05:24:11 -05:00
|
|
|
pytest.skip(
|
2010-07-12 16:48:58 -05:00
|
|
|
'Server not available: %r' % api.env.xmlrpc_uri
|
|
|
|
)
|