def test_x509_matches_hostname(self): """ The returned X.509 certificate is valid for the hostname. """ verify_certificate_hostname( self.server_x509_cert.to_cryptography(), self.hostname, )
def test_certificate_verify_hostname_fail(self): """ verify_certificate_hostname fails if the hostnames don't match and provides the user with helpful information. """ with pytest.raises(VerificationError) as ei: verify_certificate_hostname(X509_DNS_ONLY, u"google.com") assert [DNSMismatch(mismatched_id=DNS_ID(u"google.com")) ] == ei.value.errors
def test_certificate_verify_hostname_fail(self): """ verify_certificate_hostname fails if the hostnames don't match and provides the user with helpful information. """ with pytest.raises(VerificationError) as ei: verify_certificate_hostname(X509_DNS_ONLY, u"google.com") assert [ DNSMismatch(mismatched_id=DNS_ID(u"google.com")) ] == ei.value.errors
def test_verify_hostname(self): """ It's just a convenience one-liner. Let's check it doesn't explode b/c of some typo. """ verify_certificate_hostname(X509_DNS_ONLY, u"twistedmatrix.com")
def test_certificate_verify_hostname_ok(self): """ verify_certificate_hostname succeeds if the hostnames match. """ verify_certificate_hostname(X509_DNS_ONLY, u"twistedmatrix.com")