summaryrefslogtreecommitdiffstats
path: root/ipatests
diff options
context:
space:
mode:
authorMilan KubĂ­k <mkubik@redhat.com>2016-04-05 10:04:37 +0200
committerMartin Basti <mbasti@redhat.com>2016-04-21 17:06:54 +0200
commitb0b9972213760dcf351cdd85dbfe2c38fc21b2e6 (patch)
tree7a2a30c08c19c0d78297524d70eb9d2c5a22515e /ipatests
parentc2b92b57354923a8099a0da446cef63802d2447b (diff)
downloadfreeipa-b0b9972213760dcf351cdd85dbfe2c38fc21b2e6.tar.gz
freeipa-b0b9972213760dcf351cdd85dbfe2c38fc21b2e6.tar.xz
freeipa-b0b9972213760dcf351cdd85dbfe2c38fc21b2e6.zip
ipatests: fix for change_principal context manager
The context manager was leaving API object disconnected when an exception was raised inside of it. This led to resource leak in the tests. https://fedorahosted.org/freeipa/ticket/5733 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
Diffstat (limited to 'ipatests')
-rw-r--r--ipatests/util.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/ipatests/util.py b/ipatests/util.py
index 6aefe74d3..118c47a12 100644
--- a/ipatests/util.py
+++ b/ipatests/util.py
@@ -696,16 +696,17 @@ def change_principal(user, password, client=None, path=None):
client.Backend.rpcclient.disconnect()
- with private_ccache(ccache_name):
- kinit_password(user, password, ccache_name)
- client.Backend.rpcclient.connect()
-
- try:
- yield
- finally:
- client.Backend.rpcclient.disconnect()
+ try:
+ with private_ccache(ccache_name):
+ kinit_password(user, password, ccache_name)
+ client.Backend.rpcclient.connect()
- client.Backend.rpcclient.connect()
+ try:
+ yield
+ finally:
+ client.Backend.rpcclient.disconnect()
+ finally:
+ client.Backend.rpcclient.connect()
def get_group_dn(cn):
return DN(('cn', cn), api.env.container_group, api.env.basedn)