Test Auth Protection

Verifying Your Authentication Checks.

🤔

Tests not working?

Stuck? Reach out to support and our developers will work directly with you to resolve the issue.

Previously, you restricted access to specific frontend routes, components, and backend endpoints. Now, let’s run a few quick tests to confirm that your route and API protections are working as expected.

Test 1: Verify Frontend Blocks Unauthenticated Access

o ensure your frontend routes and components correctly block unauthenticated access, perform the following steps:

  1. First, clear your active session by executing the logout flow. Enter your Logout Endpoint URL (e.g., http://localhost:3001/auth/logout) into your browser's address bar and press Enter.
  2. Next, enter the URL of a protected route into your browser's address bar and press Enter.
  3. If your checks are working correctly, you should be redirected to your application's login page.

Test 2: Verify Backend Blocks Unauthenticated Access

Protected backend endpoints must return a 401 Unauthorized response when a request lacks a valid session cookie. Follow these steps to verify this behavior:

  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

Next, verify that authenticated users can successfully access your protected pages. Follow these steps to test this behavior:

  1. First, ensure you have an active session by executing the login flow. Enter your Login Endpoint URL (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 will be redirected back to your application, where you can now view any of your protected pages.

If all tests pass, your authentication checks are working correctly.



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?