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>
This commit is contained in:
Milan Kubík
2016-04-05 10:04:37 +02:00
committed by Martin Basti
parent 90ca7d4167
commit c4fa656b0e

View File

@@ -696,6 +696,7 @@ def change_principal(user, password, client=None, path=None):
client.Backend.rpcclient.disconnect()
try:
with private_ccache(ccache_name):
kinit_password(user, password, ccache_name)
client.Backend.rpcclient.connect()
@@ -704,7 +705,7 @@ def change_principal(user, password, client=None, path=None):
yield
finally:
client.Backend.rpcclient.disconnect()
finally:
client.Backend.rpcclient.connect()
def get_group_dn(cn):