Hexify cert serial (#763)
* Hexify serial at the serialization layer * Fix for flakey test. Change test to test for uppercased string
This commit is contained in:
parent
88ac783fd2
commit
05f4ae8e58
|
@ -6,7 +6,7 @@
|
|||
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
|
||||
"""
|
||||
from flask import current_app
|
||||
from marshmallow import fields, validate, validates_schema, post_load, pre_load
|
||||
from marshmallow import fields, validate, validates_schema, post_load, pre_load, post_dump
|
||||
from marshmallow.exceptions import ValidationError
|
||||
|
||||
from lemur.schemas import AssociatedAuthoritySchema, AssociatedDestinationSchema, AssociatedCertificateSchema, \
|
||||
|
@ -198,6 +198,12 @@ class CertificateOutputSchema(LemurOutputSchema):
|
|||
endpoints = fields.Nested(EndpointNestedOutputSchema, many=True, missing=[])
|
||||
replaced_by = fields.Nested(CertificateNestedOutputSchema, many=True, attribute='replaced')
|
||||
|
||||
@post_dump
|
||||
def convert_serial_to_hex(self, data):
|
||||
if data:
|
||||
data['serial'] = hex(int(data['serial']))[2:].upper()
|
||||
return data
|
||||
|
||||
|
||||
class CertificateUploadInputSchema(CertificateCreationSchema):
|
||||
name = fields.String()
|
||||
|
|
|
@ -73,14 +73,14 @@ def test_authority_key_identifier_schema():
|
|||
|
||||
data, errors = AuthorityKeyIdentifierSchema().load(input_data)
|
||||
|
||||
assert data == {
|
||||
assert sorted(data) == sorted({
|
||||
'use_key_identifier': True,
|
||||
'use_authority_cert': True
|
||||
}
|
||||
})
|
||||
assert not errors
|
||||
|
||||
data, errors = AuthorityKeyIdentifierSchema().dumps(data)
|
||||
assert data == json.dumps(input_data)
|
||||
assert sorted(data) == sorted(json.dumps(input_data))
|
||||
assert not errors
|
||||
|
||||
|
||||
|
@ -364,6 +364,11 @@ def test_certificate_get(client, token, status):
|
|||
assert client.get(api.url_for(Certificates, certificate_id=1), headers=token).status_code == status
|
||||
|
||||
|
||||
def test_certificate_get_body(client):
|
||||
response_body = client.get(api.url_for(Certificates, certificate_id=1), headers=VALID_USER_HEADER_TOKEN).json
|
||||
assert response_body['serial'] == "3E9"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("token,status", [
|
||||
(VALID_USER_HEADER_TOKEN, 405),
|
||||
(VALID_ADMIN_HEADER_TOKEN, 405),
|
||||
|
|
Loading…
Reference in New Issue