mirror of
https://github.com/rjNemo/fastapi
synced 2026-06-11 04:56:41 +00:00
🎨 Fix missing format
This commit is contained in:
parent
804ec460fc
commit
c3e5e65093
2 changed files with 6 additions and 2 deletions
|
|
@ -17,7 +17,7 @@ fake_users_db = {
|
||||||
"email": "alice@example.com",
|
"email": "alice@example.com",
|
||||||
"hashed_password": "fakehashedsecret2",
|
"hashed_password": "fakehashedsecret2",
|
||||||
"disabled": True,
|
"disabled": True,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,9 @@ def test_login():
|
||||||
|
|
||||||
|
|
||||||
def test_login_incorrect_password():
|
def test_login_incorrect_password():
|
||||||
response = client.post("/token", data={"username": "johndoe", "password": "incorrect"})
|
response = client.post(
|
||||||
|
"/token", data={"username": "johndoe", "password": "incorrect"}
|
||||||
|
)
|
||||||
assert response.status_code == 400
|
assert response.status_code == 400
|
||||||
assert response.json() == {"detail": "Incorrect username or password"}
|
assert response.json() == {"detail": "Incorrect username or password"}
|
||||||
|
|
||||||
|
|
@ -154,6 +156,7 @@ def test_incorrect_token():
|
||||||
assert response.status_code == 400
|
assert response.status_code == 400
|
||||||
assert response.json() == {"detail": "Invalid authentication credentials"}
|
assert response.json() == {"detail": "Invalid authentication credentials"}
|
||||||
|
|
||||||
|
|
||||||
def test_incorrect_token_type():
|
def test_incorrect_token_type():
|
||||||
response = client.get(
|
response = client.get(
|
||||||
"/users/me", headers={"Authorization": "Notexistent testtoken"}
|
"/users/me", headers={"Authorization": "Notexistent testtoken"}
|
||||||
|
|
@ -161,6 +164,7 @@ def test_incorrect_token_type():
|
||||||
assert response.status_code == 403
|
assert response.status_code == 403
|
||||||
assert response.json() == {"detail": "Not authenticated"}
|
assert response.json() == {"detail": "Not authenticated"}
|
||||||
|
|
||||||
|
|
||||||
def test_inactive_user():
|
def test_inactive_user():
|
||||||
response = client.get("/users/me", headers={"Authorization": "Bearer alice"})
|
response = client.get("/users/me", headers={"Authorization": "Bearer alice"})
|
||||||
assert response.status_code == 400
|
assert response.status_code == 400
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue