Skip to content

WIP - Migrate organization and user flows to BaseOrg/BaseUser - #1982

Open
jdalphond-mitre wants to merge 20 commits into
2.9.0-releasefrom
jd_1942_1943
Open

WIP - Migrate organization and user flows to BaseOrg/BaseUser#1982
jdalphond-mitre wants to merge 20 commits into
2.9.0-releasefrom
jd_1942_1943

Conversation

@jdalphond-mitre

@jdalphond-mitre jdalphond-mitre commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

#1942
#1943
Migrates CVE, CVE-ID, organization, and user flows away from legacy repository dual-writes while preserving legacy-format compatibility where required.

Important Changes

src/repositories/baseOrgRepository.js / src/repositories/baseUserRepository.js

  • Moved organization and user reads, writes, authorization, and audit lookups to BaseOrg/BaseUser.
  • Removed legacy user dual-write behavior and retired repository factory support.

src/utils/orgCompatibility.js / src/utils/userCompatibility.js

  • Added compatibility projections for legacy organization and user API responses.

src/controller/

  • Updated CVE, CVE-ID, organization, registry, and user controllers to use the consolidated repositories.

src/repositories/userRepository.js / src/scripts/migrate.js

  • Removed retired legacy repository and migration implementations.

test/

  • Updated affected unit and integration tests.
  • Added compatibility and legacy user-write contract coverage.
  • Reorganized organization tests into legacy and registry groups.

Testing

  • 1) Run bash -i -c "npm run test:integration".
  • 2) Verify legacy and registry organization/user endpoints preserve expected response formats.
  • 3) Verify CVE-ID reservation and CVE update flows succeed for CNA and ADP users.

… out legacy and registry tests to more easily tell which files are which.
…bsolete OrgRepository factory getter and legacy test mocks.
Update legacy user-capacity setup to use BaseOrg membership rather than
legacy User records. Add coverage that verifies legacy user create, update,
read, and reset-secret responses remain compatible while BaseUser and
BaseOrg remain the sources of truth.
Project legacy user reads and write responses directly from BaseUser and
BaseOrg membership/admin data, eliminating UserRepository and RegistryUser
usage from BaseUserRepository create, update, full update, reset-secret,
delete, lookup, and authorization paths.

Normalize legacy dotted user fields during creation and re-read the owning
BaseOrg before projecting legacy responses so names and ADMIN roles match the
persisted BaseUser/BaseOrg state. Avoid logging one-time user secrets in org
creation audit records.

Release BaseOrg reservation locks before sending post-lock CVE-ID responses,
while retaining finally cleanup for exceptions, so an immediately-following
reservation is not incorrectly rejected as in progress.

Update unit and integration tests for BaseUser-only behavior, legacy write
compatibility, and clearer reservation response assertions.
Registry full user updates preserve ADMIN membership when the user remains
in the same organization. When org_short_name changes, the user is removed
from the source admins list and receives destination membership only.

Extend integration coverage for both same-org updates and organization moves.
Use BaseUserRepository when CVE and CVE-ID controllers resolve the
authenticated requester UUID for audit metadata, removing their remaining
UserRepository factory dependency.

Update affected CVE/CVE-ID unit-test factories to provide BaseUserRepository
and update registry user-move coverage to require destination membership
without destination ADMIN access.
Make BaseOrg the sole source of ADMIN membership by removing the legacy
User collection updates from addAdmin() and removeAdmin(). Legacy user
responses continue to derive active_roles from BaseOrg membership through
the compatibility projection.

Expand admin-role integration coverage to verify that:
- legacy grants remain visible through registry reads,
- registry revokes remain visible through both API formats, and
- registry grants remain visible through legacy reads.
Remove the legacy UserRepository factory import and getter now that all
production callers use BaseUserRepository.

Delete the retired UserRepository implementation and its unit coverage.
Update remaining middleware, user-update, and reservation test helpers to
use BaseOrgRepository and BaseUserRepository exclusively.
Seed canonical BaseOrg/BaseUser fixtures directly, including memberships, admin references, discriminator types, and quotas.

Remove the legacy Org/User migration script and obsolete test setup references.

Update population helpers and affected tests to use Base repositories only.

Retain Monday migration support for existing BaseOrg/BaseUser data.

@david-rocca david-rocca left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The factory no longer exposes the legacy repositories, but these artifacts remain:

@david-rocca

Copy link
Copy Markdown
Collaborator

In addition, we need to fix the lint issues.

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.

2 participants