Rely on the lemur generating the correct name for rotated certificates. (#714)
* Rely on the lemur generating the correct name for rotated certificates. * Fixing tests.
This commit is contained in:
parent
602c5580d3
commit
3c5b2618c0
|
@ -470,6 +470,11 @@ def get_certificate_primitives(certificate):
|
||||||
"""
|
"""
|
||||||
start, end = calculate_reissue_range(certificate.not_before, certificate.not_after)
|
start, end = calculate_reissue_range(certificate.not_before, certificate.not_after)
|
||||||
data = CertificateInputSchema().load(CertificateOutputSchema().dump(certificate).data).data
|
data = CertificateInputSchema().load(CertificateOutputSchema().dump(certificate).data).data
|
||||||
|
|
||||||
|
# we can't quite tell if we are using a custom name, as this is an automated process (typically)
|
||||||
|
# we will rely on the Lemur generated name
|
||||||
|
data.pop('name', None)
|
||||||
|
|
||||||
data['validity_start'] = start
|
data['validity_start'] = start
|
||||||
data['validity_end'] = end
|
data['validity_end'] = end
|
||||||
return data
|
return data
|
||||||
|
@ -484,8 +489,7 @@ def reissue_certificate(certificate, replace=None, user=None):
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
primitives = get_certificate_primitives(certificate)
|
primitives = get_certificate_primitives(certificate)
|
||||||
from pprint import pprint
|
|
||||||
pprint(primitives)
|
|
||||||
if not user:
|
if not user:
|
||||||
primitives['creator'] = certificate.user
|
primitives['creator'] = certificate.user
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ def test_get_certificate_primitives(certificate):
|
||||||
|
|
||||||
with freeze_time(datetime.date(year=2016, month=10, day=30)):
|
with freeze_time(datetime.date(year=2016, month=10, day=30)):
|
||||||
primitives = get_certificate_primitives(certificate)
|
primitives = get_certificate_primitives(certificate)
|
||||||
assert len(primitives) == 21
|
assert len(primitives) == 20
|
||||||
|
|
||||||
|
|
||||||
def test_certificate_edit_schema(session):
|
def test_certificate_edit_schema(session):
|
||||||
|
@ -321,7 +321,7 @@ def test_import(user):
|
||||||
assert str(cert.not_after) == '2040-01-01T20:30:52+00:00'
|
assert str(cert.not_after) == '2040-01-01T20:30:52+00:00'
|
||||||
assert str(cert.not_before) == '2015-06-26T20:30:52+00:00'
|
assert str(cert.not_before) == '2015-06-26T20:30:52+00:00'
|
||||||
assert cert.issuer == 'Example'
|
assert cert.issuer == 'Example'
|
||||||
assert cert.name == 'long.lived.com-Example-20150626-20400101-1'
|
assert cert.name == 'long.lived.com-Example-20150626-20400101-2'
|
||||||
|
|
||||||
cert = import_certificate(body=INTERNAL_VALID_LONG_STR, chain=INTERNAL_VALID_SAN_STR, private_key=PRIVATE_KEY_STR, owner='joe@example.com', name='ACustomName2', creator=user['user'])
|
cert = import_certificate(body=INTERNAL_VALID_LONG_STR, chain=INTERNAL_VALID_SAN_STR, private_key=PRIVATE_KEY_STR, owner='joe@example.com', name='ACustomName2', creator=user['user'])
|
||||||
assert cert.name == 'ACustomName2'
|
assert cert.name == 'ACustomName2'
|
||||||
|
@ -333,7 +333,7 @@ def test_upload(user):
|
||||||
assert str(cert.not_after) == '2040-01-01T20:30:52+00:00'
|
assert str(cert.not_after) == '2040-01-01T20:30:52+00:00'
|
||||||
assert str(cert.not_before) == '2015-06-26T20:30:52+00:00'
|
assert str(cert.not_before) == '2015-06-26T20:30:52+00:00'
|
||||||
assert cert.issuer == 'Example'
|
assert cert.issuer == 'Example'
|
||||||
assert cert.name == 'long.lived.com-Example-20150626-20400101-2'
|
assert cert.name == 'long.lived.com-Example-20150626-20400101-3'
|
||||||
|
|
||||||
cert = upload(body=INTERNAL_VALID_LONG_STR, chain=INTERNAL_VALID_SAN_STR, private_key=PRIVATE_KEY_STR, owner='joe@example.com', name='ACustomName', creator=user['user'])
|
cert = upload(body=INTERNAL_VALID_LONG_STR, chain=INTERNAL_VALID_SAN_STR, private_key=PRIVATE_KEY_STR, owner='joe@example.com', name='ACustomName', creator=user['user'])
|
||||||
assert 'ACustomName' in cert.name
|
assert 'ACustomName' in cert.name
|
||||||
|
|
Loading…
Reference in New Issue