Skip to content

[PM-38273] feat(admin-console): Add InjectOrganizationAttribute and OrganizationModelBinder#7659

Merged
JaredScar merged 8 commits into
mainfrom
ac/pm-33919-inject-organization-attribute
May 28, 2026
Merged

[PM-38273] feat(admin-console): Add InjectOrganizationAttribute and OrganizationModelBinder#7659
JaredScar merged 8 commits into
mainfrom
ac/pm-33919-inject-organization-attribute

Conversation

@JaredScar
Copy link
Copy Markdown
Contributor

@JaredScar JaredScar commented May 18, 2026

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-38273

📔 Objective

This PR contains the implementation of InjectOrganizationAttribute (renamed to Bind because of conflicting Billing one) needed for #7527, split to their own PR to manage PR size.

…ModelBinder for automatic organization parameter binding
@JaredScar JaredScar requested a review from a team as a code owner May 18, 2026 16:02
@JaredScar JaredScar added the ai-review Request a Claude code review label May 18, 2026
@JaredScar JaredScar requested a review from jrmccannon May 18, 2026 16:02
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

This PR introduces BindOrganizationAttribute and OrganizationModelBinder to bind an Organization parameter directly from the orgId/organizationId route value. The pattern mirrors the established InjectOrganizationUserAttribute/OrganizationUserModelBinder in the same directory, including reuse of HttpContext.GetOrganizationId(). The first consumer (GetResetPasswordDetails on OrganizationUsersController) drops a redundant repository call and uses the bound organization instead. Unit tests for the binder, integration tests for the endpoint, and updates to the controller's existing unit tests are all included.

Code Review Details

No findings at this time. Prior review threads (signature mismatch breaking controller tests, missing binder unit tests, naming overlap with Billing.Attributes.InjectOrganizationAttribute) have all been resolved on the current head.

@JaredScar JaredScar changed the title [PM-33919] feat(admin-console): Add InjectOrganizationAttribute and OrganizationModelBinder [PM-33951] feat(admin-console): Add InjectOrganizationAttribute and OrganizationModelBinder May 18, 2026
Comment thread src/Api/AdminConsole/Attributes/BindOrganizationAttribute.cs
Comment thread src/Api/AdminConsole/Attributes/InjectOrganizationAttribute.cs Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.59%. Comparing base (7180015) to head (c2011b6).
⚠️ Report is 33 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7659      +/-   ##
==========================================
+ Coverage   60.43%   60.59%   +0.15%     
==========================================
  Files        2140     2147       +7     
  Lines       94622    95086     +464     
  Branches     8443     8507      +64     
==========================================
+ Hits        57188    57613     +425     
- Misses      35429    35449      +20     
- Partials     2005     2024      +19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@jrmccannon jrmccannon left a comment

Choose a reason for hiding this comment

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

We should add unit tests to this and apply it to a simple endpoint.

…tionModelBinder for organization parameter binding with unit tests
@JaredScar JaredScar requested a review from jrmccannon May 19, 2026 20:04
Comment thread src/Api/AdminConsole/Controllers/OrganizationUsersController.cs Outdated
Comment thread src/Api/AdminConsole/Attributes/BindOrganizationAttribute.cs
@JaredScar JaredScar requested a review from jrmccannon May 20, 2026 19:09
Comment thread src/Api/AdminConsole/Controllers/OrganizationUsersController.cs
JaredScar and others added 3 commits May 21, 2026 12:04
…n GetResetPasswordDetails method

- Updated test cases to pass the organization directly instead of relying on repository calls.
- Ensured that the tests correctly assert NotFoundException when the organization user does not match the bound organization.
- Improved clarity in test setup by explicitly binding the organization to the method calls.
jrmccannon
jrmccannon previously approved these changes May 26, 2026
@JaredScar JaredScar changed the title [PM-33951] feat(admin-console): Add InjectOrganizationAttribute and OrganizationModelBinder [PM-38273] feat(admin-console): Add InjectOrganizationAttribute and OrganizationModelBinder May 28, 2026
…ion functionality

- Introduced OrganizationUsersControllerBindOrganizationTests to validate the behavior of the GET reset-password-details endpoint.
- Implemented tests for successful retrieval of reset password details, handling of non-existent organization users, and cases where the user belongs to a different organization.
- Ensured comprehensive coverage of scenarios to verify correct status responses and organization binding logic.
@sonarqubecloud
Copy link
Copy Markdown

@JaredScar JaredScar merged commit 970cacd into main May 28, 2026
41 checks passed
@JaredScar JaredScar deleted the ac/pm-33919-inject-organization-attribute branch May 28, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants