ipatests: Allow change_principal context manager to use canonicalization

The context manager has been extended to optionally request principal
canonicalization and indicate that the enterprise principal is being
used.

This allows to change the user during the test to an user using the alias
and to test behavior related to enterprise principals.

https://fedorahosted.org/freeipa/ticket/6142

Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
This commit is contained in:
Milan Kubík 2016-07-25 13:24:51 +02:00 committed by Martin Basti
parent 8e83b9715a
commit e17ec08dae

View File

@ -693,7 +693,8 @@ def unlock_principal_password(user, oldpw, newpw):
@contextmanager @contextmanager
def change_principal(user, password, client=None, path=None): def change_principal(user, password, client=None, path=None,
canonicalize=False, enterprise=False):
if path: if path:
ccache_name = path ccache_name = path
@ -708,7 +709,8 @@ def change_principal(user, password, client=None, path=None):
try: try:
with private_ccache(ccache_name): with private_ccache(ccache_name):
kinit_password(user, password, ccache_name) kinit_password(user, password, ccache_name,
canonicalize=canonicalize, enterprise=enterprise)
client.Backend.rpcclient.connect() client.Backend.rpcclient.connect()
try: try: