summaryrefslogtreecommitdiffstats
path: root/ipatests/test_cmdline/test_ipagetkeytab.py
diff options
context:
space:
mode:
authorMichael Simacek <msimacek@redhat.com>2015-07-20 16:04:07 +0200
committerJan Cholasta <jcholast@redhat.com>2015-08-26 09:41:36 +0200
commitaad73fad601f576dd83b758f4448839b4e8e87df (patch)
treec99433fc5aade363e7f9f66a7c08fcfd8e3dfc69 /ipatests/test_cmdline/test_ipagetkeytab.py
parentaebb72e1fb144939285380a6a9261c4d4177195e (diff)
downloadfreeipa-aad73fad601f576dd83b758f4448839b4e8e87df.tar.gz
freeipa-aad73fad601f576dd83b758f4448839b4e8e87df.tar.xz
freeipa-aad73fad601f576dd83b758f4448839b4e8e87df.zip
Port from python-krbV to python-gssapi
python-krbV library is deprecated and doesn't work with python 3. Replacing all it's usages with python-gssapi. - Removed Backend.krb and KRB5_CCache classes They were wrappers around krbV classes that cannot really work without them - Added few utility functions for querying GSSAPI credentials in krb_utils module. They provide replacements for KRB5_CCache. - Merged two kinit_keytab functions - Changed ldap plugin connection defaults to match ipaldap - Unified getting default realm Using api.env.realm instead of krbV call Reviewed-By: Jan Cholasta <jcholast@redhat.com> Reviewed-By: Robbie Harwood <rharwood@redhat.com> Reviewed-By: Simo Sorce <ssorce@redhat.com>
Diffstat (limited to 'ipatests/test_cmdline/test_ipagetkeytab.py')
-rw-r--r--ipatests/test_cmdline/test_ipagetkeytab.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/ipatests/test_cmdline/test_ipagetkeytab.py b/ipatests/test_cmdline/test_ipagetkeytab.py
index 2b99c268e..d9ab0daaa 100644
--- a/ipatests/test_cmdline/test_ipagetkeytab.py
+++ b/ipatests/test_cmdline/test_ipagetkeytab.py
@@ -26,10 +26,10 @@ from cmdline import cmdline_test
from ipalib import api
from ipalib import errors
import tempfile
-from ipapython import ipautil
+from ipapython import ipautil, ipaldap
import nose
import tempfile
-import krbV
+import gssapi
from ipaserver.plugins.ldap2 import ldap2
from ipapython.dn import DN
@@ -37,21 +37,18 @@ def use_keytab(principal, keytab):
try:
tmpdir = tempfile.mkdtemp(prefix = "tmp-")
ccache_file = 'FILE:%s/ccache' % tmpdir
- krbcontext = krbV.default_context()
- principal = str(principal)
- keytab = krbV.Keytab(name=keytab, context=krbcontext)
- principal = krbV.Principal(name=principal, context=krbcontext)
+ name = gssapi.Name(principal, gssapi.NameType.kerberos_principal)
+ store = {'ccache': ccache_file,
+ 'client_keytab': keytab}
os.environ['KRB5CCNAME'] = ccache_file
- ccache = krbV.CCache(name=ccache_file, context=krbcontext, primary_principal=principal)
- ccache.init(principal)
- ccache.init_creds_keytab(keytab=keytab, principal=principal)
+ gssapi.Credentials(name=name, usage='initiate', store=store)
conn = ldap2(api)
- conn.connect(ccache=ccache)
+ conn.connect(autobind=ipaldap.AUTOBIND_DISABLED)
conn.disconnect()
- except krbV.Krb5Error as e:
- raise StandardError('Unable to bind to LDAP. Error initializing principal %s in %s: %s' % (principal.name, keytab, str(e)))
+ except gssapi.exceptions.GSSError as e:
+ raise StandardError('Unable to bind to LDAP. Error initializing principal %s in %s: %s' % (principal, keytab, str(e)))
finally:
- del os.environ['KRB5CCNAME']
+ os.environ.pop('KRB5CCNAME', None)
if tmpdir:
shutil.rmtree(tmpdir)