1
0
mirror of https://github.com/bitwarden/server synced 2025-12-06 00:03:34 +00:00
Commit Graph

623 Commits

Author SHA1 Message Date
Kyle Denney
ef8c7f656d [PM-24350] fix tax calculation (#6251) 2025-09-03 10:03:49 -05:00
cyprain-okeke
fa8d65cc1f [PM 19727] Update InvoiceUpcoming email content (#6168)
* changes to implement the email

* Refactoring and fix the unit testing

* refactor the code and remove used method

* Fix the failing test

* Update the email templates

* remove the extra space here

* Refactor the descriptions

* Fix the wrong subject header

* Add the in the hyperlink rather than just Help center
2025-09-03 20:33:32 +05:30
Rui Tomé
1dade9d4b8 [PM-24233] Use BulkResourceCreationService in CipherRepository (#6201)
* Add constant for CipherRepositoryBulkResourceCreation in FeatureFlagKeys

* Add bulk creation methods for Ciphers, Folders, and CollectionCiphers in BulkResourceCreationService

- Implemented CreateCiphersAsync, CreateFoldersAsync, CreateCollectionCiphersAsync, and CreateTempCiphersAsync methods for bulk insertion.
- Added helper methods to build DataTables for Ciphers, Folders, and CollectionCiphers.
- Enhanced error handling for empty collections during bulk operations.

* Refactor CipherRepository to utilize BulkResourceCreationService

- Introduced IFeatureService to manage feature flag checks for bulk operations.
- Updated methods to conditionally use BulkResourceCreationService for creating Ciphers, Folders, and CollectionCiphers based on feature flag status.
- Enhanced existing bulk copy logic to maintain functionality while integrating feature flag checks.

* Add InlineFeatureService to DatabaseDataAttribute for feature flag management

- Introduced EnabledFeatureFlags property to DatabaseDataAttribute for configuring feature flags.
- Integrated InlineFeatureService to provide feature flag checks within the service collection.
- Enhanced GetData method to utilize feature flags for conditional service registration.

* Add tests for bulk creation of Ciphers in CipherRepositoryTests

- Implemented tests for bulk creation of Ciphers, Folders, and Collections with feature flag checks.
- Added test cases for updating multiple Ciphers to validate bulk update functionality.
- Enhanced existing test structure to ensure comprehensive coverage of bulk operations in the CipherRepository.

* Refactor BulkResourceCreationService to use dynamic types for DataColumns

- Updated DataColumn definitions in BulkResourceCreationService to utilize the actual types of properties from the cipher object instead of hardcoded types.
- Simplified the assignment of nullable properties to directly use their values, improving code readability and maintainability.

* Update BulkResourceCreationService to use specific types for DataColumns

- Changed DataColumn definitions to use specific types (short and string) instead of dynamic types based on cipher properties.
- Improved handling of nullable properties when assigning values to DataTable rows, ensuring proper handling of DBNull for null values.

* Refactor CipherRepositoryTests for improved clarity and consistency

- Renamed test methods to better reflect their purpose and improve readability.
- Updated test data to use more descriptive names for users, folders, and collections.
- Enhanced test structure with clear Arrange, Act, and Assert sections for better understanding of test flow.
- Ensured all tests validate the expected outcomes for bulk operations with feature flag checks.

* Update CipherRepositoryBulkResourceCreation feature flag key

* Refactor DatabaseDataAttribute usage in CipherRepositoryTests to use array syntax for EnabledFeatureFlags

* Update CipherRepositoryTests to use GenerateComb for generating unique IDs

* Refactor CipherRepository methods to accept a boolean parameter for enabling bulk resource creation based on feature flags. Update tests to verify functionality with and without the feature flag enabled.

* Refactor CipherRepository and related services to support new methods for bulk resource creation without boolean parameters.
2025-09-03 14:57:53 +01:00
Ike
d2d3e0f11b [PM-22678] Send email otp authentication method (#6255)
feat(auth): email OTP validation, and generalize authentication interface

- Generalized send authentication method interface
- Made validate method async
- Added email mail support for Handlebars
- Modified email templates to match future implementation

fix(auth): update constants, naming conventions, and error handling

- Renamed constants for clarity
- Updated claims naming convention
- Fixed error message generation
- Added customResponse for Rust consumption

test(auth): add and fix tests for validators and email

- Added tests for SendEmailOtpRequestValidator
- Updated tests for SendAccessGrantValidator

chore: apply dotnet formatting
2025-09-02 16:48:57 -04:00
Jimmy Vo
8ceb6f5621 [PM-24278] Create Remove Individual Vault validator (#6139) 2025-08-27 11:01:22 -04:00
Justin Baur
e5159a3ba2 [PM-19659] Clean up Notifications code (#6244)
* Move PushType to Platform Folder

- Move the PushType next to the rest of push notification code
- Specifically exclude it from needing Platform code review
- Add tests establishing rules Platform has for usage of this enum, making it safe to have no owner

* Move NotificationHub code into Platform/Push directory

* Update NotificationHub namespace imports

* Add attribute for storing push type metadata

* Rename Push Engines to have PushEngine suffix

* Move Push Registration items to their own directory

* Push code move

* Add expected usage comment

* Add Push feature registration method

- Make method able to be called multipes times with no ill effects

* Add Push Registration service entrypoint and tests

* Use new service entrypoints

* Test changes
2025-08-26 13:30:37 -04:00
renovate[bot]
50b36bda2a [deps] Auth: Update Duende.IdentityServer to 7.2.4 (#5683)
* [deps] Auth: Update Duende.IdentityServer to 7.2.4

* fix: update namespaces

* chore: dotnet format
---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Ike Kottlowski <ikottlowski@bitwarden.com>
Co-authored-by: Ike <137194738+ike-kottlowski@users.noreply.github.com>
2025-08-21 16:53:36 -04:00
Stephon Brown
91bb3c1e68 [PM-24555] Remove Code for PM-21092 (#6198) 2025-08-21 16:24:16 -04:00
Kyle Denney
c519fa43c6 [PM-21878] update gateway/stripe fields for business units (#6186)
* [PM-21878] also update gateway/stripe fields for business units

* pr feedback: replacing switch with extension method

* [PM-21878] prevent invalid stripe ids from crashing the edit provider page

* pr feedback: adding service methods to validate stripe ids

and added unit tests for the new methods

* pr feedback: move validation to SubscriberService and cleanup

* pr feedback: use subscriber service to remove dependency on stripe adapter
2025-08-21 13:54:20 -05:00
Kyle Spearrin
1c98e59003 [PM-25050] limit failed 2fa emails to once per hour (#6227)
* limit failed 2fa emails to once per hour

* Linting.

---------

Co-authored-by: Todd Martin <tmartin@bitwarden.com>
2025-08-21 13:44:08 -04:00
Brandon Treston
cf94438150 [PM-22586/PM-22587] Remove feature flagged logic (#6194)
* remove feature flagged logic

* remove feature flag

* remove OrganizationService.ImportAsync and tests

* remove unused function
2025-08-20 11:10:06 -04:00
Stephon Brown
9face76417 [PM-22980] Organization name not updated in Stripe when organization name is changed (#6189)
* tests: add tests for UpdateAsync change

* fix: update Stripe customer object update

* refactor: replace CustomerService objects with stripeAdapter

* refactor: simplify controller logic

* fix: mark businessname and it's function obsolete for future use

* fix: pr feedback remove business name check

* refactor: remove unused functions in organizationservice
2025-08-20 09:27:05 -04:00
Alex Morask
bd133b936c [PM-22145] Tax ID notifications for Organizations and Providers (#6185)
* Add TaxRegistrationsListAsync to StripeAdapter

* Update GetOrganizationWarningsQuery, add GetProviderWarningsQuery to support tax ID warning

* Add feature flag to control web display

* Run dotnet format'
2025-08-18 09:42:51 -05:00
Ike
8a36d96e56 [PM-22739] Add ClaimsPrincipal Extension
feat: add ClaimsPrincipal Extension
test: add tests
2025-08-15 10:06:40 -04:00
Rui Tomé
c30c0c1d2a [PM-12492] Create ResendOrganizationInviteCommand (#6182)
* Add IResendOrganizationInviteCommand and ResendOrganizationInviteCommand implementation

* Add unit tests for ResendOrganizationInviteCommand to validate invite resend functionality

* Refactor Organizations, OrganizationUsers, and Members controllers to use IResendInviteCommand for invite resending functionality

* Fix Organizations, OrganizationUsers, and Members controllers to replace IResendInviteCommand with IResendOrganizationInviteCommand

* Remove ResendInviteAsync method from IOrganizationService and its implementation in OrganizationService to streamline invite management functionality.

* Add IResendOrganizationInviteCommand registration in OrganizationServiceCollectionExtensions
2025-08-14 15:02:00 +01:00
Thomas Rittson
9022ad2360 [PM-20140] Prevent accidental bulk removal of users without a Master Password (#6173) 2025-08-12 10:21:29 +10:00
Rui Tomé
e042572cfb [PM-24582] Bugfix: exclude admins and owners from default user collection creation on confirmation (#6177)
* Update the OrganizationUserController integration Confirm tests to handle the Owner type

* Refactor ConfirmOrganizationUserCommand to simplify side-effect handling in organization user confirmation.
Update IPolicyRequirementQuery to return eligible org user IDs for policy enforcement.
Update tests for method signature changes and default collection creation logic.
2025-08-11 16:36:40 +01:00
Rui Tomé
9d05105dc0 [PM-23981] Fix DefaultUserCollection filtering in organization user updates (#6161)
* Refactor UpdateOrganizationUserCommand to validate and filter out DefaultUserCollections during user updates.

* Enhance UpdateOrganizationUserCommandTests to filter out DefaultUserCollections during user updates, ensuring only shared collections are processed. Updated test logic to reflect new filtering behavior.

* Add integration test for updating organization user with existing default collection. The test verifies successful updates to user permissions, group access, and collection access, ensuring correct handling of shared and default collections.

* Refactor UpdateOrganizationUserCommand to separate the collection validation and DefaultUserCollection filtering

* Refactored integration test setup/assertion for clarity
2025-08-07 11:12:45 +01:00
Rui Tomé
7454430aa1 [PM-22241] Add DefaultUserCollectionName support to bulk organization user confirmation (#6153)
* Implement GetByOrganizationAsync method in PolicyRequirementQuery and add corresponding unit tests

* Refactor ConfirmOrganizationUserCommand for clarity and add bulk support

* Update ConfirmOrganizationUserCommandTests to use GetByOrganizationAsync for policy requirement queries

* Add DefaultUserCollectionName property to OrganizationUserBulkConfirmRequestModel with encryption attributes

* Update ConfirmUsersAsync method to include DefaultUserCollectionName parameter in OrganizationUsersController

* Add EnableOrganizationDataOwnershipPolicyAsync method to OrganizationTestHelpers

* Add integration tests for confirming organization users in OrganizationUserControllerTests

- Implemented Confirm_WithValidUser test to verify successful confirmation of a single user.
- Added BulkConfirm_WithValidUsers test to ensure multiple users can be confirmed successfully.

* Refactor organization user confirmation integration tests to also test when the organization data ownership policy is disabled

* Refactor ConfirmOrganizationUserCommand to consolidate confirmation side effects handling

- Replaced single and bulk confirmation side effect methods with a unified HandleConfirmationSideEffectsAsync method.
- Updated related logic to handle confirmed organization users more efficiently.
- Adjusted unit tests to reflect changes in the collection creation process for confirmed users.

* Refactor OrganizationUserControllerTests to simplify feature flag handling and consolidate test logic

- Removed redundant feature flag checks in Confirm and BulkConfirm tests.
- Updated tests to directly enable the Organization Data Ownership policy without conditional checks.
- Ensured verification of DefaultUserCollection for confirmed users remains intact.

* Refactor OrganizationUserControllerTests to enhance clarity and reduce redundancy

- Simplified user creation and confirmation logic in tests by introducing helper methods.
- Consolidated verification of confirmed users and their associated collections.
- Removed unnecessary comments and streamlined test flow for better readability.
2025-08-05 15:34:13 +01:00
Stephon Brown
2908ddb759 [PM-22692] Fix Secrets Manager Seat and ServiceAccount Limit Bug (#6138)
* test: add new test harnesses

* feat: update autoscale limit logic for SM Subscription Command

* fix: remove redundant helper methods

* fix: add periods to second sentence of templates
2025-08-01 14:40:43 -04:00
Brant DeBow
ccedefb8b8 [PM-17562] Update logs to use custom categories (#6145)
* [PM-17562] Update logs to use custom categories

* Added tests to verify hardcoded names match the real type
2025-08-01 08:46:00 -04:00
Jimmy Vo
6f4a0c4a61 [PM-15052] Add RevokeOrganizationUserCommand (#6111) 2025-07-31 11:27:53 -04:00
Jared McCannon
86ce3a86e9 [PM-20452] - Offloading Stripe Update (#6034)
* Adding job to update stripe subscriptions and increment seat count  when inviting a user.

* Updating name

* Added ef migrations

* Fixing script

* Fixing procedures. Added repo tests.

* Fixed set stored procedure. Fixed parameter name.

* Added tests for database calls and updated stored procedures

* Fixed build for sql file.

* fixing sproc

* File is nullsafe

* Adding view to select from instead of table.

* Updating UpdateSubscriptionStatus to use a CTE and do all the updates in 1 statement.

* Setting revision date when incrementing seat count

* Added feature flag check for the background job.

* Fixing nullable property.

* Removing new table and just adding the column to org. Updating to query and command. Updated tests.

* Adding migration script rename

* Add SyncSeats to Org.sql def

* Adding contraint name

* Removing old table files.

* Added tests

* Upped the frequency to be at the top of every 3rd hour.

* Updating error message.

* Removing extension method

* Changed to GuidIdArray

* Added xml doc and switched class to record
2025-07-31 07:54:51 -05:00
Thomas Rittson
88dd977848 [PM-23921] [BEEEP] Add IOrganizationRequirements for each permission (#6105)
* Add BasePermissionRequirement and implement it for each permission

* Add tests
2025-07-31 11:22:06 +10:00
Rui Tomé
5816ed6600 [PM-23141] Fix: Users unable to edit ciphers after being confirmed into organization (#6097)
* Refactor ConfirmOrganizationUserCommand to push registration after DB save

* Assert device push registration handling in ConfirmOrganizationUserCommandTests
2025-07-30 12:00:48 +01:00
Brant DeBow
a84e5554fb [PM-17562] Refactor event integration methods / declarations in ServiceCollectionExtensions (#6118)
* [PM-17562] Refactor event integration methods / declarations in ServiceCollectionExtensions

* Refactored ServiceCollectionExtensions to use TryAdd and still launch unique listeneer services

* Updated unit tests to match new generic format for Listeners

* Fix method spacing

* Update README to reflect new integration setup in ServiceCollectionExtensions

* Move interfaces to I prefix; fix typo in subscription

* Fix reference to IIntegrationListenerConfiguration
2025-07-29 11:22:21 -04:00
Justin Baur
7e80e01747 [PM-21948] Warn on deprecated logging methods (#6101)
* Add warnings and scaffold tests

* Do some private reflection

* Add tests for warnings

* Add explainer comment

* Remove Reference to Azure CosmosDb Sink

* Don't warn on old file location

* Update test names

* Add syslog test

* dotnet format

* Add lazy syslog fix

* Add longer wait for file

* Make syslog test local only

* Switch to shortened URL
2025-07-25 17:44:51 -04:00
Brandon Treston
571111e897 [PM-18239] Master password policy requirement (#5936)
* wip

* initial implementation

* add tests

* more tests, fix policy Enabled

* remove exempt statuses

* test EnforcedOptions is populated

* clean up, add test

* fix test, add json attributes for deserialization

* fix attribute casing

* fix test

---------

Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
2025-07-25 10:14:16 -04:00
Ike
05398ad8a4 [PM-22736] Send password hasher (#6112)
* feat: 
  - Add SendPasswordHasher class and interface
  - DI for SendPasswordHasher to use Marker class allowing us to use custom options for the SendPasswordHasher without impacting other PasswordHashers.
* test: Unit tests for SendPasswordHasher implementation
* doc: docs for interface and comments

Co-authored-by: Maciej Zieniuk <167752252+mzieniukbw@users.noreply.github.com>
2025-07-24 12:49:15 -04:00
Alex Morask
2d1f914eae [PM-24067] Check for unverified bank account in free trial / inactive subscription warning (#6117)
* [NO LOGIC] Move query to core

* Check for unverified bank account in free trial and inactive subscription warnings

* Run dotnet format

* fix test

* Run dotnet format

* Remove errant file
2025-07-24 09:59:23 -05:00
Brandon Treston
947ae8db51 [PM-19145] refactor organization service.import async (#5800)
* initial lift and shift

* extract function RemoveExistingExternalUsers

* Extract function RemoveExistingUsers()

* extract function OverwriteExisting()

* create new model for sync data

* extract add users to function, rename

* rename OrganizatinUserInvite for command, implement command

* implement command

* refactor groups logic

* fix imports

* remove old tests, fix imports

* fix namespace

* fix CommandResult useage

* tests wip

* wip

* wip

* remove redundant code, remove looping db call, refactor tests

* clean up

* remove looping db call with bulk method

* clean up

* remove orgId param to use id already in request

* change param

* cleanup params

* remove IReferenceEventService

* fix test

* fix tests

* cr feedback

* remove _timeProvider

* add xmldoc, refactor to make InviteOrganizationUsersCommand vNext instead of default

* switch back to command

* re-add old ImportAsync impl

* fix test

* add feature flag

* cleanup

* clean up

* fix tests

* wip

* wip

* add api integration tests for users WIP

* groups integration tests

* cleanup

* fix error from merging main

* fix tests

* cr feedback

* fix test

* fix test
2025-07-22 17:30:25 -04:00
Brant DeBow
f4e1e2f1f7 [PM-17562] Add support for null/all event type (#6100)
* [PM-17562] Add support for null/all event type

* Address PR Feedback

* Adjusted SQL scripts per feedback
2025-07-22 10:02:13 -04:00
Justin Baur
b0b2b94fc9 Remove X509ChainCustomization Feature (#6108)
* Remove X509ChainCustomization Feature

* `dotnet format`
2025-07-21 11:54:00 -04:00
Rui Tomé
4464bfe900 [PM-15159] Create SelfHostedOrganizationSignUp command (#6089)
* Add SelfHostedOrganizationSignUpCommand for organization sign-up process

Method extracted from OrganizationService

* Register SelfHostedOrganizationSignUpCommand for dependency injection

* Add unit tests for SelfHostedOrganizationSignUpCommand

* Refactor SelfHostedOrganizationLicensesController to use ISelfHostedOrganizationSignUpCommand

* Remove SignUpAsync method and related validation from IOrganizationService and OrganizationService

* Move ISelfHostedOrganizationSignUpCommand into a separate file and update references

* Enable null safety in SelfHostedOrganizationSignUpCommand and update ISelfHostedOrganizationSignUpCommand interface to reflect nullable types for organizationUser and collectionName.
2025-07-21 14:35:41 +01:00
Ike
828003f101 [PM-19055] Add OTP Token Provider that is not dependent on the User entity (#6081)
* feat(pm-19055) : 
  - Add generic OTP generator. This OTP generator is not linked to .NET Identity giving us flexibility.
  - Update `OtpTokenProvider` to accept configuration object to keep interface clean.
  - Implement `OtpTokenProvider` in DI as open generic for flexibility.
* test: 100% test coverage for `OtpTokenProvider`
* doc: Added readme for `OtpTokenProvider`
2025-07-17 17:44:20 -04:00
Alex Morask
ec70a18bda [NO LOGIC] [PM-21100] Organize billing organization code (#6099)
* [NO LOGIC] Organize Billing organization code

* Run dotnet format
2025-07-17 12:02:25 -05:00
Brant DeBow
5fc7f4700c [PM-17562] Add in-memory cache for event integrations (#6085)
* [PM-17562] Add in-memory cache for event integrations

* Fix Sql error

* Fix failing test

* Add additional tests for new cache service

* PR suggestions addressed
2025-07-16 11:41:08 -04:00
Jared McCannon
c4965350d1 [PM-12474] Move to authorization to attibutes/handlers/requirements (#6001)
* Created ReadAllOrganizationUsersBasicInformationRequirement for use with Authorize attribute.

* Removed unused req and Handler and tests. Moved to new auth attribute

* Moved tests to integration tests with new response.

* Removed tests that were migrated to integration tests.

* Made string params Guids instead of parsing them manually in methods.

* Admin and Owner added to requirement.

* Added XML docs for basic get endpoint. Removed unused. Added another auth check. Inverted if check.

* Removed unused endpoint

* Added tests for requirement

* Added checks for both User and Custom

* Added org id check to validate the user being requested belongs to the org in the route.

* typo
2025-07-15 07:52:47 -05:00
Alex Morask
d914ab8a98 [PM-23687] Support free organizations on Payment Details page (#6084)
* Resolve JSON serialization bug in OneOf converters and organize pricing models

* Support free organizations for payment method and billing address flows

* Run dotnet format
2025-07-14 12:39:49 -05:00
Todd Martin
2f8460f4db feat(OTP): [PM-18612] Change email OTP to six digits
* Change email OTP to 6 digits

* Added comment on base class

* Added tests

* Renamed tests.

* Fixed tests

* Renamed file to match class
2025-07-14 10:23:30 -04:00
Conner Turnbull
9b65e9f4cc [PM-22580] Org/User License Codeownership Move (No logic changes) (#6080)
* Moved license models to billing

* Moved LicensingService to billing

* Moved license command and queries to billing

* Moved LicenseController to billing
2025-07-11 16:41:32 -04:00
Alex Morask
7f65a655d4 [PM-21881] Manage payment details outside of checkout (#6032)
* Add feature flag

* Further establish billing command pattern and use in PreviewTaxAmountCommand

* Add billing address models/commands/queries/tests

* Update TypeReadingJsonConverter to account for new union types

* Add payment method models/commands/queries/tests

* Add credit models/commands/queries/tests

* Add command/query registrations

* Add new endpoints to support new command model and payment functionality

* Run dotnet format

* Add InjectUserAttribute for easier AccountBillilngVNextController handling

* Add InjectOrganizationAttribute for easier OrganizationBillingVNextController handling

* Add InjectProviderAttribute for easier ProviderBillingVNextController handling

* Add XML documentation for billing command pipeline

* Fix StripeConstants post-nullability

* More nullability cleanup

* Run dotnet format
2025-07-10 08:32:25 -05:00
Justin Baur
da66400248 Add #nullable disable to AC code (#6052) 2025-07-08 17:32:49 -04:00
Todd Martin
79ad1dbda0 fix(2fa): [PM-22323] Do not show 2FA warning for 2FA setup and login emails
* Added configuration to not display 2FA setup instruction

* Refactored to new service.

* Linting.

* Dependency injection

* Changed to scoped to have access to ICurrentContext.

* Inverted logic for EmailTotpAction

* Fixed tests.

* Fixed tests.

* More tests.

* Fixed tests.

* Linting.

* Added tests at controller level.

* Linting

* Fixed error in test.

* Review updates.

* Accidentally deleted imports.
2025-07-07 10:56:59 -04:00
Nick Krantz
240968ef4c Refactor PendingSecurityTasks to RefreshSecurityTasks (#5903)
- Allows for more general use case of security task notifications
2025-07-07 09:24:57 -05:00
Brant DeBow
f6cd661e8e [PM-17562] Add HEC integration support (#6010)
* [PM-17562] Add HEC integration support

* Re-ordered parameters per PR suggestion

* Apply suggestions from code review

Co-authored-by: Matt Bishop <mbishop@bitwarden.com>

* Refactored webhook request model validation to be more clear

---------

Co-authored-by: Matt Bishop <mbishop@bitwarden.com>
2025-07-01 08:52:38 -04:00
Rui Tomé
e8ad23c8bc [PM-22442] Remove CollectionService (#6015)
* Refactor Collections and OrganizationExport Controllers to Remove ICollectionService Dependency

* Remove ICollectionService registration from ServiceCollectionExtensions

* Remove CollectionServiceTests file as part of the ongoing refactor to eliminate ICollectionService.

* Remove ICollectionService and its implementation in CollectionService as part of the ongoing refactor to eliminate the service.
2025-07-01 13:17:53 +01:00
Jimmy Vo
1da39aa2b8 [PM-22405] Add debugging instrument for finding invalid OrganizationUser state. (#5955) 2025-06-30 09:45:15 -04:00
Rui Tomé
290fa3ded4 [PM-22101] Enforce restrictions on collections with DefaultUserCollection type (#5968)
* Add CreateCollectionCommand and associated interface with validation logic

* Implement CreateCollectionCommand to handle collection creation with organization checks and access permissions.
* Introduce ICreateCollectionCommand interface for defining the collection creation contract.
* Add unit tests for CreateCollectionCommand to validate various scenarios including permission checks and error handling.

* Add UpdateCollectionCommand and associated interface with validation logic

* Implement UpdateCollectionCommand to handle collection updates with organization checks and access permissions.
* Introduce IUpdateCollectionCommand interface for defining the collection update contract.
* Add unit tests for UpdateCollectionCommand to validate various scenarios including permission checks and error handling.

* Add scoped services for collection commands

* Register ICreateCollectionCommand and IUpdateCollectionCommand in the service collection for handling collection creation and updates.

* Refactor CollectionsController to use command interfaces for collection creation and updates

* Updated CollectionsController to utilize ICreateCollectionCommand and IUpdateCollectionCommand for handling collection creation and updates, replacing calls to ICollectionService.
* Adjusted related unit tests to verify the new command implementations.

* Refactor ICollectionService and CollectionService to remove SaveAsync method

* Removed the SaveAsync method from ICollectionService and its implementation in CollectionService.
* Updated related tests in CollectionServiceTests to reflect the removal of SaveAsync, ensuring existing functionality remains intact.

* Remove unused organization repository dependency from CollectionServiceTests

* Add validation to CreateCollectionCommand to prevent creation of DefaultUserCollection type

* Implemented a check in CreateCollectionCommand to throw a BadRequestException if a collection of type DefaultUserCollection is attempted to be created.
* Added a unit test to verify that the exception is thrown with the correct message when attempting to create a collection of this type.

* Add validation to DeleteCollectionCommand to prevent deletion of DefaultUserCollection type

* Implemented checks in DeleteAsync and DeleteManyAsync methods to throw a BadRequestException if a collection of type DefaultUserCollection is attempted to be deleted.
* Added unit tests to verify that the exceptions are thrown with the correct messages when attempting to delete collections of this type.

* Add validation in UpdateCollectionCommand to prevent editing DefaultUserCollection type

* Implemented a check in UpdateAsync to throw a BadRequestException if a collection of type DefaultUserCollection is attempted to be updated.
* Added a unit test to verify that the exception is thrown with the correct message when attempting to update a collection of this type.

* Add validation in UpdateOrganizationUserCommand to prevent modification of DefaultUserCollection type

* Implemented a check to throw a BadRequestException if an attempt is made to modify member access for collections of type DefaultUserCollection.
* Added a unit test to ensure the exception is thrown with the correct message when this condition is met.

* Add validation in UpdateGroupCommand to prevent modification of DefaultUserCollection type

* Implemented a check to throw a BadRequestException if an attempt is made to modify group access for collections of type DefaultUserCollection.
* Added a unit test to ensure the exception is thrown with the correct message when this condition is met.

* Add validation in BulkAddCollectionAccessCommand to prevent addition of collections of DefaultUserCollection type

* Implemented a check to throw a BadRequestException if an attempt is made to add access to collections of type DefaultUserCollection.
* Added a unit test to ensure the exception is thrown with the correct message when this condition is met.

* Add validation in CollectionService to prevent modification of DefaultUserCollection type

* Implemented a check in DeleteUserAsync to throw a BadRequestException if an attempt is made to modify member access for collections of type DefaultUserCollection.
* Added a unit test to ensure the exception is thrown with the correct message when this condition is met.

* Implement a check to throw a BadRequestException if an attempt is made to modify member access for collections of type DefaultUserCollection.

* Add validation in CollectionsController to prevent deletion of DefaultUserCollection type

* Implemented a check to return a BadRequestObjectResult if an attempt is made to delete a collection of type DefaultUserCollection.

* Remove unused test method for handling DefaultUserCollection in CollectionsControllerTests

* Update UpdateOrganizationUserCommandTests to use OrganizationUserType for user updates
2025-06-27 15:29:34 +01:00
Brant DeBow
57cd628de8 [PM-17562] Add integration filter support (#5971)
* [PM-17562] Add integration filter support

* Repond to PR feedback; Remove Date-related filters

* Use tables to format the filter class descriptions

* [PM-17562] Add database support for integration filters (#5988)

* [PM-17562] Add database support for integration filters

* Respond to PR review - fix database scripts

* Further database updates; fix Filters to be last in views, stored procs, etc

* Fix for missing nulls in stored procedures in main migration script

* Reorder Filters to the bottom of OrganizationIntegrationConfiguration

* Separate out the creation of filters from the IntegrationFilterService to IntegrationFIlterFactory

* Move properties to static readonly field

* Fix unit tests failing from merge

---------

Co-authored-by: Matt Bishop <mbishop@bitwarden.com>
2025-06-26 16:03:05 -04:00