From the course: Blazor: Getting Started
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Challenge: Unit testing authorization - Blazor Tutorial
From the course: Blazor: Getting Started
Challenge: Unit testing authorization
(upbeat music) - [Instructor] Now that we have authorization and the ability to test authorized views, we can add another section to the index page. We'll show the user something if they don't have access and they somehow got to the index page without following the redirect in the main layout. We can't easily test this manually because of that redirect. The challenge is to add some text there and then write a unit test to validate that the index page shows the NotAuthorized section if the user viewing the page doesn't authenticate successfully. To help with this challenge, I'll mention that there's another parameter we haven't used yet when calling AddAuthenticationService from the test authentication service. You can set that value to AuthorizationResult.Failed.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Authentication in a Blazor application11m 4s
-
(Locked)
Authorization in a Blazor application9m 7s
-
(Locked)
Unit test authorization in a Blazor application4m 51s
-
(Locked)
Maintain state in Blazor WebAssembly11m 4s
-
(Locked)
Challenge: Unit testing authorization59s
-
(Locked)
Solution: Unit testing authorization1m 28s
-
-
-
-