def test_uid_invalid_certificate(self, fake_read, fake_valid): fake_read.return_value = CERTIFICATE fake_valid.return_value = False bundle = Bundle('') uid = bundle.uid() fake_valid.assert_called_with() self.assertTrue(uid is None)
def test_uid(self, fake_read, fake_valid): fake_read.return_value = VERIZON_CERTIFICATE fake_valid.return_value = True bundle = Bundle('') uid = bundle.uid() fake_valid.assert_called_with() fake_read.assert_called_with() self.assertEqual(uid, 'vzn-user')
def uid(self): """ Get the userid (UID) part of the certificate subject. Returns None, if the certificate is invalid. :return The userid (UID) part of the certificate subject or None when the certificate is not found or invalid. :rtype: str """ try: return Bundle.uid(self) except X509Error: log.warn('certificate: %s, not valid', self.path)