def test_certificate_info_exception(): with pytest.raises(ParseException): ssl_certificate.CertificateInfo(context_wrap(BAD_OUTPUT1)) with pytest.raises(ParseException): ssl_certificate.CertificateInfo(context_wrap(BAD_OUTPUT2)) with pytest.raises(ContentException): ssl_certificate.CertificateInfo(context_wrap(BAD_OUTPUT3)) with pytest.raises(SkipException): ssl_certificate.CertificateInfo(context_wrap(BAD_OUTPUT4))
def test_doc(): cert = ssl_certificate.CertificateInfo(context_wrap(CERTIFICATE_OUTPUT1)) ca_cert = ssl_certificate.CertificateChain( context_wrap(CERTIFICATE_CHAIN_OUTPUT1)) satellite_ca_certs = ssl_certificate.SatelliteCustomCaChain( context_wrap(SATELLITE_OUTPUT2)) rhsm_katello_default_ca = ssl_certificate.RhsmKatelloDefaultCACert( context_wrap(RHSM_KATELLO_CERT_OUTPUT1)) date_info = ssl_certificate.HttpdSSLCertExpireDate( context_wrap(HTTPD_CERT_EXPIRE_INFO)) nginx_date_info = ssl_certificate.NginxSSLCertExpireDate( context_wrap(HTTPD_CERT_EXPIRE_INFO, args='/a/b/c.pem')) mssql_date_info = ssl_certificate.MssqlTLSCertExpireDate( context_wrap(MSSQL_CERT_EXPIRE_INFO)) cert_info = ssl_certificate.HttpdCertInfoInNSS( context_wrap(NSS_CERT_OUTPUT)) globs = { 'cert': cert, 'certs': ca_cert, 'satellite_ca_certs': satellite_ca_certs, 'rhsm_katello_default_ca': rhsm_katello_default_ca, 'date_info': date_info, 'nginx_date_info': nginx_date_info, 'mssql_date_info': mssql_date_info, 'nss_cert_info': cert_info } failed, _ = doctest.testmod(ssl_certificate, globs=globs) assert failed == 0
def test_certificate_info(): cert = ssl_certificate.CertificateInfo(context_wrap(CERTIFICATE_OUTPUT1, args='/a/b/c.pem')) assert cert['issuer'] == '/C=US/ST=North Carolina/L=Raleigh/O=Katello/OU=SomeOrgUnit/CN=a.b.c.com' assert cert['notBefore'].str == 'Dec 7 07:02:33 2020' assert cert['notAfter'].str == 'Jan 18 07:02:33 2038' assert cert['subject'] == '/C=US/ST=North Carolina/L=Raleigh/O=Katello/OU=SomeOrgUnit/CN=a.b.c.com' assert cert.cert_path == '/a/b/c.pem'
def test_doc(): cert = ssl_certificate.CertificateInfo(context_wrap(CERTIFICATE_OUTPUT1)) ca_cert = ssl_certificate.CertificateChain( context_wrap(CERTIFICATE_CHAIN_OUTPUT1)) satellite_ca_certs = ssl_certificate.SatelliteCustomCaChain( context_wrap(SATELLITE_OUTPUT2)) rhsm_katello_default_ca = ssl_certificate.RhsmKatelloDefaultCACert( context_wrap(RHSM_KATELLO_CERT_OUTPUT1)) globs = { 'cert': cert, 'certs': ca_cert, 'satellite_ca_certs': satellite_ca_certs, 'rhsm_katello_default_ca': rhsm_katello_default_ca } failed, tested = doctest.testmod(ssl_certificate, globs=globs) assert failed == 0