Skip to content

test: Add comprehensive tests for auth module#31

Merged
mverteuil merged 1 commit intomainfrom
test/improve-coverage
Feb 23, 2026
Merged

test: Add comprehensive tests for auth module#31
mverteuil merged 1 commit intomainfrom
test/improve-coverage

Conversation

@mverteuil
Copy link
Owner

Summary

  • Add tests/birdnetpi/utils/test_auth.py with 18 tests covering authentication utilities
  • Expand tests/birdnetpi/web/routers/test_auth_routes.py with SQLAdmin redirect tests

Coverage improvements

Module Before After
utils/auth.py 71% 100%
web/routers/auth_routes.py 68% 77%

Test details

  • Password hashing context (hash and verify)
  • AdminUser model creation
  • AuthService (load, save, verify, admin_exists)
  • require_admin_relative decorator (authentication, redirects)
  • SessionAuthBackend (session-based authentication)

Test plan

  • Run pytest locally - all tests pass
  • Pre-commit passes
  • CI passes

- Add test_auth.py with 18 tests covering:
  - Password hashing context (hash and verify)
  - AdminUser model creation
  - AuthService (load, save, verify, admin_exists)
  - require_admin_relative decorator (authentication, redirects)
  - SessionAuthBackend (session-based authentication)

- Expand test_auth_routes.py with SQLAdmin redirect tests

Coverage improvements:
- utils/auth.py: 71% -> 100%
- web/routers/auth_routes.py: 68% -> 77%
@mverteuil mverteuil merged commit cd2d3a6 into main Feb 23, 2026
4 checks passed
@mverteuil mverteuil deleted the test/improve-coverage branch February 23, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant