From c8161fc40cf0ec38612bc346097d6a93972ba032 Mon Sep 17 00:00:00 2001 From: Stanislav Laznicka Date: Fri, 8 Sep 2017 13:21:36 +0200 Subject: [PATCH] certmap testing: fix wrong cert construction `bytes` instances have no `.format()`, we can simply base64 decode the certificate and load it as DER instead. https://pagure.io/freeipa/issue/7131 Reviewed-By: Florence Blanc-Renaud Reviewed-By: Alexander Bokovoy --- ipatests/test_xmlrpc/tracker/certmapdata.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ipatests/test_xmlrpc/tracker/certmapdata.py b/ipatests/test_xmlrpc/tracker/certmapdata.py index b869640f8..47db97e4b 100644 --- a/ipatests/test_xmlrpc/tracker/certmapdata.py +++ b/ipatests/test_xmlrpc/tracker/certmapdata.py @@ -1,6 +1,8 @@ # # Copyright (C) 2015 FreeIPA Contributors see COPYING for license # +import base64 + from cryptography import x509 from cryptography.hazmat.backends import default_backend from nose.tools import assert_raises @@ -50,11 +52,9 @@ class CertmapdataMixin(object): certs = [certs] for cert in certs: - cert = x509.load_pem_x509_certificate( - (b'-----BEGIN CERTIFICATE-----\n' - b'{}-----END CERTIFICATE-----\n' - .format(cert)), - default_backend() + cert = x509.load_der_x509_certificate( + base64.b64decode(cert), + backend=default_backend() ) issuer = DN(cert.issuer).x500_text() subject = DN(cert.subject).x500_text()