Test Auth Protection
Verify that your authentication checks are configured correctly.
Tests not working?Need help? Contact our team to resolve the issue.
To verify your authentication protections, run three key tests:
- Check frontend route blocking
- Test backend API rejection
- Confirm access for authenticated user
Test 1: Verify Frontend Blocks Unauthenticated Access
To verify that your frontend routes and components successfully block unauthenticated users, complete these explicit testing steps:
- Log out: Go to your logout URL (e.g., http://localhost:3001/auth/logout) to clear any active session.
- Test route: Try to visit a protected page by typing its URL into your browser bar.
- Verify redirect: Make sure the app sends you to the login page.
Test 2: Verify Backend Blocks Unauthenticated Access
To test your protected backend endpoints, send an unauthenticated request and verify the server rejects it.
- Use a tool such as cURL or Postman to send a request to a protected backend endpoint without including a valid session cookie.
- Verify the endpoint returns a
401 Unauthorizedresponse.
Test 3: Verify Authenticated Users Can Access Protected Pages
To verify that authenticated users can successfully access restricted areas, complete the following steps:
- Start the login flow by entering the URL of your Login Endpoint, such as http://localhost:3001/auth/login, in your browser's address bar, then press Enter.
- Complete the login flow by entering your credentials when prompted.
- After authentication completes, confirm you are redirected back to your application.
Access your application's protected pages.
If the tests above succeed, your authentication checks are working correctly.
Updated 3 days ago
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!