Exemplo n.º 1
0
 def test_cn_invalid_certificate(self, fake_read, fake_valid):
     fake_read.return_value = CERTIFICATE
     fake_valid.return_value = False
     bundle = Bundle('')
     cn = bundle.cn()
     fake_valid.assert_called_with()
     self.assertTrue(cn is None)
Exemplo n.º 2
0
 def test_cn_invalid_certificate(self, fake_read, fake_valid):
     fake_read.return_value = CERTIFICATE
     fake_valid.return_value = False
     bundle = Bundle('')
     cn = bundle.cn()
     fake_valid.assert_called_with()
     self.assertTrue(cn is None)
Exemplo n.º 3
0
 def test_cn(self, fake_read, fake_valid):
     fake_read.return_value = CERTIFICATE
     fake_valid.return_value = True
     bundle = Bundle('')
     cn = bundle.cn()
     fake_valid.assert_called_with()
     fake_read.assert_called_with()
     self.assertEqual(cn, 'localhost')
Exemplo n.º 4
0
 def test_cn(self, fake_read, fake_valid):
     fake_read.return_value = CERTIFICATE
     fake_valid.return_value = True
     bundle = Bundle('')
     cn = bundle.cn()
     fake_valid.assert_called_with()
     fake_read.assert_called_with()
     self.assertEqual(cn, 'localhost')
Exemplo n.º 5
0
 def cn(self):
     """
     Get the common name (CN) part of the certificate subject.
     Returns None, if the certificate is invalid.
     :return The common name (CN) part of the certificate subject or None when
         the certificate is not found or invalid.
     :rtype: str
     """
     try:
         return Bundle.cn(self)
     except X509Error:
         log.warn('certificate: %s, not valid', self.path)