Use the compound statement formatting API for configuring PKINIT

Use `if_branch` and `else_branch` context managers instead of raw
`command` calls in the method that generates Bash snippet that
configures PKINIT on the master.

https://pagure.io/freeipa/issue/7036

Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Martin Babinsky 2017-06-22 15:08:08 +02:00 committed by Martin Basti
parent 85a79b5ccd
commit a9fec090f7

View File

@ -214,15 +214,13 @@ class config_server_for_smart_card_auth(common_smart_card_auth_config):
def check_and_enable_pkinit(self):
self.log.comment('check whether PKINIT is configured on the master')
self.log.command(
"if ipa-pkinit-manage status | grep -q 'enabled'")
self.log.command('then')
self.log.command(' echo "PKINIT already enabled"')
self.log.command('else')
self.log.exit_on_failed_command(
'ipa-pkinit-manage enable',
['Failed to issue PKINIT certificates to local KDC'])
self.log.command('fi')
with self.log.if_branch(
"ipa-pkinit-manage status | grep -q 'enabled'"):
self.log.command('echo "PKINIT already enabled"')
with self.log.else_branch():
self.log.exit_on_failed_command(
'ipa-pkinit-manage enable',
['Failed to issue PKINIT certificates to local KDC'])
def enable_ok_to_auth_as_delegate_on_http_principal(self):
self.log.comment('Enable OK-AS-DELEGATE flag on the HTTP principal')