Loading
Current section: Authentication 6 exercises
Problem

Basic

Loading exercise

Transcript

00:00 Let's start from taking a look at what authentication methods we have in our app. If I go to the login page, I can see that the user can log in with their username and password. This is one of the most common ways to authenticate on the web. But they can also log in using their pass key and even external accounts like GitHub if they have any. Your task in this exercise is to test the username and password authentication option.

00:21 And to do that reliably, you have to understand how it works. So when the user submits their credentials, the client sends them to the server to validate. In other words, to make sure that the user by this username indeed exists in the database and they have provided the right password. What's important here for our tests is to understand that the user has to exist in the database for this authentication to succeed. And this is where you come in.

00:43 You will implement the create user utility that's gonna generate a test user and put it in the database. And once you're done with that, you will start with a test case focusing on the successful authentication flow. You will use that utility function to create a test user, and with those credentials, you will follow the UI and interact with it the same way the user would to eventually log in. And at the end, you will assert the successful authentication the same way the user would through the UI elements visible on the page. After that, you will have another test case focused on the failed authentication attempt, for example when the user provides wrong credentials.

01:15 And at the end, don't forget to run your tests to make sure that they are passing.