summaryrefslogtreecommitdiffstats
path: root/ipatests/util.py
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2017-02-14 07:49:20 -0500
committerJan Cholasta <jcholast@redhat.com>2017-02-15 07:13:37 +0100
commit09c92e2bc1ca9db5b73d5ab8483b42dbd6b9a0e9 (patch)
treea1ab78cb90035fd94fb8ea97c062cd92eef04415 /ipatests/util.py
parent41c1efc44a6b809445facd4772574595029553b1 (diff)
downloadfreeipa-09c92e2bc1ca9db5b73d5ab8483b42dbd6b9a0e9.tar.gz
freeipa-09c92e2bc1ca9db5b73d5ab8483b42dbd6b9a0e9.tar.xz
freeipa-09c92e2bc1ca9db5b73d5ab8483b42dbd6b9a0e9.zip
Explicitly pass down ccache names for connections
Instead of relying on side effects (setting the KRB5CCNAME env var), explicitly pass the ccache name to be used if it is not the default ccache. This fixes some tests that sometimes fail to work properly due to the wrong ccache being used. https://fedorahosted.org/freeipa/ticket/6543 Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipatests/util.py')
-rw-r--r--ipatests/util.py31
1 files changed, 18 insertions, 13 deletions
diff --git a/ipatests/util.py b/ipatests/util.py
index 932038352..f55ef73fa 100644
--- a/ipatests/util.py
+++ b/ipatests/util.py
@@ -43,7 +43,7 @@ from ipalib.install.kinit import kinit_keytab, kinit_password
from ipalib.plugable import Plugin
from ipalib.request import context
from ipapython.dn import DN
-from ipapython.ipautil import private_ccache, run
+from ipapython.ipautil import run
from ipaplatform.paths import paths
if six.PY3:
@@ -761,20 +761,25 @@ def change_principal(principal, password=None, client=None, path=None,
client.Backend.rpcclient.disconnect()
try:
- with private_ccache(ccache_name):
- if keytab:
- kinit_keytab(principal, keytab, ccache_name)
- else:
- kinit_password(principal, password, ccache_name,
- canonicalize=canonicalize,
- enterprise=enterprise)
- client.Backend.rpcclient.connect()
+ if keytab:
+ kinit_keytab(principal, keytab, ccache_name)
+ else:
+ kinit_password(principal, password, ccache_name,
+ canonicalize=canonicalize,
+ enterprise=enterprise)
+ client.Backend.rpcclient.connect(ccache=ccache_name)
- try:
- yield
- finally:
- client.Backend.rpcclient.disconnect()
+ try:
+ yield
+ finally:
+ client.Backend.rpcclient.disconnect()
finally:
+ # If we generated a ccache name, try to remove it, but don't fail
+ if not path:
+ try:
+ os.remove(ccache_name)
+ except OSError:
+ pass
client.Backend.rpcclient.connect()