URL: https://github.com/freeipa/freeipa/pull/1247
Author: stlaz
 Title: #1247: [Backport][ipa-4-6] CA-less integration tests minor log fixes
Action: opened

PR body:
"""
This PR was opened automatically because PR #1233 was pushed to master and 
backport to ipa-4-6 is required.
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/1247/head:pr1247
git checkout pr1247
From ac9a39e3a65ed0116b03c09c4bbb6c9baef5c50f Mon Sep 17 00:00:00 2001
From: Stanislav Laznicka <slazn...@redhat.com>
Date: Mon, 6 Nov 2017 09:07:31 +0100
Subject: [PATCH 1/2] caless tests: make debug log of certificates sensible

CA-less tests debug logging uses representation of a variable
containing the certificate object, which does not help very much.
Use the actual DER representation of the certificate on such places.
---
 ipatests/test_integration/test_caless.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ipatests/test_integration/test_caless.py b/ipatests/test_integration/test_caless.py
index ef33be2136..231cdb75e7 100644
--- a/ipatests/test_integration/test_caless.py
+++ b/ipatests/test_integration/test_caless.py
@@ -360,8 +360,8 @@ def verify_installation(self):
         logger.debug('Expected /etc/ipa/ca.crt contents:\n%s',
                      expected_cacrt.decode('utf-8'))
         expected_cacrt = x509.load_unknown_x509_certificate(expected_cacrt)
-        logger.debug('Expected binary CA cert:\n%r',
-                     expected_cacrt)
+        logger.debug('Expected CA cert:\n%r',
+                     expected_cacrt.public_bytes(x509.Encoding.PEM))
         for host in [self.master] + self.replicas:
             # Check the LDAP entry
             ldap = host.ldap_connect()
@@ -370,7 +370,7 @@ def verify_installation(self):
                                       ('cn', 'etc'), host.domain.basedn))
             cert_from_ldap = entry.single_value['cACertificate']
             logger.debug('CA cert from LDAP on %s:\n%r',
-                         host, cert_from_ldap)
+                         host, cert_from_ldap.public_bytes(x509.Encoding.PEM))
             assert cert_from_ldap == expected_cacrt
 
             # Verify certmonger was not started
@@ -384,7 +384,7 @@ def verify_installation(self):
                          host, remote_cacrt)
             cacrt = x509.load_unknown_x509_certificate(remote_cacrt)
             logger.debug('%s: Decoded /etc/ipa/ca.crt:\n%r',
-                         host, cacrt)
+                         host, cacrt.public_bytes(x509.Encoding.PEM))
             assert expected_cacrt == cacrt
 
 

From 06497c1a5576b3893a62457210b4e90fce1bf800 Mon Sep 17 00:00:00 2001
From: Stanislav Laznicka <slazn...@redhat.com>
Date: Mon, 6 Nov 2017 09:11:39 +0100
Subject: [PATCH 2/2] caless tests: decode cert bytes in debug log

Bytes would cause the logger to throw up while interpolating the
string.
---
 ipatests/test_integration/test_caless.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipatests/test_integration/test_caless.py b/ipatests/test_integration/test_caless.py
index 231cdb75e7..eccc9967db 100644
--- a/ipatests/test_integration/test_caless.py
+++ b/ipatests/test_integration/test_caless.py
@@ -381,7 +381,7 @@ def verify_installation(self):
             # Check the cert PEM file
             remote_cacrt = host.get_file_contents(paths.IPA_CA_CRT)
             logger.debug('%s:/etc/ipa/ca.crt contents:\n%s',
-                         host, remote_cacrt)
+                         host, remote_cacrt.decode('utf-8'))
             cacrt = x509.load_unknown_x509_certificate(remote_cacrt)
             logger.debug('%s: Decoded /etc/ipa/ca.crt:\n%r',
                          host, cacrt.public_bytes(x509.Encoding.PEM))
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to