Testing authentication

Testing our code is essential at this point: we should check, document, and verify the behaviors of our system before running the application in a server instance. Furthermore, it is also crucial to test authentication behavior because it is a sensitive part of our service.

Since the UserRepository implementation is the most low-level part of the authentication stack and the first component that relies on EF Core to retrieve, update, and authenticate the user, we can keep it isolated and exclude it from the testing process by mocking the IUserRepository interface.

Both SignInManager<T> and the UserManager<T> classes represent a core part of our authentication process, and they are part of a third-party package maintained ...

Get Hands-On RESTful Web Services with ASP.NET Core 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.