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

Challenge: Unit testing authorization - Blazor Tutorial

From the course: Blazor: Getting Started

Start my 1-month free trial

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.

Contents