Test Auth Protection

In this section, test your setup to verify your authentication checks.

🤔

Tests not working?

If you get stuck, contact us and our development team will work directly with you to get unblocked.

Now that you've protected your frontend routes, components, and backend endpoints with authentication checks, it's time to verify your setup. Follow the quick tests below to confirm that your application blocks unauthenticated access as intended.

Test 1: Verify Frontend Blocks Unauthenticated Access

Unauthenticated users should not be able to access protected frontend routes or components. Perform the following steps to test this protection:

  1. First, ensure that your user does not have an active session. To do this, execute the logout flow by entering the URL of your Logout Endpoint (e.g., http://localhost:3001/auth/logout) into your browser's address bar and press Enter.
  2. Now that your user has been logged out, enter the URL of one of your application's protected routes into the browser's address bar and press Enter.
  3. If your authentication checks are working correctly, you should be redirected to your application's login page.

Test 2: Verify Backend Blocks Unauthenticated Access

Requests to protected backend endpoints without a valid session cookie should trigger a 401 Unauthorized status. Perform the following steps to test this protection:

  1. Use a tool like cURL or Postman to send a request to a protected backend endpoint; make sure not to include a valid session cookie in the request.
  2. Verify that the endpoint returns a 401 Unauthorized response.

Test 3: Verify Authenticated Users Can Access Protected Pages

Now, verify that an authenticated user can successfully view a protected page. The security check should succeed without redirecting. Follow these steps to test this flow:

  1. First, ensure that the user is logged in by entering the URL of your Login Endpoint (e.g., http://localhost:3001/auth/login) into your browser's address bar and press Enter.
  2. Complete the login flow by entering your credentials when prompted.
  3. After authenticating, you'll be redirected back to your application. At this point, you should be able to view any of your application's protected pages.

Once these tests pass, your authentication protection is verified and working as expected.







What’s Next

Congratulations! Your application now properly enforces user authentication. But there’s still plenty more you can do with our platform - let’s explore!

Did this page help you?