def testConvertAmountInDays(self): thirty_days = six.text_type(30 * 24 * 60 * 60) + 's' modified = hooks.ConvertCertificateLifetimeToIso8601( self._GenerateCertificate(thirty_days), None) self.assertEqual(modified.lifetime, 'P30D') self.assertEqual( modified.certificateDescription.subjectDescription.lifetime, 'P30D')
def testConvertAmountLessThanDays(self): two_hours = six.text_type(2 * 60 * 60) + 's' modified = hooks.ConvertCertificateLifetimeToIso8601( self._GenerateCertificate(two_hours), None) self.assertEqual(modified.lifetime, 'PT2H') self.assertEqual( modified.certificateDescription.subjectDescription.lifetime, 'PT2H')
def testConvertAmountInTwoUnits(self): thirty_days_and_two_hours = str(30 * 24 * 60 * 60 + 2 * 60 * 60) + 's' modified = hooks.ConvertCertificateLifetimeToIso8601( self._GenerateCertificate(thirty_days_and_two_hours), None) self.assertEqual(modified.lifetime, 'P30DT2H') self.assertEqual( modified.certificateDescription.subjectDescription.lifetime, 'P30DT2H')
def testHandleMissingLifetimesWithoutErrors(self): cert_without_lifetimes = self.messages.Certificate(name='foo') hooks.ConvertCertificateLifetimeToIso8601(cert_without_lifetimes, None)