You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add /auth/login endpoint for jwt securitzation (#13)
* Refactor existing test_app fixture for mock database with user inserted
* Install and initialize Flask-Bcrypt globally in app
* Use Flask-Bcrypt in mock_user_data fixture; standardize password key
* Add /auth/login test suite covering success, failures, and edge cases
- Test valid login returns 200 with correct JWT payload
- Test wrong password returns 401 with 'Invalid credentials'
- Test non-existent user returns 401
- Test missing data returns 400 with specific error message
- Parametrize payload variations for missing data cases
- Test PyJWT encoding error returns 500 with proper message
* Implement /login route with JWT authentication using PyJWT
- Validate email and password from request
- Look up user in MongoDB
- Verify password hash with Flask-Bcrypt
- Generate JWT with sub, iat, and exp claims
- Handle PyJWTError with 500 response
* Add minimal Flask app & route to isolate decorator
* Add tests 4 jwt.decode errors with monkeypatch + unittest.mock patch
* Add tests for invalid user_id in token and missing user in DB
* Add test for require_jwt decorator happy path
* Add require_jwt decorator: validate Bearer token and attach user
* Drop default key; set SECRET_KEY via test_app fixture
0 commit comments