Skip to content

feat(ra): make identityCsrPEM optional on agent registration - #33

Merged
jhateley-godaddy merged 4 commits into
mainfrom
feat/optional-identity-csr
Jun 3, 2026
Merged

jhateley-godaddy merged 4 commits into
mainfrom
feat/optional-identity-csr

Conversation

@jhateley-godaddy

Copy link
Copy Markdown
Contributor

Agents may now register without an identity CSR on both the V1 and V2 lanes. When identityCsrPEM is supplied, behavior is unchanged: the RA issues an identity certificate from it at verify-acme. When omitted, the agent registers with no identity certificate, drives through the lifecycle to ACTIVE normally, and emits TL events carrying empty identity certs.

  • domain: NewRegistration accepts a nil identity CSR.
  • service: RegisterAgent skips CSR validation/persistence when omitted; VerifyACME treats a missing pending identity CSR as a no-op rather than an inconsistent-state error.
  • no-add-later guard: an ACTIVE agent that registered without an identity CSR cannot obtain one via SubmitIdentityCSR (409 IDENTITY_CSR_NOT_PERMITTED); it must register a new version instead.
  • spec: identityCsrPEM removed from the required list; docsui regenerated.

Tests follow the repo convention (unit-under-test + concern):

  • domain/agent_test.go pins nil-CSR acceptance.
  • service: RegisterAgent cases in registration_errors_test.go; new lifecycle_test.go covers VerifyACME/VerifyDNS V1+V2 wire shapes and the SubmitIdentityCSR guard.
  • handler: V2 202 + V1 reaches-ACTIVE parity, plus the 409 add-later path. Replaces the stale TestV1Register_MissingIdentityCSR_422.

Copilot AI review requested due to automatic review settings June 3, 2026 02:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables agents to register without providing an identityCsrPEM (V1 and V2 lanes), while keeping prior behavior unchanged when an identity CSR is supplied. This allows agents to progress through PENDING_VALIDATION → PENDING_DNS → ACTIVE without an identity certificate, and adds a guard to prevent adding an identity CSR later for agents that registered without one.

Changes:

  • Spec/docs: identityCsrPEM is no longer required and is documented as optional (with “no add later” semantics).
  • Domain/service: registration accepts nil identity CSR; registration persists/validates identity CSR only when provided; VerifyACME treats missing pending identity CSR as a no-op.
  • Lifecycle/tests: adds “no-add-later” conflict on SubmitIdentityCSR for ACTIVE agents that have no identity certs; adds/updates unit + handler tests for V1/V2 parity and event shapes.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
spec/api-spec-v2.yaml Makes identityCsrPEM optional in the V2 OpenAPI spec and documents semantics.
internal/adapter/docsui/openapi/ra.yaml Regenerates docs UI OpenAPI to match the updated optional field.
internal/domain/agent.go Removes domain-level validation requiring a non-nil identity CSR at registration.
internal/domain/agent_test.go Adds test coverage for nil identity CSR registration; removes “missing CSR” validation case.
internal/ra/service/registration.go Skips identity CSR validation/persistence when omitted; passes nil CSR into NewRegistration.
internal/ra/service/registration_errors_test.go Adds tests for register-without-identity-CSR and regression for supplied-CSR path.
internal/ra/service/lifecycle.go Adds no-add-later guard in SubmitIdentityCSR; makes VerifyACME tolerate missing pending identity CSR.
internal/ra/service/lifecycle_test.go New tests for lifecycle progression and V1/V2 event shapes when identity CSR is omitted.
internal/ra/handler/v1registration_test.go Updates V1 handler test to expect success (202) without identity CSR and to reach ACTIVE.
internal/ra/handler/lifecycle_test.go Adds V2 handler coverage for registration without identity CSR and the 409 “no add later” path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/ra/service/lifecycle.go Resolved
Comment thread internal/ra/service/lifecycle_test.go Resolved
Comment thread internal/ra/service/lifecycle_test.go Resolved
Agents may now register without an identity CSR on both the V1 and V2
lanes. When identityCsrPEM is supplied, behavior is unchanged: the RA
issues an identity certificate from it at verify-acme. When omitted, the
agent registers with no identity certificate, drives through the
lifecycle to ACTIVE normally, and emits TL events carrying empty identity
certs.

- domain: NewRegistration accepts a nil identity CSR.
- service: RegisterAgent skips CSR validation/persistence when omitted;
  VerifyACME treats a missing pending identity CSR as a no-op rather than
  an inconsistent-state error.
- no-add-later guard: an ACTIVE agent that registered without an identity
  CSR cannot obtain one via SubmitIdentityCSR (409 IDENTITY_CSR_NOT_PERMITTED);
  it must register a new version instead.
- spec: identityCsrPEM removed from the required list; docsui regenerated.

Tests follow the repo convention (unit-under-test + concern):
- domain/agent_test.go pins nil-CSR acceptance.
- service: RegisterAgent cases in registration_errors_test.go; new
  lifecycle_test.go covers VerifyACME/VerifyDNS V1+V2 wire shapes and the
  SubmitIdentityCSR guard.
- handler: V2 202 + V1 reaches-ACTIVE parity, plus the 409 add-later path.
  Replaces the stale TestV1Register_MissingIdentityCSR_422.

Signed-off-by: James Hateley <jhateley@godaddy.com>
@jhateley-godaddy
jhateley-godaddy force-pushed the feat/optional-identity-csr branch from a3fe582 to 2a57287 Compare June 3, 2026 02:32
Flatten SubmitIdentityCSR with an early-return AGENT_NOT_ACTIVE guard,
removing the now-redundant nested status check.

Reword the no-identity-CSR event tests: identityCert/identityCerts/
validIdentityCerts are all omitempty, so the fields are absent on the
wire when empty rather than serialized as null/empty arrays. Comments
and failure messages no longer assert a wire shape the encoder cannot
produce.

Signed-off-by: James Hateley <jhateley@godaddy.com>
Remove AC-* acceptance-criteria identifiers and plan-relative framing
("RED gauge", "the optional-identity-CSR feature", "as before the
optional path was introduced") from test comments. These pointed at an
implementation plan rather than describing behavior; reword them to
state what each test verifies in product terms.

Signed-off-by: James Hateley <jhateley@godaddy.com>
@jhateley-godaddy
jhateley-godaddy added this pull request to the merge queue Jun 3, 2026
Merged via the queue into main with commit f4e0619 Jun 3, 2026
2 checks passed
@jhateley-godaddy
jhateley-godaddy deleted the feat/optional-identity-csr branch June 3, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants