mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-10-27 18:52:23 +02:00
Changed errors to new type, was causing warnings
This commit is contained in:
parent
69eafda777
commit
4a45a68703
@ -207,7 +207,7 @@ async def sqlalchemy_error_handler(request: Request, exc: SQLAlchemyError):
|
|||||||
async def validation_exception_handler(request: Request, exc: RequestValidationError):
|
async def validation_exception_handler(request: Request, exc: RequestValidationError):
|
||||||
log.error(f"Request validation error in {request.url.path} ({request.method}): {exc}")
|
log.error(f"Request validation error in {request.url.path} ({request.method}): {exc}")
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
||||||
content={"message": str(exc)}
|
content={"message": str(exc)}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -297,7 +297,7 @@ class TestEthernetSwitchNodesRoutes:
|
|||||||
node_id=ethernet_switch["node_id"]),
|
node_id=ethernet_switch["node_id"]),
|
||||||
json=port_params
|
json=port_params
|
||||||
)
|
)
|
||||||
assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY
|
assert response.status_code == status.HTTP_422_UNPROCESSABLE_CONTENT
|
||||||
|
|
||||||
|
|
||||||
async def test_ethernet_switch_delete(
|
async def test_ethernet_switch_delete(
|
||||||
|
|||||||
@ -133,7 +133,7 @@ class TestTemplateRoutes:
|
|||||||
"template_type": "invalid_template_type"}
|
"template_type": "invalid_template_type"}
|
||||||
|
|
||||||
response = await client.post(app.url_path_for("create_template"), json=params)
|
response = await client.post(app.url_path_for("create_template"), json=params)
|
||||||
assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY
|
assert response.status_code == status.HTTP_422_UNPROCESSABLE_CONTENT
|
||||||
|
|
||||||
async def test_template_update(self, app: FastAPI, client: AsyncClient) -> None:
|
async def test_template_update(self, app: FastAPI, client: AsyncClient) -> None:
|
||||||
|
|
||||||
|
|||||||
@ -75,10 +75,10 @@ class TestUserRoutes:
|
|||||||
(
|
(
|
||||||
("email", "user2@email.com", status.HTTP_400_BAD_REQUEST),
|
("email", "user2@email.com", status.HTTP_400_BAD_REQUEST),
|
||||||
("username", "user2", status.HTTP_400_BAD_REQUEST),
|
("username", "user2", status.HTTP_400_BAD_REQUEST),
|
||||||
("email", "invalid_email@one@two.io", status.HTTP_422_UNPROCESSABLE_ENTITY),
|
("email", "invalid_email@one@two.io", status.HTTP_422_UNPROCESSABLE_CONTENT),
|
||||||
("password", "short", status.HTTP_422_UNPROCESSABLE_ENTITY),
|
("password", "short", status.HTTP_422_UNPROCESSABLE_CONTENT),
|
||||||
("username", "user2@#$%^<>", status.HTTP_422_UNPROCESSABLE_ENTITY),
|
("username", "user2@#$%^<>", status.HTTP_422_UNPROCESSABLE_CONTENT),
|
||||||
("username", "ab", status.HTTP_422_UNPROCESSABLE_ENTITY),
|
("username", "ab", status.HTTP_422_UNPROCESSABLE_CONTENT),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
async def test_user_registration_fails_when_credentials_are_taken(
|
async def test_user_registration_fails_when_credentials_are_taken(
|
||||||
@ -101,10 +101,10 @@ class TestUserRoutes:
|
|||||||
("email", "user@email.com", status.HTTP_200_OK),
|
("email", "user@email.com", status.HTTP_200_OK),
|
||||||
("email", "user@email.com", status.HTTP_400_BAD_REQUEST),
|
("email", "user@email.com", status.HTTP_400_BAD_REQUEST),
|
||||||
("username", "user2", status.HTTP_400_BAD_REQUEST),
|
("username", "user2", status.HTTP_400_BAD_REQUEST),
|
||||||
("email", "invalid_email@one@two.io", status.HTTP_422_UNPROCESSABLE_ENTITY),
|
("email", "invalid_email@one@two.io", status.HTTP_422_UNPROCESSABLE_CONTENT),
|
||||||
("password", "short", status.HTTP_422_UNPROCESSABLE_ENTITY),
|
("password", "short", status.HTTP_422_UNPROCESSABLE_CONTENT),
|
||||||
("username", "user2@#$%^<>", status.HTTP_422_UNPROCESSABLE_ENTITY),
|
("username", "user2@#$%^<>", status.HTTP_422_UNPROCESSABLE_CONTENT),
|
||||||
("username", "ab", status.HTTP_422_UNPROCESSABLE_ENTITY),
|
("username", "ab", status.HTTP_422_UNPROCESSABLE_CONTENT),
|
||||||
("full_name", "John Doe", status.HTTP_200_OK),
|
("full_name", "John Doe", status.HTTP_200_OK),
|
||||||
("password", "password123", status.HTTP_200_OK),
|
("password", "password123", status.HTTP_200_OK),
|
||||||
("is_active", True, status.HTTP_200_OK),
|
("is_active", True, status.HTTP_200_OK),
|
||||||
@ -259,7 +259,7 @@ class TestUserLogin:
|
|||||||
(
|
(
|
||||||
("wrong_username", "user1_password", status.HTTP_401_UNAUTHORIZED),
|
("wrong_username", "user1_password", status.HTTP_401_UNAUTHORIZED),
|
||||||
("user1", "wrong_password", status.HTTP_401_UNAUTHORIZED),
|
("user1", "wrong_password", status.HTTP_401_UNAUTHORIZED),
|
||||||
("user1", None, status.HTTP_422_UNPROCESSABLE_ENTITY),
|
("user1", None, status.HTTP_422_UNPROCESSABLE_CONTENT),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
async def test_user_with_wrong_creds_doesnt_receive_token(
|
async def test_user_with_wrong_creds_doesnt_receive_token(
|
||||||
|
|||||||
@ -62,4 +62,4 @@ class TestVersionRoutes:
|
|||||||
|
|
||||||
params = "BOUM"
|
params = "BOUM"
|
||||||
response = await client.post(app.url_path_for("check_version"), json=params)
|
response = await client.post(app.url_path_for("check_version"), json=params)
|
||||||
assert response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY
|
assert response.status_code == status.HTTP_422_UNPROCESSABLE_CONTENT
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user