* implementation plan
* feedback updates
* revert updates
* implementation plan
* feedback updates
* revert updates
* implement plan
* Revert "Merge branch '2fa-account-recovery' of github.com:bitwarden/server into 2fa-account-recovery"
This reverts commit 3be2d140f1, reversing
changes made to 9fb8d3891c.
* PR feedback
* revert claude local settings
* lint fixes
* fix test models
* move new commands to v2 namespace.
* format
* fix swagger stuff
* update feature flag name
* fix(billing): replace per-change IsStructural with changeset-level ChargeImmediately flag
* fix(billing): set seat quantity when upgrading from non-seat-based to seat-based plan
* Send better error message when token is expired
* Add comment indicating frontend usage
* Add testcase for Invalid Token scenario
* Update comment in test-case
* Fix merge issue
* Fix method name
* Consolidate token validation error calculation, apply to new area
* Move away from magic strings, fix tests
* Adjust class name
* Clean up old method name references
* Change errors to fields for singleton behavior
* Formatting
This was being used to combine policies before sending them
to the client. Instead, the server just send the policies and
the client should process/combine them. Revert this to save
unnecessary QA (etc) and we will refactor this away in the
future.
* Add more efficient sproc to retrieve PolicyDetails
for a single user. This closely matches the existing sproc
used by PolicyService and should be performant enough
to be used in the login flow
* Maintain feature flag for this critical path
* feat(emergency-access): [PM-29585] Prevent New EA Invitations or Acceptance - Initial implementation
* fix(emergency-access): [PM-29585] Prevent New EA Invitations or Acceptance - Changes in a good place. Need to write tests.
* test(emergency-access): [PM-29585] Prevent New EA Invitations or Acceptance - Service tests have been added.
* fix(emergency-access): [PM-29585] Prevent New EA Invitations or Acceptance - Fixed comment.
* chore: add CLAUDE.local.md and .worktrees to gitignore
* feat(billing): add Stripe interval and payment behavior constants and feature flag
* feat(billing): add OrganizationSubscriptionChangeSet model and unit tests
* refactor(billing): rename UpdateOrganizationSubscriptionCommand to BulkUpdateOrganizationSubscriptionsCommand
* feat(billing): add UpdateOrganizationSubscriptionCommand with tests
* feat(billing): use UpdateOrganizationSubscriptionCommand in BulkUpdateOrganizationSubscriptions behind feature flag
* feat(billing): use UpdateOrganizationSubscriptionCommand in SetUpSponsorshipCommand behind feature flag
* feat(billing): add UpgradeOrganizationPlanVNextCommand with tests and feature flag gate
* feat(billing): use UpdateOrganizationSubscriptionCommand in OrganizationService.AdjustSeatsAsync behind feature flag
* feat(billing): use UpdateOrganizationSubscriptionCommand in UpdateSecretsManagerSubscriptionCommand behind feature flag
* feat(billing): use UpdateOrganizationSubscriptionCommand in BillingHelpers.AdjustStorageAsync behind feature flag
* chore: run dotnet format
* fix(billing): missed optional owner in OrganizationBillingService.Finalize after merge
* refactor(billing): address PR feedback on UpdateOrganizationSubscription
* Added new methods and ff for single org req
* Changed req messages and added new method for creating orgs
* Updated Requirement and Tests.
* Updated commands and requirement to take a list of org users
* Updated xml docs and renamed to be consistent
* Changes from Code Review
* Removed feature flag check for policy requirements around single org. Aligned error message with what other commands were returning.
* Fixed test names. Updated error messages to be specific for each caller.
* Updated tests to clean up details consturction
* Added test for confirmed accepted user in another org.
* fixed tests to use new factory
* Update test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/RestoreUser/RestoreOrganizationUserCommandTests.cs
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
* Fixed tests by adding no op for req.
---------
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
* Remove emergency access from all organization users on policy enable, or when accepted/restored
* Use correct policy save system
* Add additional tests
* Implement both PreUpsert and OnSave side effects
The IApplicationCacheService implementation is defective and
does not synchronise between instances. Switch to using
the repository directly to ensure that the organization is always
available. This will be reverted when the cache is fixed.
---------
Co-authored-by: Jared McCannon <jmccannon@bitwarden.com>
* Add integration tests for AcceptInit endpoint in OrganizationUsersController
* Add new feature flag for organization acceptance initialization refactor
* Add InitPendingOrganizationVNextAsync for consolidated organization initialization
Introduces a new method that consolidates organization initialization,
user confirmation, email verification, and collection creation into a
single operation with upfront validation.
Key improvements:
- All validation performed before any state changes
- Returns typed errors via CommandResult instead of throwing exceptions
- Reduces three separate command calls into one unified flow
- Maintains backward compatibility via feature flag
The existing InitPendingOrganizationAsync is marked obsolete and will be
removed after feature flag rollout completes.
* Add unit tests for InitPendingOrganizationVNextAsync method
Introduces comprehensive unit tests for the InitPendingOrganizationVNextAsync method, covering various scenarios including valid data initialization, error handling for invalid tokens, organization status checks, and user confirmation requirements.
Key additions:
- Tests for successful organization initialization and user confirmation.
- Error handling tests for invalid tokens, already enabled organizations, and mismatched organization IDs.
- Validation for existing keys and email mismatches.
- Support for creating default collections during initialization.
These tests enhance the reliability and robustness of the organization initialization process.
* Refactor AcceptInit method to support feature flag for organization initialization
Updated the AcceptInit method in OrganizationUsersController to return an IResult type and handle organization initialization based on a feature flag. If the feature is enabled, it utilizes the new InitPendingOrganizationVNextAsync method for atomic organization setup and user confirmation. Integration tests were added to verify the behavior under both feature flag states, ensuring proper initialization and error handling.
* Enhance InitPendingOrganizationCommand with policy validation and feature flag support
Updated the ValidatePoliciesAsync method to enforce the Automatic User Confirmation Policy when the feature flag is enabled. Added new unit tests to cover scenarios for automatic user confirmation and single organization policy violations, ensuring comprehensive validation during organization initialization. This improves error handling and maintains compliance with organizational policies.
* Add InitializePendingOrganizationAsync method for atomic organization initialization
Implemented the InitializePendingOrganizationAsync method in both Dapper and Entity Framework repositories to streamline the initialization of pending organizations. This method enables the organization, confirms the first owner, updates user details, and optionally creates a default collection, all within a single atomic transaction. Enhanced error handling ensures robustness during the initialization process.
* Add unit tests for InitializePendingOrganizationAsync method
Introduced several unit tests for the InitializePendingOrganizationAsync method, covering scenarios such as successful organization initialization with and without collections, exception handling for invalid organization IDs, and rollback behavior on errors. These tests enhance the reliability of the organization initialization process and ensure proper handling of various edge cases.
* Refactor InitPendingOrganizationCommand to use consolidated InitializePendingOrganizationAsync method
Replaced multiple asynchronous calls for organization initialization with a single call to the new InitializePendingOrganizationAsync method. This change streamlines the process by encapsulating organization setup, user confirmation, and collection creation into one atomic operation, enhancing maintainability and reducing complexity in the command logic.
* Enhance InitPendingOrganizationCommandTests with new test cases and refactor existing ones
Added a new test case for InitPendingOrganizationVNextAsync to validate organization initialization with a collection name. Refactored existing tests to improve clarity and maintainability, including the removal of redundant assertions and the consolidation of organization setup logic. This update strengthens the test coverage for the organization initialization process and ensures proper handling of various scenarios.
* Refactor IOrganizationRepository and OrganizationRepository to remove nullable collectionName parameter
Updated the IOrganizationRepository and OrganizationRepository interfaces to change the collectionName parameter from nullable to non-nullable. This change enforces stricter parameter requirements and improves data integrity during organization initialization processes.
* Improve error handling in OrganizationRepository by logging exceptions during transaction rollback
Updated the OrganizationRepository in both Dapper and Entity Framework implementations to log detailed error messages when exceptions occur during the initialization of pending organizations. This enhancement improves traceability and debugging capabilities by providing context on failures, ensuring better maintainability of the organization initialization process.
* Refactor OrganizationRepository to consolidate SaveChangesAsync calls
Updated the OrganizationRepository to reduce multiple SaveChangesAsync calls into a single call at the end of the transaction. This change enhances performance and ensures that all changes are committed atomically, improving the overall maintainability of the organization initialization process.
* refactor: Introduce InitPendingOrganizationRequest model and update InitPendingOrganizationVNextAsync method
- Created InitPendingOrganizationRequest to encapsulate parameters for initializing a pending organization.
- Refactored InitPendingOrganizationVNextAsync method to accept the new request model instead of multiple parameters.
- Updated OrganizationUsersController to use the new request model for improved readability and maintainability.
- Adjusted related tests to accommodate the new request structure.
* Create database update action delegate for organization initialization.
* Add BuildVerifyUserEmailAction method to IUserRepository and implementations in UserRepository classes
- Introduced a new method in IUserRepository to create an action for verifying user emails.
- Implemented the method in both Dapper and Entity Framework UserRepository classes to update the email verification status of users.
- Ensured that the method checks if the user's email is already verified before updating.
* Add BuildCreateDefaultCollectionAction method to ICollectionRepository and implementations in CollectionRepository classes
- Introduced a new method in ICollectionRepository to build an action for creating a default collection with user access.
- Implemented the method in both Dapper and Entity Framework CollectionRepository classes to handle collection creation and user access assignments.
- Enhanced the functionality to support transaction execution for database operations.
* Add BuildConfirmOrganizationUserAction method to IOrganizationUserRepository and implementations in OrganizationUserRepository classes
- Introduced a new method in IOrganizationUserRepository to build an action for confirming an organization user.
- Implemented the method in both Dapper and Entity Framework OrganizationUserRepository classes to handle user confirmation and status updates.
- Enhanced the functionality to support transaction execution for database operations.
* Refactor organization initialization methods in IOrganizationRepository and implementations
- Introduced BuildUpdateOrganizationAction method to create an action for updating organization properties during initialization.
- Replaced the InitializePendingOrganizationAsync method with ExecuteOrganizationInitializationUpdatesAsync to handle multiple update actions in a single transaction.
- Updated Dapper and Entity Framework implementations to support the new action-based approach for organization initialization, enhancing transaction management and code clarity.
* Add integration tests for ExecuteOrganizationInitializationUpdatesAsync
* Refactor InitPendingOrganizationCommand to streamline organization initialization process
- Introduced methods for preparing organization and organization user for initialization.
- Replaced direct calls to repository methods with a new action-based approach for executing multiple database updates in a single transaction.
- Enhanced test cases to validate the new initialization logic and ensure proper handling of organization states.
* Refactor organization user acceptance tests to utilize feature flags
- Converted existing tests to use [Theory] with [InlineData] for feature flag variations.
- Updated assertions to reflect expected status codes based on feature flag state.
- Enhanced user confirmation checks to ensure proper linking and email verification after acceptance.
- Improved test coverage for organization initialization scenarios with and without collections.
* Refactor BuildVerifyUserEmailAction to accept User entity instead of user ID
- Updated IUserRepository and its implementations to change the parameter of BuildVerifyUserEmailAction from Guid userId to User user.
- Modified related repository methods in Dapper and Entity Framework to utilize the User entity for email verification.
- Adjusted tests to reflect the new method signature, ensuring proper functionality and integration with the updated user verification process.
* Revert "Refactor BuildVerifyUserEmailAction to accept User entity instead of user ID"
This reverts commit 71047bee2a.
* Enhance InitPendingOrganizationCommand for null safety and error handling
- Removed nullable disable directive to enable null safety checks.
- Added a null check for the organization retrieval, throwing a BadRequestException if not found.
- Updated validation methods to return nullable Error types, improving error handling in the organization initialization process.
* Add remarks to IInitPendingOrganizationCommand for clarity on organization initialization
- Enhanced the documentation for the InitPendingOrganizationCommand interface by adding remarks to clarify the role of the user initializing the organization.
- Explained the default state assumptions during validation, emphasizing that no policies are enforced at this stage.
* Implement InitPendingOrganizationValidator for improved organization initialization validation
- Introduced IInitPendingOrganizationValidator interface and its implementation to encapsulate validation logic for organization initialization.
- Refactored InitPendingOrganizationCommand to utilize the new validator for token validation, user email matching, organization state checks, and policy enforcement.
- Enhanced dependency injection in OrganizationServiceCollectionExtensions to include the new validator.
- Added comprehensive unit tests for the validator to ensure robust validation logic and error handling.
* Update documentation in IInitPendingOrganizationCommand to clarify organization initialization process
- Revised the summary comment to specify that the method initializes a pending organization created via the Bitwarden Portal on behalf of a Reseller.
- Added a reference to the ResellerClientOrganizationSignUpCommand for better context.
- Emphasized the confirmation of the first owner during the initialization process.
* Update InitPendingOrganizationRequest to allow optional collection name
- Modified the CollectionName property to be nullable, allowing for no collection to be created if the value is null or empty.
- Enhanced documentation to clarify the optional nature of the CollectionName parameter.
* Fix nullability issue in InitPendingOrganizationCommand by enforcing non-null collection name assignment
* Refactor organization key handling in InitPendingOrganization features. Updated OrganizationUsersController to use new key pair data structure. Adjusted InitPendingOrganizationCommand and InitPendingOrganizationRequest to reflect changes in key management.
* Update organization key handling to use the name EncryptedOrganizationSymmetricKey. Refactor OrganizationUsersController, InitPendingOrganizationCommand, and InitPendingOrganizationRequest for consistency in key management.
* Refactor InitPendingOrganizationCommand to utilize TimeProvider for date handling. Updated methods to replace direct DateTime calls with _timeProvider.GetUtcNow().
* Refactor InitPendingOrganization validation methods to rename ValidateBusinessRulesAsync to ValidateFreeOrganizationLimitAsync for clarity and consistency. Updated related command and test files accordingly.
* Refactor InitPendingOrganizationCommand and related classes to streamline validation logic. Introduced InitPendingOrganizationValidationRequest for enriched validation context and updated methods to improve clarity and consistency in error handling. Adjusted tests to reflect changes in validation flow.
* Remove unused dependencies from InitPendingOrganizationCommand
* Refactor InitPendingOrganizationCommand to streamline organization initialization process. Replaced multiple update actions with a single atomic operation for organization and owner confirmation. Updated related repository interfaces and methods for improved clarity and consistency in transaction handling.
* Remove commented-out regions and clean up whitespace in InitPendingOrganizationCommandTests for improved readability.
* Remove unnecessary null check for organization in InitPendingOrganizationCommand
* Revert "Remove unnecessary null check for organization in InitPendingOrganizationCommand"
This reverts commit 1ad7148fc9.
* Refactor organization initialization actions to use DbConnection and DbTransaction instead of SqlConnection and SqlTransaction. Update related interfaces and implementations across repositories for improved database transaction handling.
* Refactor organization and organization user update logic to use null checks for entity existence. Throw exceptions for not found entities to improve error handling during initialization.
* Update InitPendingOrganizationCommandTests to use SendConfirmationAsync for email notifications and added missing using directive for OrganizationConfirmation.
* Remove unnecessary blank lines from CollectionRepository and UserRepository classes for improved code readability.
* Remove redundant test cases from OrganizationUsersControllerAcceptInitTests
* Enhance InitPendingOrganizationCommandTests to validate organization and user properties in repository interactions
* Update RefactorOrgAcceptInit feature flag key to new identifier pm-33082-refactor-org-accept-init
* Remove usage of policy requirements retrieval by org
* Simplify result model
* Return early if no restored confirmed users exist to create default collections for
* fix merge conflict flog
* Fix test mocks
---------
Co-authored-by: bnagawiecki <107435978+bnagawiecki@users.noreply.github.com>
* Cleaning up code around feature flag. removing old implementation. will remove flag in subsequent pr.
* Remove unused feature flag
* Fixing test from merge
* Add validation for reset password key and account recovery enrollment in OrganizationUser
* Update admin approval logic to check account recovery enrollment and add tests for reset password key validation
* Enhance UserService validation to include account recovery enrollment and add unit test for empty or whitespace reset password key handling
* Refactor OrganizationUserUserDetailsQuery to validate reset password keys and add unit tests for filtering out invalid keys
* Update AdminRecoverAccountCommand to validate account recovery enrollment and adjust tests for whitespace reset password keys
* Enhance OrganizationUserRotationValidator to validate reset password keys, including filtering out whitespace-only keys, and add corresponding unit tests for validation logic.
* Refactor OrganizationUserUserDetailsQueryTests to remove unnecessary whitespace-only test cases for account recovery key validation.
* Refactor MemberResponseModel to use OrganizationUser's validation method for ResetPasswordEnrolled status and update corresponding unit test for clarity.
* Refactor OrganizationUsersController and response models to utilize OrganizationUser's validation method for ResetPasswordKey, ensuring consistent validation across the application. Add unit tests for OrganizationUser to verify key validation logic.
* Update OrganizationUserRotationValidator to handle null reset password keys and adjust tests for client-side bug. Add comments for future migration after resolving PM-31001.
* Fix whitespace issue in UserServiceTests.cs by removing BOM character from the file header.
* Adds new method for retrieving policy requirements for a collection of user IDs
* Use Single instead of First for explicit correctness
* Fix xmldoc
* Refactor return type to include user ID
* Add new feature flag for updating the join organization email templates
* Add new MJML email template for organization invite to existing users
* Add new MJML email template for organization invite to new users
* Add new MJML email template for organization invite to existing families
* Add new MJML email template for organization invite to families for new users
* Add new MJML email template for organization invite to free users
* Add OrganizationInviteBaseView model for organization invite email templates
* Add required properties for email title customization in OrganizationInviteBaseView
* Add new MJML email templates for organization invites to existing and new users, including families and free users.
* Enhance SendInvitesRequest to include optional InvitingUserId and update related methods in OrganizationService for improved user invitation tracking.
* Refactor organization invite email handling to support customized templates for existing and new users, incorporating inviting user information and enhancing the SendInvitesRequest structure.
* Refactor OrganizationInviteBaseView and SendOrganizationInvitesCommand to remove unnecessary properties, streamlining the organization invite email structure and focusing on essential information for user invitations.
* Refactor SendOrganizationInvitesCommand to improve email invitation logic by removing the OrganizationCategory enum and consolidating plan type checks. Introduce a new method for formatting expiration dates to enhance code clarity and maintainability.
* Update organization invite email templates to enhance styling
* Enhance SendOrganizationInvitesCommand to include additional plan types for organization invites, allowing support for TeamsStarter, TeamsStarter2023, and Custom plans in the invitation logic.
* Add tests for SendOrganizationInvitesCommand to validate email sending logic for various plan types, including Enterprise, Teams, Families, Free, and Custom plans, based on user existence and feature flags.
* Update organization invite email templates to improve styling and layout consistency across various user types, including adjustments to padding, font weights, and vertical alignment for a more polished appearance.
* Refactor organization invite email templates to improve styling consistency and layout across various user types, including adjustments to padding, font families, and visibility of icon rows for a more polished appearance.
* [PM-30610] Break shared components into AC versions
* Revert changes to shared MJML components
* Refactor organization invite email templates to use admin console MJML components
* Update organization invite email templates to utilize new admin console MJML components
* Enhance organization invite email templates by adding bullet point for mobile views
* Update organization invite email templates to improve layout and visibility of bullet points by changing display properties and adding inline text spans.
---------
Co-authored-by: Jimmy Vo <huynhmaivo82@gmail.com>
* [PM-28300] Remove BlockClaimedDomainAccountCreation feature flag checks
* Fix user registration tests by adding proper email domains
* Remove redundant feature flag checks from user registration tests
* Remove BlockClaimedDomainAccountCreation constant from FeatureFlagKeys
* Extracted policy compliance checking for the organization out and added a check when attempting to enable auto user confirm via Admin Portal
* Moved injection order. Fixed error message.
* [PM-31361] Enhance domain claimed email notifications
* Updated the email template to include the claimed domain name and user email.
* Modified the `ClaimedUserDomainClaimedEmails` model to include the domain name.
* Adjusted the `SendClaimedDomainUserEmailAsync` method to pass the domain name to the email message.
* Added a new test for rendering the domain claimed email to ensure proper content delivery.
* Update email templates for domain claimed notifications
* Adjusted styles and formatting in the DomainClaimedByOrganization email template for improved readability.
* Modified the TitleContactUs layout to ensure proper rendering of titles.
* Updated the HandlebarsMailService to include HTML line breaks in the email title for better presentation.
* Update TitleContactUs email template to center-align title text for improved presentation
* Refine TitleContactUs email template by removing unnecessary text-align property for improved consistency in styling
* Fix PR comments
* Update test/Core.Test/Platform/Mail/DomainClaimedEmailRenderTest.cs
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
* Update test/Core.Test/Platform/Mail/DomainClaimedEmailRenderTest.cs
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
* Update test/Core.Test/Platform/Mail/DomainClaimedEmailRenderTest.cs
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
* Remove unnecessary comments
---------
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
* Initial implementation of new policy query
* Remove unused using
* Adjusts method name to better match repository method
* Correct namespace
* Initial refactor of policy loading
* Add xml doc, incorporate shim data model
* Updates usages to reflect new shim model
* Prune extranneous data from policy detail response model, format code
* Fix broken test, delete inapplicable test
* Adds test cases covering query
* Adjust codebase to use new PolicyQueryçˆ
* Format code
* Fix incorrect mock on test
* Fix formatting
* Adjust method name
* More naming adjustments
* Add PolicyData constructor, update test usages
* Rename PolicyData -> PolicyStatus
* Remove unused using
* Add default collection name to call stack for restore user command
* Committing feature flag and request model.
* Added tests
* fix for tests.
* added empty string to test
* figured out the mystery commit.
* added vnext onto method name.
* updating tests and command to include feature flag
* moved event call
* last few changes.
* opting for null instead of empty string.
* Enhance MasterPasswordPolicyData with validation attributes
Added data annotations for MinComplexity and MinLength properties to enforce validation rules. MinComplexity must be between 0 and 4, and MinLength must be between 12 and 128.
* Implement model validation in PolicyDataValidator and enhance error handling
Added a ValidateModel method to enforce validation rules for policy data. Updated error messages to provide clearer feedback on validation failures. Enhanced unit tests to cover new validation scenarios for MinLength and MinComplexity properties.
* Update PoliciesControllerTests to reflect new validation rules for MinComplexity and MinLength
Modified test cases to use updated values for MinComplexity (4) and MinLength (128). Added new tests to verify that excessive values for these properties return BadRequest responses. Ensured consistency across integration tests for both Admin and Public controllers.
* Enhance MasterPasswordPolicyData with XML documentation for properties
Added XML documentation comments for MinComplexity and MinLength properties to clarify their purpose and constraints. This improves code readability and provides better context for developers using the model.
* Add unit tests for PolicyDataValidator to validate minLength and minComplexity rules
Implemented new test cases to verify the behavior of the ValidateAndSerialize method in PolicyDataValidator. Tests cover scenarios for minimum and maximum values, as well as edge cases for invalid inputs, ensuring robust validation for MasterPassword policy data.
* Fix null reference when restoring invited users in Free orgs
Add null check before querying for other free org ownership. Invited
users don't have a UserId yet, causing NullReferenceException.
* Add regression test for restoring revoked invited users with null UserId.
* Add sproc to create multiple default collections.
SqlBulkCopy implementation is overkill for most cases.
This provides a lighter weight sproc implementation for smaller
data sets.
* DRY up collection arrangement
* DRY up tests because bulk and non-bulk share same behavior
* use EF native AddRange instead of bulk insert, because
we expect smaller data sizes on self-host
* Updated organization licenses to save the correct values from the token
* Added additional test cases around licenses
* Added missing properties from Organization to UpdateOrganizationLicenseCommand.UpdateLicenseAsync()
* Add tests to validate license property synchronization pipeline
* `dotnet format`
* Add OrganizationUser_SelfRevoked event type to EventType enum
* Add SelfRevokeOrganizationUserCommand implementation and interface for user self-revocation from organizations
* Add unit tests for SelfRevokeOrganizationUserCommand to validate user self-revocation logic, including success scenarios and various failure conditions.
* Add ISelfRevokeOrganizationUserCommand registration to OrganizationServiceCollectionExtensions for user self-revocation functionality
* Add self-revoke user functionality to OrganizationUsersController with new endpoint for user-initiated revocation
* Add integration tests for self-revoke functionality in OrganizationUsersController, covering scenarios for eligible users, non-members, and users with owner/admin roles.
* Add unit test for SelfRevokeOrganizationUserCommand to validate behavior when a user attempts to self-revoke without confirmation. This test checks for a BadRequestException with an appropriate message.
* Add MemberRequirement class for organization membership authorization
- Implemented MemberRequirement to check if a user is a member of the organization.
- Added unit tests for MemberRequirement to validate authorization logic for different user types.
* Update authorization requirement for self-revoke endpoint and add integration test for provider users
- Changed authorization attribute from MemberOrProviderRequirement to MemberRequirement in the RevokeSelfAsync method.
- Added a new integration test to verify that provider users who are not members receive a forbidden response when attempting to revoke themselves.
* Add EligibleForSelfRevoke method to OrganizationDataOwnershipPolicyRequirement
- Implemented the EligibleForSelfRevoke method to determine if a user can self-revoke their data ownership based on their membership status and policy state.
- Added unit tests to validate the eligibility logic for confirmed, invited, and non-policy users, as well as for different organization IDs.
* Refactor self-revoke user command to enhance eligibility checks
- Updated the SelfRevokeOrganizationUserCommand to utilize policy requirements for determining user eligibility for self-revocation.
- Implemented checks to prevent the last owner from revoking themselves, ensuring organizational integrity.
- Modified unit tests to reflect changes in eligibility logic and added scenarios for confirmed owners and admins.
- Removed deprecated policy checks and streamlined the command's dependencies.
* Use CommandResult pattern in self-revoke command
* Clearer documentation
Main fix: only assign new key value where old keys are not set
and new keys have been provided.
Refactors:
- use consistent DTO model for keypairs
- delete duplicate property assignment for new orgs