Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle missing certs model properties in 2016-10-01 #13129

Merged
merged 1 commit into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -450,21 +450,18 @@ def __repr__(self):
def _from_certificate_operation_bundle(cls, certificate_operation_bundle):
# type: (models.CertificateOperation) -> CertificateOperation
"""Construct a CertificateOperation from an autorest-generated CertificateOperation"""

issuer_parameters = certificate_operation_bundle.issuer_parameters
return cls(
cert_operation_id=certificate_operation_bundle.id,
issuer_name=(certificate_operation_bundle.issuer_parameters.name
if certificate_operation_bundle.issuer_parameters
else None),
issuer_name=issuer_parameters.name,
certificate_type=(
certificate_operation_bundle.issuer_parameters.certificate_type
if certificate_operation_bundle.issuer_parameters
else None
),
certificate_transparency=(
certificate_operation_bundle.issuer_parameters.certificate_transparency
if certificate_operation_bundle.issuer_parameters
else None
),
# 2016-10-01 IssuerParameters doesn't have certificate_transparency
certificate_transparency=getattr(issuer_parameters, "certificate_transparency", None),
csr=certificate_operation_bundle.csr,
cancellation_requested=certificate_operation_bundle.cancellation_requested,
status=certificate_operation_bundle.status,
Expand Down Expand Up @@ -667,7 +664,7 @@ def _to_certificate_policy_bundle(self):
issuer_parameters = models.IssuerParameters(
name=self.issuer_name,
certificate_type=self.certificate_type,
certificate_transparency=self.certificate_transparency,
certificate_transparency=self.certificate_transparency, # 2016-10-01 model will ignore this
)
else:
issuer_parameters = None
Expand Down Expand Up @@ -775,27 +772,23 @@ def _from_certificate_policy_bundle(cls, certificate_policy_bundle):
else:
key_usage = None
key_properties = certificate_policy_bundle.key_properties
curve_name = getattr(key_properties, "curve", None) # missing from 2016-10-01 KeyProperties
if curve_name:
curve_name = KeyCurveName(curve_name)

issuer_parameters = certificate_policy_bundle.issuer_parameters
return cls(
issuer_name=(certificate_policy_bundle.issuer_parameters.name
if certificate_policy_bundle.issuer_parameters else None
),
issuer_name=issuer_parameters.name,
subject=(x509_certificate_properties.subject if x509_certificate_properties else None),
certificate_type=(
certificate_policy_bundle.issuer_parameters.certificate_type
if certificate_policy_bundle.issuer_parameters
else None
),
certificate_transparency=(
certificate_policy_bundle.issuer_parameters.certificate_transparency
if certificate_policy_bundle.issuer_parameters
else None
),
certificate_type=issuer_parameters.certificate_type,
# 2016-10-01 IssuerParameters doesn't have certificate_transparency
certificate_transparency=getattr(issuer_parameters, "certificate_transparency", None),
lifetime_actions=lifetime_actions,
exportable=key_properties.exportable if key_properties else None,
key_type=KeyType(key_properties.key_type) if key_properties and key_properties.key_type else None,
key_size=key_properties.key_size if key_properties else None,
reuse_key=key_properties.reuse_key if key_properties else None,
key_curve_name=KeyCurveName(key_properties.curve) if key_properties and key_properties.curve else None,
key_curve_name=curve_name,
enhanced_key_usage=x509_certificate_properties.ekus if x509_certificate_properties else None,
key_usage=key_usage,
content_type=(
Expand Down
Loading