mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-10-22 19:02:23 +03:00
Merge pull request #2950 from markparonyan/api-issue-14-yywwso
fix(api): return 200 instead of 201 for ACL endpoints, IOU license up…
This commit is contained in:
commit
0836e01525
@ -80,7 +80,7 @@ def _iter_route_paths(routes: Sequence[BaseRoute], prefix: str = "", include_mou
|
|||||||
yield from _iter_route_paths(mounted_routes, _join_paths(prefix, route.path), include_mounted_routes)
|
yield from _iter_route_paths(mounted_routes, _join_paths(prefix, route.path), include_mounted_routes)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/endpoints", status_code=status.HTTP_201_CREATED, dependencies=[Depends(has_privilege("ACE.Audit"))])
|
@router.get("/endpoints", dependencies=[Depends(has_privilege("ACE.Audit"))])
|
||||||
async def endpoints(
|
async def endpoints(
|
||||||
users_repo: UsersRepository = Depends(get_repository(UsersRepository)),
|
users_repo: UsersRepository = Depends(get_repository(UsersRepository)),
|
||||||
rbac_repo: RbacRepository = Depends(get_repository(RbacRepository)),
|
rbac_repo: RbacRepository = Depends(get_repository(RbacRepository)),
|
||||||
|
|||||||
@ -146,7 +146,7 @@ def get_iou_license() -> schemas.IOULicense:
|
|||||||
@router.put(
|
@router.put(
|
||||||
"/iou_license",
|
"/iou_license",
|
||||||
dependencies=[Depends(get_current_active_user)],
|
dependencies=[Depends(get_current_active_user)],
|
||||||
status_code=status.HTTP_201_CREATED,
|
status_code=status.HTTP_200_OK,
|
||||||
response_model=schemas.IOULicense,
|
response_model=schemas.IOULicense,
|
||||||
)
|
)
|
||||||
async def update_iou_license(iou_license: schemas.IOULicense) -> schemas.IOULicense:
|
async def update_iou_license(iou_license: schemas.IOULicense) -> schemas.IOULicense:
|
||||||
|
|||||||
@ -495,7 +495,7 @@ async def close_project(project: Project = Depends(dep_project)) -> None:
|
|||||||
|
|
||||||
@router.post(
|
@router.post(
|
||||||
"/{project_id}/open",
|
"/{project_id}/open",
|
||||||
status_code=status.HTTP_201_CREATED,
|
status_code=status.HTTP_200_OK,
|
||||||
response_model=schemas.Project,
|
response_model=schemas.Project,
|
||||||
responses={**responses, 409: {"model": schemas.ErrorMessage, "description": "Could not open project"}},
|
responses={**responses, 409: {"model": schemas.ErrorMessage, "description": "Could not open project"}},
|
||||||
dependencies=[Depends(has_privilege("Project.Allocate"))],
|
dependencies=[Depends(has_privilege("Project.Allocate"))],
|
||||||
|
|||||||
@ -106,7 +106,7 @@ async def delete_snapshot(
|
|||||||
|
|
||||||
@router.post(
|
@router.post(
|
||||||
"/{snapshot_id}/restore",
|
"/{snapshot_id}/restore",
|
||||||
status_code=status.HTTP_201_CREATED,
|
status_code=status.HTTP_200_OK,
|
||||||
response_model=schemas.Project,
|
response_model=schemas.Project,
|
||||||
dependencies=[Depends(has_privilege("Snapshot.Restore"))],
|
dependencies=[Depends(has_privilege("Snapshot.Restore"))],
|
||||||
)
|
)
|
||||||
|
|||||||
@ -161,3 +161,8 @@ class TestACLRoutes:
|
|||||||
|
|
||||||
# the ACE should have been deleted after deleting the project
|
# the ACE should have been deleted after deleting the project
|
||||||
assert not await rbac_repo.get_ace_by_path(path)
|
assert not await rbac_repo.get_ace_by_path(path)
|
||||||
|
|
||||||
|
async def test_get_endpoints(self, app: FastAPI, client: AsyncClient) -> None:
|
||||||
|
|
||||||
|
response = await client.get(app.url_path_for("endpoints"))
|
||||||
|
assert response.status_code == status.HTTP_200_OK
|
||||||
|
|||||||
@ -70,3 +70,10 @@ class TestControllerRoutes:
|
|||||||
|
|
||||||
response = await client.get(app.url_path_for("statistics"))
|
response = await client.get(app.url_path_for("statistics"))
|
||||||
assert response.status_code == status.HTTP_200_OK
|
assert response.status_code == status.HTTP_200_OK
|
||||||
|
|
||||||
|
async def test_update_iou_license(self, app: FastAPI, client: AsyncClient) -> None:
|
||||||
|
|
||||||
|
license_settings = {"iourc_content": "[license]\ngns3vm = 1234567890abcdef;", "license_check": False}
|
||||||
|
response = await client.put(app.url_path_for("update_iou_license"), json=license_settings)
|
||||||
|
assert response.status_code == status.HTTP_200_OK
|
||||||
|
assert response.json() == license_settings
|
||||||
|
|||||||
@ -216,7 +216,7 @@ class TestControllerProjectRoutes:
|
|||||||
|
|
||||||
with asyncio_patch("gns3server.controller.project.Project.open", return_value=True) as mock:
|
with asyncio_patch("gns3server.controller.project.Project.open", return_value=True) as mock:
|
||||||
response = await client.post(app.url_path_for("open_project", project_id=project.id))
|
response = await client.post(app.url_path_for("open_project", project_id=project.id))
|
||||||
assert response.status_code == status.HTTP_201_CREATED
|
assert response.status_code == status.HTTP_200_OK
|
||||||
assert mock.called
|
assert mock.called
|
||||||
|
|
||||||
async def test_load_project(self, app: FastAPI, client: AsyncClient, project: Project, config) -> None:
|
async def test_load_project(self, app: FastAPI, client: AsyncClient, project: Project, config) -> None:
|
||||||
|
|||||||
@ -72,7 +72,7 @@ class TestSnapshotRoutes:
|
|||||||
response = await client.post(
|
response = await client.post(
|
||||||
app.url_path_for("restore_snapshot", project_id=project.id, snapshot_id=snapshot.id)
|
app.url_path_for("restore_snapshot", project_id=project.id, snapshot_id=snapshot.id)
|
||||||
)
|
)
|
||||||
assert response.status_code == status.HTTP_201_CREATED
|
assert response.status_code == status.HTTP_200_OK
|
||||||
assert response.json()["name"] == project.name
|
assert response.json()["name"] == project.name
|
||||||
|
|
||||||
async def test_create_snapshot(self, app: FastAPI, client: AsyncClient, project: Project) -> None:
|
async def test_create_snapshot(self, app: FastAPI, client: AsyncClient, project: Project) -> None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user