-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose an endpoint for bulk processing of organization auth requests #4077
Expose an endpoint for bulk processing of organization auth requests #4077
Conversation
f5c7ec3
to
6c4d8cf
Compare
080c2c9
to
3a85a7c
Compare
8b8099c
to
1a754f5
Compare
3a85a7c
to
e59e335
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## ac/addison/ac-2301/bulk-device-approval-service #4077 +/- ##
==================================================================================
Coverage ? 39.26%
==================================================================================
Files ? 1215
Lines ? 58454
Branches ? 5376
==================================================================================
Hits ? 22950
Misses ? 34434
Partials ? 1070 ☔ View full report in Codecov by Sentry. |
1a754f5
to
603cc6d
Compare
model.Select(x => | ||
new OrganizationAuthRequestUpdateCommandModel | ||
{ | ||
Id = x.Id, | ||
Key = x.Key, | ||
Approved = x.Approved | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like putting this in the request class itself: model.Select(x => x.ToOrganizationAuthRequestUpdate())
. We do this elsewhere as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented as suggested on 9771863
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment as on the command PR, but here I think it's actually fairly critical that we unit test the permissions check on the endpoint itself, and not (only) via the ValidateaAdminRequest
method. As a security matter, we want to ensure that our endpoints are checking user permissions, and you're not really assured of that unless you're testing the endpoint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented as suggested on 2587e5d
fd4eb2f
to
5942db0
Compare
7f61948
to
b84c312
Compare
6357076
to
fb11acb
Compare
fb11acb
to
78da7fc
Compare
7f17510
to
cdb5a32
Compare
…c/addison/ac-2301/bulk-device-approval-api
…c/addison/ac-2301/bulk-device-approval-api
Merging into the base branch, then merging that into |
5d263fa
into
ac/addison/ac-2301/bulk-device-approval-service
* 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>
Type of change
Objective
In order to facilitate a new batch approval process for organization auth requests in the web vault and CLI a new endpoint needs to be added to the API that accepts a list or auth request updates and processes them.
Code changes
The changes here are pretty straight forward, most of the work has already happened on lower levels of the project. This PR simply adds a new endpoint, request model, and some tests. A feature flag has also been added at this stage.
References