From 4ea34d5910f304c50a1a432f43318239b1db8be6 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Mon, 12 Jul 2010 17:48:58 -0400 Subject: Add framework for other command-line tests, starting with ipa-getkeytab. --- tests/test_cmdline/cmdline.py | 61 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tests/test_cmdline/cmdline.py (limited to 'tests/test_cmdline/cmdline.py') diff --git a/tests/test_cmdline/cmdline.py b/tests/test_cmdline/cmdline.py new file mode 100644 index 000000000..4de06850c --- /dev/null +++ b/tests/test_cmdline/cmdline.py @@ -0,0 +1,61 @@ +# Authors: +# Rob Crittenden +# +# Copyright (C) 2010 Red Hat +# see file 'COPYING' for use and warranty information +# +# 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; version 2 only +# +# 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 +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +""" +Base class for all cmdline tests +""" + +import nose +import ldap +import krbV +from ipalib import api, request +from ipalib import errors +from tests.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().name + +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 + """ + + def setUp(self): + 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() -- cgit