-
Notifications
You must be signed in to change notification settings - Fork 0
test: auth tests, 401 coverage, and test suite gaps #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
811d061
test: implement auth integration tests
podmar 6088fc0
test: add unathorized test for each endpoint
podmar 0effb0c
test: supress fastapi-users decprecation warnings
podmar be170f2
test: boundary of expiring items
podmar a17b046
test: isolation for single items
podmar 862ed38
chore: update til with session learnings
podmar 0bd80fb
chore: fix til formating
podmar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| from httpx import AsyncClient | ||
|
|
||
|
|
||
| async def test_register_creates_user(client: AsyncClient): | ||
| resp = await client.post( | ||
| "/auth/register", json={"email": "alice@test.com", "password": "testpass123"} | ||
| ) | ||
| assert resp.status_code == 201 | ||
| body = resp.json() | ||
| assert body["email"] == "alice@test.com" | ||
| assert "password" not in body | ||
|
|
||
|
|
||
| async def test_register_duplicate_email_returns_400(client: AsyncClient): | ||
| await client.post( | ||
| "/auth/register", json={"email": "alice@test.com", "password": "testpass123"} | ||
| ) | ||
| resp = await client.post( | ||
| "/auth/register", json={"email": "alice@test.com", "password": "testpass123"} | ||
| ) | ||
| assert resp.status_code == 400 | ||
|
|
||
|
|
||
| async def test_register_invalid_email_returns_422(client: AsyncClient): | ||
| resp = await client.post( | ||
| "/auth/register", json={"email": "not-an-email", "password": "testpass123"} | ||
| ) | ||
| assert resp.status_code == 422 | ||
|
|
||
|
|
||
| async def test_login_returns_token(client: AsyncClient): | ||
| await client.post( | ||
| "/auth/register", json={"email": "alice@test.com", "password": "testpass123"} | ||
| ) | ||
| resp = await client.post( | ||
| "/auth/jwt/login", | ||
| data={"username": "alice@test.com", "password": "testpass123"}, | ||
| ) | ||
| assert resp.status_code == 200 | ||
| assert "access_token" in resp.json() | ||
|
|
||
|
|
||
| async def test_login_wrong_password_returns_400(client: AsyncClient): | ||
| await client.post( | ||
| "/auth/register", json={"email": "alice@test.com", "password": "testpass123"} | ||
| ) | ||
| resp = await client.post( | ||
| "/auth/jwt/login", | ||
| data={"username": "alice@test.com", "password": "wrongpassword"}, | ||
| ) | ||
| assert resp.status_code == 400 | ||
|
|
||
|
|
||
| async def test_login_unknown_email_returns_400(client: AsyncClient): | ||
| resp = await client.post( | ||
| "/auth/jwt/login", | ||
| data={"username": "nobody@test.com", "password": "testpass123"}, | ||
| ) | ||
| assert resp.status_code == 400 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good boundary test! This confirms that the
<=operator on line 271 ofbatches.pyis correct — batches expiring on the cutoff day should be included. A common off-by-one bug in expiry logic.This is the kind of test that catches subtle regressions when someone "simplifies" the query later.