Commit 41540d5
Dev authorization fakes (#151)
* Created fake helper classes to assist with testing Blazor authentication/authorization. Added unit tests for them.
* Added extension methods to add appropriate authentication/authorization test service, in the right state, to the TestServiceProvider. Added unit tests.
* Added component tests that use AuthorizeView and the BUnit authorization fakes to validate the various states.
* Updated changelog and minor cleanup for SimpleAuthView and test.
* Added placeholders for AuthenticationStateProvider and IAuthorizationService to give user friendly reminder to call AddAuthorization to TestContext.Services.
* committing this to be able to switch
* Created fake helper classes to assist with testing Blazor authentication/authorization. Added unit tests for them.
* Added extension methods to add appropriate authentication/authorization test service, in the right state, to the TestServiceProvider. Added unit tests.
* Added component tests that use AuthorizeView and the BUnit authorization fakes to validate the various states.
* Updated changelog and minor cleanup for SimpleAuthView and test.
* Added placeholders for AuthenticationStateProvider and IAuthorizationService to give user friendly reminder to call AddAuthorization to TestContext.Services.
* Added documentation for fake authorization services and how to use them.
* Fixed code formatting in documentation.
* Update docs/site/docs/mocking/mocking-auth.md
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update src/bunit.web/TestDoubles/Authorization/FakeAuthenticationStateProvider.cs
Change to method comment.
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update docs/site/docs/mocking/mocking-auth.md
changing mocking to faking
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update src/bunit.web.tests/TestDoubles/Authorization/FakeAuthorizationPolicyProviderTest.cs
Removing ConfigureAwait call.
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update src/bunit.web.tests/TestDoubles/Authorization/LoginDisplay.razor
removing NavigationManager
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update src/bunit.web.tests/TestDoubles/Authorization/LoginDisplayTest.cs
removed navigation manager from component.
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update src/bunit.web.tests/TestDoubles/Authorization/LoginDisplayTest.cs
removed navigation manager from component.
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update src/bunit.web.tests/TestDoubles/Authorization/SimpleAuthView.razor
remove unnecessary @code block
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update src/bunit.web.tests/TestDoubles/Authorization/LoginDisplayTest.cs
removed navigation manager from component.
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update src/bunit.web.tests/TestDoubles/Authorization/LoginDisplayTest.cs
removed navigation manager from component.
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Created fake helper classes to assist with testing Blazor authentication/authorization. Added unit tests for them.
* Added extension methods to add appropriate authentication/authorization test service, in the right state, to the TestServiceProvider. Added unit tests.
* Added component tests that use AuthorizeView and the BUnit authorization fakes to validate the various states.
* Updated changelog and minor cleanup for SimpleAuthView and test.
* Added placeholders for AuthenticationStateProvider and IAuthorizationService to give user friendly reminder to call AddAuthorization to TestContext.Services.
* Update src/bunit.web/TestDoubles/Authorization/FakeAuthenticationStateProvider.cs
Change to method comment.
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update src/bunit.web.tests/TestDoubles/Authorization/FakeAuthorizationPolicyProviderTest.cs
Removing ConfigureAwait call.
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update src/bunit.web.tests/TestDoubles/Authorization/LoginDisplay.razor
removing NavigationManager
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update src/bunit.web.tests/TestDoubles/Authorization/LoginDisplayTest.cs
removed navigation manager from component.
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update src/bunit.web.tests/TestDoubles/Authorization/LoginDisplayTest.cs
removed navigation manager from component.
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update src/bunit.web.tests/TestDoubles/Authorization/SimpleAuthView.razor
remove unnecessary @code block
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update src/bunit.web.tests/TestDoubles/Authorization/LoginDisplayTest.cs
removed navigation manager from component.
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update src/bunit.web.tests/TestDoubles/Authorization/LoginDisplayTest.cs
removed navigation manager from component.
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Removed this prefixes from usage in code.
* Rename SimpleAuthViewTest to AuthorizationTests to better describe what it is doing. Remove LoginDisplay component and tests since they are redundant with SimpleAuthView and its tests.
* Added AuthorizationState enum to encapsulate the states. Changed API parameter to use AuthorizationState rather than isAuthorized boolean.
* Renamed FakeAuthorizationExtensions.AddAuthorization to AddTestAuthorization
* Replaced FakeAuthorizationService.NextResult to be CurrentState with an AuthorizationState enum value. Changed FakeAuthenticationStateProvider.TriggerAuthenticationStateChanged to take userName and optional roles parameters.
* Added simplifying methods to FakeAuthorizationExtensions to UpdateTestAuthorizationState. Removes requiring boilerplate state change code in tests.
* Added factory method to simplify creating ClaimsPrincipal when needed.
* Update docs/site/docs/test-doubles/faking-auth.md
Updated doc title
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update docs/site/docs/test-doubles/faking-auth.md
updated doc title
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Update src/bunit.web/TestDoubles/Authorization/MissingFakeAuthorizationException.cs
Updated exception help link
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Fix build failure caused by IList property with a setter.
* Moved SimpleAuthTest to bunit.testassets project. Fixed tests to reference new component.
* Add an explicit SetAuthorizationState to FakeAuthorizationService.
* Hide the CurrentState property because it's an implementation detail.
* Made policy scheme name a settable property with a default to TestScheme (in case users need to explicitly set it).
* Created an AuthorizationAdaptor to wrap some of the auth services and state. Refactored to simplify FakeAuthorizationExtensions methods. Fixed tests.
* Renamed AuthorizationAdaptor to TestAuthorizationContext and minor clean up.
* Changed Roles properties to be non-nullable in TestAuthorizationContext and FakePrincipal.
* Renamed TestAuthorizationContext methods to SetAuthorized and SetNotAuthorized.
* Update CHANGELOG.md with PR comments
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Minor clean ups from PR comments.
* Added check to property setters in FakeIdentity and FakeAuthorizationPolicyProvider.
* Exposed AuthorizeCalls through TestAuthorizationContext for callers to easily access it in tests.
* Small style tweaks to code, spelling, etc.
* Added back .Render() to test removed during experiments
* Additional simplifications of code, update to changelog
* Fixed tests and code that broke during refactor
* Added empty string check to PolicySchemeName. Removed AuthorizeCalls
* Added documentation sample code to the bunit.docs.samples project. Update markdown files to reference sample code rather than duplicate it.
* Made roles list in SetAuthorized a params string[] roles, making it easier to pass just one role. Fixed up tests.
* Added TestAuthorizationContext.SetAuthorizationPolicies as way for callers to specify policy names when they need to test AuthorizeView with Policy set. Changed FakeAuthorizationPolicy to validate policy name in GetPolicyAsync.
* Fix up sample build break.
* Added SimpleAuthViewWithPolicy component to validate testing with AuthorizationView.Policy set.
* Added sample code and unit tests for using AuthorizeView with Policy.
* changed role names, and removed ConfigureAwait calls from test classes.
* Made CreatePrincipal internal
* Added SetRoles method, and made the TestAuthorizationContext methods chainable.
* Updated samples to the TestAuthorizationContext api changes.
* Updated docs to match the style of the other pages
* Added docs samples
* Tests (which breaks) for missing or invalid roles and policies
* removed src/bunit.testassets/SampleComponents/SimpleWithJsRuntimeDep.razor
* Readded SimpleWithJSRuntimeDep.razor
* Fix FakeAuthorizationService to validate checks for policies and roles in AuthorizeAsync method.
* Added SetAuthorizing method and state implementation to get AuthorizeView to behave as expected. Updated sample code too.
* Added TestAuthorizationContext.SetClaims and implementation in services, new SimpleAuthViewWithClaims component, and unit tests.
* Clean up from PR comments.
* Added negative test for AuthorizeView without defined claims.
* Update docs/samples/components/UserInfo.razor
sample white space formtting
Co-authored-by: Egil Hansen <egil@assimilated.dk>
* Changed code to remove null pointer exception if authorizing state was set before call to RenderComponent. Additional other tweaks.
* Docs: added authorizing example to tests, fixed spelling and gramma
Co-authored-by: Egil Hansen <egil@assimilated.dk>1 parent 6b8dc3f commit 41540d5
File tree
36 files changed
+1932
-6
lines changed- docs
- samples
- components
- tests/xunit
- site/docs/test-doubles
- src
- bunit.testassets
- SampleComponents
- bunit.web.tests/TestDoubles/Authorization
- bunit.web
- Extensions
- TestDoubles/Authorization
36 files changed
+1932
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
12 | 51 | | |
13 | 52 | | |
14 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
0 commit comments