mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Fix certificate type error when exporting to file
Commands `ipa ca-show` and `ipa cert-show` share the same code,
this commit updates the former, closing the gap between them.
Reflecting the changes done in 5a44ca6383
.
https://pagure.io/freeipa/issue/7628
Signed-off-by: Armando Neto <abiagion@redhat.com>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
parent
c29581c9a0
commit
c7064494e5
@ -1,6 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
|
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
|
||||||
#
|
#
|
||||||
|
import base64
|
||||||
|
|
||||||
from ipaclient.frontend import MethodOverride
|
from ipaclient.frontend import MethodOverride
|
||||||
from ipalib import errors, util, x509, Str
|
from ipalib import errors, util, x509, Str
|
||||||
@ -34,13 +35,11 @@ class WithCertOutArgs(MethodOverride):
|
|||||||
result = super(WithCertOutArgs, self).forward(*keys, **options)
|
result = super(WithCertOutArgs, self).forward(*keys, **options)
|
||||||
if filename:
|
if filename:
|
||||||
if options.get('chain', False):
|
if options.get('chain', False):
|
||||||
certs = (x509.load_der_x509_certificate(c)
|
certs = result['result']['certificate_chain']
|
||||||
for c in result['result']['certificate_chain'])
|
|
||||||
else:
|
else:
|
||||||
certs = [
|
certs = [result['result']['certificate']]
|
||||||
x509.load_der_x509_certificate(
|
certs = (x509.load_der_x509_certificate(base64.b64decode(cert))
|
||||||
result['result']['certificate'])
|
for cert in certs)
|
||||||
]
|
|
||||||
x509.write_certificate_list(certs, filename)
|
x509.write_certificate_list(certs, filename)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -97,6 +97,13 @@ class TestCAbasicCRUD(XMLRPC_test):
|
|||||||
def test_retrieve_all(self, crud_subca):
|
def test_retrieve_all(self, crud_subca):
|
||||||
crud_subca.retrieve(all=True)
|
crud_subca.retrieve(all=True)
|
||||||
|
|
||||||
|
def test_export_ca(self, tmpdir, crud_subca):
|
||||||
|
exported_ca = tmpdir.join('exported_ca')
|
||||||
|
command = crud_subca.make_retrieve_command(
|
||||||
|
certificate_out=u'%s' % exported_ca,
|
||||||
|
)
|
||||||
|
command()
|
||||||
|
|
||||||
def test_delete(self, crud_subca):
|
def test_delete(self, crud_subca):
|
||||||
crud_subca.delete()
|
crud_subca.delete()
|
||||||
|
|
||||||
|
@ -91,9 +91,10 @@ class CATracker(Tracker):
|
|||||||
result=dict(failed=[])
|
result=dict(failed=[])
|
||||||
), result)
|
), result)
|
||||||
|
|
||||||
def make_retrieve_command(self, all=False, raw=False):
|
def make_retrieve_command(self, all=False, raw=False, **options):
|
||||||
"""Make function that retrieves the entry using ${CMD}_show"""
|
"""Make function that retrieves the entry using ${CMD}_show"""
|
||||||
return self.make_command('ca_show', self.name, all=all, raw=raw)
|
return self.make_command('ca_show', self.name, all=all, raw=raw,
|
||||||
|
**options)
|
||||||
|
|
||||||
def check_retrieve(self, result, all=False, raw=False):
|
def check_retrieve(self, result, all=False, raw=False):
|
||||||
"""Check the plugin's `show` command result"""
|
"""Check the plugin's `show` command result"""
|
||||||
|
Loading…
Reference in New Issue
Block a user