Post by account_disabled on Jan 1, 2024 21:11:09 GMT -8
Should respond with a status code of success user details When of success it should respond with a valid session token When given invalid When credentials are given it should respond with a status code When the user is not found it should respond with a status code When an invalid request body is given it should respond with a status code Before testing each scenario you need to define another set of tests to test the All tests related to this endpoint are grouped. Add another copy for the route under the closing tag that defines the test suite. The tests you will write in this suite will also require the user to exist in the database as you will be the login function. In the block you just added you can use the function before each test to add users to the database. Add the following to your new test suite Copy Note It is important to note that the encryption method for the password here must exactly match the encryption method used in . Now that the initial setup for this set of tests is complete you can.
Move on to writing your tests. Just like before, the next six sections will cover each scenario individually and walk through how the test works. It should respond with photo editing servies a status code when valid credentials are provided. The first test will only verify a valid login request and the correct credentials in the response code from the result. Start by adding a new test in the block of this set of tests just below the function Copy To test the desired behavior send a request to the endpoint using the same username and password used to create the test user. Then verify that the status code of the response is After copying successfully it should respond with the user details The next test is very similar to the previous one except instead of checking the response status you will check the object in the response body and validate its content. Add another test with the following content Copy the above test content Do the following.
Send a request The request body contains the test user's username and password Extract the keys for the response body object Verify that there are two keys in the response and the value of and matches the test user's username On success it should respond with a valid session token. In this test you will again follow a very similar process to the previous two tests. Only this test will verify that a valid session token is present in the response body. Add the following test below the previous test Copy As you can see above the request is sent to the target endpoint and the response body is abstracted from the result. This function is used to verify the presence of the key in the response body. This function is then used to verify the session token. Note: It is important to note that similar to password encryption, it is also important to validate the session.
Move on to writing your tests. Just like before, the next six sections will cover each scenario individually and walk through how the test works. It should respond with photo editing servies a status code when valid credentials are provided. The first test will only verify a valid login request and the correct credentials in the response code from the result. Start by adding a new test in the block of this set of tests just below the function Copy To test the desired behavior send a request to the endpoint using the same username and password used to create the test user. Then verify that the status code of the response is After copying successfully it should respond with the user details The next test is very similar to the previous one except instead of checking the response status you will check the object in the response body and validate its content. Add another test with the following content Copy the above test content Do the following.
Send a request The request body contains the test user's username and password Extract the keys for the response body object Verify that there are two keys in the response and the value of and matches the test user's username On success it should respond with a valid session token. In this test you will again follow a very similar process to the previous two tests. Only this test will verify that a valid session token is present in the response body. Add the following test below the previous test Copy As you can see above the request is sent to the target endpoint and the response body is abstracted from the result. This function is used to verify the presence of the key in the response body. This function is then used to verify the session token. Note: It is important to note that similar to password encryption, it is also important to validate the session.