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)
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)
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')
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')
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)