-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'guybartal/ci-multiple-lines' of https://github.com/micr…
…osoft/AzureTRE into guybartal/ci-multiple-lines
- Loading branch information
Showing
41 changed files
with
1,392 additions
and
330 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.8.2" | ||
__version__ = "0.8.3" |
File renamed without changes.
This file contains 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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.20.4" | ||
__version__ = "0.21.0" |
This file contains 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 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,38 @@ | ||
from fastapi import APIRouter, Depends, HTTPException, status as status_code | ||
from typing import List, Optional | ||
|
||
from api.helpers import get_repository | ||
from resources import strings | ||
from db.repositories.airlock_requests import AirlockRequestRepository | ||
from models.domain.airlock_request import AirlockRequest, AirlockRequestStatus, AirlockRequestType | ||
from services.authentication import get_current_tre_user_or_tre_admin | ||
|
||
router = APIRouter(dependencies=[Depends(get_current_tre_user_or_tre_admin)]) | ||
|
||
|
||
@router.get("/requests", response_model=List[AirlockRequest], name=strings.API_LIST_REQUESTS) | ||
async def get_requests( | ||
user=Depends(get_current_tre_user_or_tre_admin), | ||
airlock_request_repo: AirlockRequestRepository = Depends(get_repository(AirlockRequestRepository)), | ||
airlock_manager: bool = False, | ||
creator_user_id: Optional[str] = None, type: Optional[AirlockRequestType] = None, status: Optional[AirlockRequestStatus] = None, | ||
order_by: Optional[str] = None, order_ascending: bool = True | ||
) -> List[AirlockRequest]: | ||
try: | ||
if not airlock_manager: | ||
requests = await airlock_request_repo.get_airlock_requests( | ||
creator_user_id=creator_user_id or user.id, | ||
type=type, | ||
status=status, | ||
order_by=order_by, | ||
order_ascending=order_ascending, | ||
) | ||
else: | ||
requests = await airlock_request_repo.get_airlock_requests_for_airlock_manager(user) | ||
|
||
return requests | ||
|
||
except ValueError as ve: | ||
raise HTTPException(status_code=status_code.HTTP_400_BAD_REQUEST, detail=str(ve)) | ||
except Exception as e: | ||
raise HTTPException(status_code=status_code.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(e)) |
This file contains 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 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 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,42 @@ | ||
import pytest | ||
from fastapi import status | ||
from mock import patch | ||
|
||
from resources import strings | ||
from services.authentication import get_current_tre_user_or_tre_admin | ||
|
||
|
||
pytestmark = pytest.mark.asyncio | ||
|
||
|
||
class TestRequestsThatDontRequireAdminRigths: | ||
@pytest.fixture(autouse=True, scope='class') | ||
def log_in_with_non_admin_user(self, app, non_admin_user): | ||
with patch('services.aad_authentication.AzureADAuthorization._get_user_from_token', return_value=non_admin_user()): | ||
app.dependency_overrides[get_current_tre_user_or_tre_admin] = non_admin_user | ||
yield | ||
app.dependency_overrides = {} | ||
|
||
# [GET] /requests/ - get_requests | ||
@patch("api.routes.airlock.AirlockRequestRepository.get_airlock_requests", return_value=[]) | ||
async def test_get_all_requests_returns_200(self, _, app, client): | ||
response = await client.get(app.url_path_for(strings.API_LIST_REQUESTS)) | ||
assert response.status_code == status.HTTP_200_OK | ||
|
||
@patch("api.routes.airlock.AirlockRequestRepository.get_airlock_requests_for_airlock_manager") | ||
async def test_get_airlock_manager_requests_returns_200(self, mock_get_airlock_requests_for_airlock_manager, app, client): | ||
mock_get_airlock_requests_for_airlock_manager.return_value = [] | ||
response = await client.get(app.url_path_for(strings.API_LIST_REQUESTS), params={"airlock_manager": True}) | ||
|
||
assert response.status_code == status.HTTP_200_OK | ||
mock_get_airlock_requests_for_airlock_manager.assert_called_once() | ||
|
||
@patch("api.routes.airlock.AirlockRequestRepository.get_airlock_requests", side_effect=Exception("Internal Server Error")) | ||
async def test_get_all_requests_returns_500(self, _, app, client): | ||
response = await client.get(app.url_path_for(strings.API_LIST_REQUESTS)) | ||
assert response.status_code == status.HTTP_500_INTERNAL_SERVER_ERROR | ||
|
||
@patch("api.routes.airlock.AirlockRequestRepository.get_airlock_requests_for_airlock_manager", side_effect=Exception("Internal Server Error")) | ||
async def test_get_airlock_manager_requests_returns_500(self, _, app, client): | ||
response = await client.get(app.url_path_for(strings.API_LIST_REQUESTS), params={"airlock_manager": True}) | ||
assert response.status_code == status.HTTP_500_INTERNAL_SERVER_ERROR |
Oops, something went wrong.