mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-29 02:08:10 +00:00
Upgrade fastapi and fix tests
This commit is contained in:
parent
8c7c17b889
commit
ce4dd17409
@ -54,7 +54,7 @@ async def login(
|
||||
) -> schemas.Token:
|
||||
"""
|
||||
Default user login method using forms (x-www-form-urlencoded).
|
||||
Example: curl http://host:port/v3/users/login -H "Content-Type: application/x-www-form-urlencoded" -d "username=admin&password=admin"
|
||||
Example: curl -X POST http://host:port/v3/access/users/login -H "Content-Type: application/x-www-form-urlencoded" -d "username=admin&password=admin"
|
||||
"""
|
||||
|
||||
user = await users_repo.authenticate_user(username=form_data.username, password=form_data.password)
|
||||
@ -76,7 +76,7 @@ async def authenticate(
|
||||
) -> schemas.Token:
|
||||
"""
|
||||
Alternative authentication method using json.
|
||||
Example: curl http://host:port/v3/users/authenticate -d '{"username": "admin", "password": "admin"}' -H "Content-Type: application/json"
|
||||
Example: curl -X POST http://host:port/v3/access/users/authenticate -d '{"username": "admin", "password": "admin"}' -H "Content-Type: application/json"
|
||||
"""
|
||||
|
||||
user = await users_repo.authenticate_user(username=user_credentials.username, password=user_credentials.password)
|
||||
|
@ -266,6 +266,7 @@ class TestUserLogin:
|
||||
(
|
||||
("wrong_username", "user1_password", status.HTTP_401_UNAUTHORIZED),
|
||||
("user1", "wrong_password", status.HTTP_401_UNAUTHORIZED),
|
||||
("user1", "", status.HTTP_401_UNAUTHORIZED),
|
||||
("user1", None, status.HTTP_422_UNPROCESSABLE_ENTITY),
|
||||
),
|
||||
)
|
||||
@ -284,6 +285,8 @@ class TestUserLogin:
|
||||
"username": username,
|
||||
"password": password,
|
||||
}
|
||||
if password is None:
|
||||
del login_data["password"]
|
||||
response = await unauthorized_client.post(app.url_path_for("login"), data=login_data)
|
||||
assert response.status_code == status_code
|
||||
assert "access_token" not in response.json()
|
||||
|
Loading…
Reference in New Issue
Block a user