'A certificate written by ``RootCredential.initialize`` has an expiry
date 20 years from the date of signing.
XXX: This test is prone to intermittent failure depending on the time
of day it is run. Fixed in
https://github.com/ClusterHQ/flocker/pull/1339'

def test_certificate_expiration(self):

    path = FilePath(self.mktemp())
    path.makedirs()
    start_date = datetime.datetime.utcnow()
    expected_expiry = (start_date + datetime.timedelta(seconds=EXPIRY_20_YEARS))
    expected_expiry = expected_expiry.strftime('%Y%m%d%H%M%SZ')
    ca = RootCredential.initialize(path, 'mycluster', begin=start_date)
    cert = ca.credential.certificate.original
    date_str = cert.get_notAfter()
    self.assertEqual(date_str, expected_expiry)
