1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-21 12:05:42 +01:00
bitwarden-server/test/Core.Test
Addison Beck 98a191a5e8
Allow for bulk processing new login device requests (#4064)
* Define a model for updating many auth requests

In order to facilitate a command method that can update many auth
requests at one time a new model must be defined that accepts valid
input for the command's needs. To achieve this a new file has been
created at
`Core/AdminConsole/OrganizationAuth/Models/OrganizationAuthRequestUpdateCommandModel.cs`
that contains a class of the same name. It's properties match those that
need to come from any calling API request models to fulfill the request.

* Declare a new command interface method

Calling API functions of the `UpdateOrganizationAuthRequestCommand` need
a function that can accept many auth request response objects and
process them as approved or denied. To achieve this a new function has
been added to `IUpdateOrganizationAuthRequestCommand` called
`UpdateManyAsync()` that accepts an
`IEnumberable<OrganizationAuthRequest>` and returns a `Task`.
Implementations of this interface method will be used to bulk process
auth requests as approved or denied.

* Stub out method implementation for unit testing

To facilitate a bulk device login request approval workflow in the admin
console `UpdateOrganizationAuthRequestCommand` needs to be updated to
include an `UpdateMany()` method. It should accept a list of
`OrganizationAuthRequestUpdateCommandModel` objects, perform some simple
data validation checks, and then pass those along to
`AuthRequestRepository` for updating in the database.

This commit stubs out this method for the purpose of writing unit tests.
At this stage the method throws a `NotImplementedException()`. It will
be expand after writing assertions.

* Inject `IAuthRequestRepository` into `UpdateOrganizationAuthCommand`

The updates to `UpdateOrganizationAuthRequestCommand` require a new
direct dependency on `IAuthRequestRepository`. This commit simply
registers this dependency in the `UpdateOrganizationAuthRequest`
constructor for use in unit tests and the `UpdateManyAsync()`
implementation.

* Write tests

* Rename `UpdateManyAsync()` to `UpdateAsync`

* Drop the `CommandModel` suffix

* Invert business logic update filters

* Rework everything to be more model-centric

* Bulk send push notifications

* Write tests that validate the command as a whole

* Fix a test that I broke by mistake

* Swap to using await instead of chained methods for processing

* Seperate a function arguement into a variable declaration

* Ungeneric-ify the processor

* Adjust ternary formatting

* Adjust naming of methods regarding logging organization events

* Throw an exception if Process is called with no auth request loaded

* Rename `_updates` -> `_update`

* Rename email methods

* Stop returning `this`

* Allow callbacks to be null

* Make some assertions about the state of a processed auth request

* Be more terse about arguements in happy path test

* Remove unneeded null check

* Expose an endpoint for bulk processing of organization auth requests  (#4077)

---------

Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
2024-05-27 11:56:52 +10:00
..
AdminConsole Allow for bulk processing new login device requests (#4064) 2024-05-27 11:56:52 +10:00
Auth Replace async void with async Task (#3835) 2024-02-22 11:59:08 -05:00
AutoFixture [AC-2027] Update Flexible Collections logic to use organization property (#3644) 2024-01-17 12:33:35 +00:00
Billing [AC-2576] Replace Billing commands and queries with services (#4070) 2024-05-23 10:17:00 -04:00
Entities [AC-1283] AC Team code ownership moves: Organization (pt 2) (#3486) 2023-11-29 15:31:15 -06:00
Helpers Run formatting (#2230) 2022-08-29 16:06:55 -04:00
Models [BEEEP][AC-2497] Create unit test for the SubscriptionUpdate classes (#4054) 2024-05-13 20:35:22 +01:00
OrganizationFeatures [AC-2211] SM Changes (#3938) 2024-04-08 14:42:01 -04:00
Resources Run formatting (#2230) 2022-08-29 16:06:55 -04:00
SecretsManager [SM-923] Add project service accounts access policies management endpoints (#3993) 2024-05-02 11:06:20 -05:00
Services [PM-6977] Migrate to FCM v1 (redo) (#4046) 2024-05-02 16:37:06 -04:00
Tokens Run formatting (#2230) 2022-08-29 16:06:55 -04:00
Tools Replace async void with async Task (#3835) 2024-02-22 11:59:08 -05:00
Utilities [AC-2211] SM Changes (#3938) 2024-04-08 14:42:01 -04:00
Vault [AC-2084] Include Collection permissions for admin endpoints (#3793) 2024-05-03 09:33:06 -04:00
ConstantsTests.cs [PM-3565] Enforce higher minimum KDF (#3304) 2023-12-05 17:21:46 +01:00
Core.Test.csproj Remove moq (#3166) 2023-08-10 17:03:42 +02:00
TempDirectory.cs Run formatting (#2230) 2022-08-29 16:06:55 -04:00