Skip to content

Add AD group management to authorization workflow#1619

Open
kin0992 wants to merge 4 commits intomainfrom
feats/add-ad-groups-authorization-json
Open

Add AD group management to authorization workflow#1619
kin0992 wants to merge 4 commits intomainfrom
feats/add-ad-groups-authorization-json

Conversation

@kin0992
Copy link
Copy Markdown
Contributor

@kin0992 kin0992 commented Apr 13, 2026

This PR implements AD group management in the CLI init (authorization) workflow, re-implementing #1400 on top of the JSON format introduced by #1541.

When the CLI creates a PR in eng-azure-authorization to add a bootstrap identity, it now also ensures all 8 default AD groups are present in the subscription's terraform.tfvars.json.

Default AD groups

<prefix>-<envShort>-adgroup-{admin,developers,operations,security,technical-project-managers,product-owners,externals,oncall}

Closes CES-1658

@kin0992 kin0992 changed the title feat(cli): add AD group management to authorization workflow Add AD group management to authorization workflow Apr 13, 2026
@kin0992 kin0992 force-pushed the feats/add-ad-groups-authorization-json branch 3 times, most recently from 1569a09 to 215b5ab Compare April 15, 2026 10:02
@kin0992 kin0992 marked this pull request as ready for review April 15, 2026 15:36
@kin0992 kin0992 requested a review from a team as a code owner April 15, 2026 15:36
Copilot AI review requested due to automatic review settings April 15, 2026 15:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds AD group management to the CLI authorization (init) workflow so that, when creating/updating subscription authorization config, the 8 default AD groups are ensured in terraform.tfvars.json alongside the bootstrap identity.

Changes:

  • Extend RequestAuthorizationInput with prefix and envShort, and generate default AD group names/specs.
  • Update the PagoPA authorization adapter to upsert default AD groups (add missing, fix roles, preserve members/custom groups) and support no-op results (no PR created).
  • Update CLI output + tests to account for optional PR URLs and new group upsert behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
apps/cli/src/domain/authorization.ts Adds input fields (prefix, envShort), default AD group specs, and makes AuthorizationResult.url optional for no-op runs.
apps/cli/src/adapters/pagopa-technology/authorization.ts Implements parsing + identity ensure + AD group upsert, and short-circuits PR creation on no-op.
apps/cli/src/adapters/pagopa-technology/tests/authorization.test.ts Adds extensive test coverage for group upsert scenarios and no-op behavior.
apps/cli/src/use-cases/tests/request-authorization.test.ts Updates tests to reflect removal of IdentityAlreadyExistsError.
apps/cli/src/adapters/commander/commands/add.ts Filters out no-op authorization results when printing “Next Steps”.
apps/cli/src/adapters/commander/commands/tests/add.test.ts Updates tests for new prefix/envShort input and no-op handling.
.nx/version-plans/version-plan-17760680773N.md Declares a patch version bump for @pagopa/dx-cli.

Comment thread apps/cli/src/adapters/pagopa-technology/authorization.ts Outdated
Comment thread apps/cli/src/adapters/pagopa-technology/authorization.ts
Comment thread apps/cli/src/adapters/pagopa-technology/authorization.ts Outdated
Comment thread apps/cli/src/domain/authorization.ts
Comment thread apps/cli/src/adapters/commander/commands/__tests__/add.test.ts Outdated
Comment thread apps/cli/src/adapters/commander/commands/__tests__/add.test.ts
Comment thread apps/cli/src/adapters/pagopa-technology/authorization.ts Outdated
Comment thread apps/cli/src/adapters/pagopa-technology/authorization.ts Outdated
Comment thread apps/cli/src/adapters/pagopa-technology/authorization.ts Outdated
@kin0992 kin0992 force-pushed the feats/add-ad-groups-authorization-json branch 4 times, most recently from ae94a18 to f332589 Compare April 24, 2026 10:03
kin0992 and others added 4 commits April 27, 2026 09:56
When creating a PR for bootstrap identity, the CLI now also ensures
all default AD groups are present in the subscription's
terraform.tfvars.json. Groups are added if missing, roles are updated
if they differ from the defaults (preserving members), and custom
groups are left untouched.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rework the authorization adapter to avoid leaving dangling branches
on no-op runs by reading from main before creating a branch.

Also apply the following review suggestions:
- Make inner groups zod schema loose to preserve unknown keys
- Preserve existing group order in upsertGroups, appending missing
  defaults at the end instead of rebuilding in a fixed order
- Tailor commit/PR title and body to the actual change kind
  (identity-only, groups-only, or both)
- Rename mismatched test title in add.test.ts
- Add tests for identity-only messaging, groups-only messaging,
  group order preservation, and extra-field round-trip safety

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kin0992 kin0992 force-pushed the feats/add-ad-groups-authorization-json branch from f332589 to b0f8be2 Compare April 27, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants