fix(certificate-authority): Optional+Computed audit — properties diff suppression, config-constraint validation, null-safe auth-cert metadata#186
Open
spbsoluble wants to merge 4 commits into
Conversation
…mented config constraints properties is Optional+Computed with a bare UseStateForUnknown plan modifier; when Command re-serializes the stored JSON with different key order or whitespace than what's declared in config, the plan showed a permanent diff (and Update kept resending the reformatted value) even though the value was semantically unchanged. Wires up the previously-dead normalizePropertiesJSON helper into a new plan modifier that keeps state when the two are semantically equal. Also enforces three config-time constraints that were previously only descriptive text in this resource's attribute docs, never actually checked: enforce_unique_dn and new_end_entity_on_renew_and_reissue are mutually exclusive; new_end_entity_on_renew_and_reissue must not be explicitly false for HTTPS CAs (ca_type=1); and allowed_enrollment_types/use_allowed_requesters/allowed_requesters are rejected when standalone is explicitly false. Undeclared or unknown values are never treated as violations, since plan-time validation can't resolve values that aren't known yet.
…en absent
caResponseToState only set auth_certificate_issued_dn/
auth_certificate_issuer_dn/auth_certificate_thumbprint inside the
"resp.AuthCertificate != nil" branch, so a CA with no auth certificate
configured left those three fields at the Go zero-value types.String{}
(a known empty string) instead of Null, unlike every other pointer field
in this function which already routes through a null-safe helper.
…ission explicit_password, auth_certificate, auth_certificate_password, and client_secret are Optional (not Computed) and, unlike this resource's other attributes, are not preserved when omitted from config: the full-replace update simply leaves them out of the request, which clears the stored credential server-side on the next apply. Documents this divergence from the resource's usual omit=unmanaged contract directly on each attribute.
…it fixes Adds entries for the properties JSON-normalization diff fix, the auth certificate metadata null-branch fix, and the new plan-time config constraint validation. Updates the "Known open gap" pending item to reflect that the two concrete residuals found in this pass are now fixed, rather than leaving the vague "unaudited" phrasing in place.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #184 (merge that first; this diff is only the last four commits). Findings come from an attribute-by-attribute Optional/Computed audit of
keyfactor_certificate_authority, the follow-up to the schedule-contract work in #182.Fixes
propertiesno longer shows a permanent diff when Command reformats stored JSON. Command's GET re-serializes the storedpropertiesblob (key order/whitespace), so a declared value could diff on every plan even though nothing changed. A new plan modifier keeps the prior state value when plan and state are semantically equal JSON; genuine value changes still surface.enforce_unique_dnandnew_end_entity_on_renew_and_reissuecannot both betruenew_end_entity_on_renew_and_reissue = falseis rejected for HTTPS CAs (ca_type = 1)allowed_enrollment_types,use_allowed_requesters, andallowed_requestersare rejected whenstandalone = falseNull/unknown values never error — only explicitly configured violations are rejected.
auth_certificate_issued_dn/auth_certificate_issuer_dn/auth_certificate_thumbprintpreviously landed in state as known empty strings.explicit_password,auth_certificate,auth_certificate_password, andclient_secretare not preserved when removed from config — the full-replace update omits them and Command clears the stored credential. The attribute descriptions now say so explicitly, since this intentionally differs from the omit=unmanaged contract the rest of the resource follows.Verification
UseStateForUnknownmodifier against the reordered-JSON scenario and asserts it does not suppress the diff (proving the new modifier is load-bearing).Audited but intentionally untouched
certificate_authorityset with neithercertificate_templatenorcertificate_enrollment_pattern) is rejected by the at-least-one-of validator despite the schema description promising it works. That is a behavior-changing fix on a different resource and needs its own design discussion/PR — deliberately not bundled here.